Description
又开始签到了,每天早上签到的人有n人之多(1<=n<=1000,000),每个人的学号是1到2*10^9之间的一个整数,现在来了n个人,想知道谁没有来。
Input
输入多组案例
第一行是n
接下来n行,是n个人的学号
最后n-1行是来了的人的学号
Output
输出没有来的人的学号
Sample Input
3 10061061 10061023 10061201 10061061 10061023
Sample Output
10061201
---------------------------------------------------------------------------------------------------------------------------------
(14条消息) (学习小记 认识map函数)PAT (Basic Level) Practice (中文)1069 微博转发抽奖 (20 分)_鬼樱G_Cher的博客-CSDN博客前天刚刚学习了map函数今天算是现学现用了。这道题有人写过用异或的方法,我用的是map。
(我自我感觉挺精简的然而并没有那么精简的代码其实异或很简单)ac代码↓
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
string a[maxn];
int main()
{
int T,i;
string aa;
map<string,bool>id;
while(cin>>T)
{
for(i=0;i<T;i++)
cin>>a[i],id[a[i]]=true;//应到学生记作true
for(i=0;i<T-1;i++)
cin>>aa,id[aa]=false;//实到学生记作false
for(i=0;i<T;i++)
if(id[a[i]]==true)//剩下的就是未到的学生
cout<<a[i];
}
return 0;
}