先用普通数组存一遍,然后第二个奖项用set存,第三遍存vector,他让你按他给的顺序,没让你按字典序
by douhuazhenren1 @ 2024-03-28 19:54:20
用结构体记录一下每个点的`id`(即输入顺序),最后按答案`id`顺序输出。
by weak_in_code @ 2024-03-28 19:54:41
其实 `map` 能很好的解决本题。
by weak_in_code @ 2024-03-28 19:55:34
@[douhuazhenren1](/user/1120417) 我寻思我也没统计总数啊
by XuYu0317 @ 2024-03-28 19:57:39
还有一种做法是,把第一个数组存起来,把第二个数组存进map中,遍历第一个数组查找数量输出。
by weak_in_code @ 2024-03-28 19:58:53
@[XuYu0317](/user/1120928)
还是删的不及时
by douhuazhenren1 @ 2024-03-28 19:58:54
@[weak_in_code](/user/753640) thx.我去试一下
by XuYu0317 @ 2024-03-28 19:59:21
@[XuYu0317](/user/1120928) 其实有一种东西叫:`unordered_set`
by c20251920TBN @ 2024-03-28 20:00:23
@[c20251920TBN](/user/928604) 这也保证不了原序啊
by sdyzpf @ 2024-03-28 20:02:55
```cpp
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
using namespace std;
int n, m;
map<int,int> a;
int b[200100];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i ++) { // 读入a
scanf("%d", &b[i]);
}
for (int i = 1, d; i <= m; i ++) { // 读入b
scanf("%d", &d);
a[d]++;
}
for (int i = 1; i <= n;i ++){
if (a[b[i]]==1) printf("%d ",b[i]);
}
return 0;
}
```
打完了,~~特意用的作者马蜂不知道一不一样。~~
by weak_in_code @ 2024-03-28 20:06:59