文章

43

粉丝

180

获赞

21

访问

196.1k

头像
c++
P1448 北京理工大学机试题
发布于2022年4月30日 17:01
阅读数 4.7k

#include <iostream>
using namespace std;
const int N = 1e5 + 10;

int m, n, x, a[N], map[110][N];
int c[N];

int main()
{
	cin >> m;
	while (m -- )
	{
		cin >> n;
		for (int i = 1; i <= n; i ++ ) 
		{
			cin >> a[i]; 
			map[0][a[i]] ++;
		}
		int p = 0, mx = 0;
		for (int i = 0; i < N; i ++ ) if (map[0][i]) c[p ++ ] = i;
		for (int i = 1; i <= n; i ++ ) 
		{
			cin >> x;
			mx = max(mx, x);
			map[x][a[i]] ++;
		}
		for (int i = 1; i <= mx; i ++ )
		{
			cout << i << "={";
			for (int j = 0; j < p - 1; j ++ ) cout << c[j] << "=" << map[i][c[j]] << ",";
			cout << c[p - 1] << "=" << map[i][c[p - 1]] << "}" << endl;
		}
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发