题意:
给三组数字, 第二组为在第一组数字上缺少一个,第三组在第二组数字上缺少一个 ?
求缺少的数字
直接map统计个数即可
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define CLR(a,b) memset(a,(b),sizeof(a))
#define ls st<<1
#define rs st<<1|1
const int INF = 0x3f3f3f3f;
const int MAXN = (int)2e5+10;
const int mod = (int)1e9+7;
int arr[MAXN];
map<int, int> mp;
int a[MAXN], b[MAXN], c[MAXN];
int main() {
int n, x;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> a[i];
}
for(int i = 0; i < n-1; ++i) {
cin >> b[i];
}
for(int i = 0; i < n-2; ++i) {
cin >> c[i];
}
for(int i = 0; i < n-1; i++) {
mp[b[i]]++;
}
for(int i = 0; i < n; ++i) {
mp[a[i]]--;
if(mp[a[i]] == -1) {
cout << a[i] << endl;
break;
}
}
mp.clear();
for(int i = 0; i < n-2; ++i) {
mp[c[i]]++;
}
for(int i = 0; i < n-1; ++i) {
mp[b[i]]--;
if(mp[b[i]] == -1) {
cout << b[i] << endl;
break;
}
}
return 0;
}