1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
using namespace std; map<int,map<int, int> >M; vector<int>database[10005]; int test, total_number, group; int initial_data[10005]; map<int, int>book; void show(map<int, int> m) { map<int, int>::iterator it; it = m.begin(); cout << it->first << "=" << it->second; for (it++; it != m.end(); it++) { cout << "," << it->first << "=" << it->second; } } int main() { cin >> test; for (int k = 1; k <= test; k++) { cin >> total_number; for (int i = 1; i <= total_number; i++) { cin >> initial_data[i]; book[initial_data[i]]++; } for (int i = 1; i <= total_number; i++) { cin >> group; M[group][initial_data[i]]++; } map<int, map<int, int>>::iterator it; map<int, int>::iterator check; for (it = M.begin(); it != M.end(); it++) { cout << it->first << "={"; for (check = book.begin(); check != book.end(); check++) { if (check == book.begin()) { cout << check->first << "=" << it->second[check->first]; } else cout << "," << check->first << "=" << it->second[check->first]; } cout << "}" << endl; } M.clear(); book.clear(); } return 0; }
|