用力戳我直达原题
给情侣配对,再输入场地里的所有人,按增序输出单身狗。
本题很简单,将场地里的人用set存起来,然后跑一遍情侣,如果一对都在set里,则erase掉两人。
问题是格式:错了一个样例,有点像cumt校赛一道坑人题。对待格式错误的办法无非是空格,回车两种。检查了下发现空格绝对没错,那就剩下回车了。
当场地里没有单身狗,输出了 0 << endl; 然后没输出第二行然后接着endl,这样就出现了两个endl;
不过,这种问题是很迷的。。。总之PE就抓空格 回车。
|
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
|
#include <bits/stdc++.h>using namespace std;int main(){ int n,m; string s[50050][2]; scanf("%d",&n); for(int i = 0; i < n; i++) cin >> s[i][0] >> s[i][1]; set<string>st; string tp; scanf("%d",&m); while(m--) { cin >> tp; st.insert(tp); } for(int i = 0; i < n; i++) { if( st.find(s[i][0]) != st.end() && st.find(s[i][1]) != st.end() ) { st.erase(s[i][0]); st.erase(s[i][1]); } } cout << st.size() << endl; set<string>::iterator it = st.begin(); bool cnt = false; for(it; it != st.end(); it++) { if(cnt) cout << ' '; cnt = true; cout << *it; }// cout << endl;} |