PAT-A-1134

PAT-A-1134

bad Code

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
#include <iostream>
#include <vector>

using namespace std;
int v, e, k, qu,q;
const int maxn = 10005;
vector<int> edge[maxn];
vector<int> cop[maxn];

int main() {
scanf("%d%d", &v, &e);
for (int i = 0; i < e; i++) {
int v1, v2;
scanf("%d%d", &v1, &v2);
edge[v1].push_back(v2);
edge[v2].push_back(v1);
}
scanf("%d", &k);
while (k--) {
for (int i = 0; i < maxn; i++) {
cop[i] = edge[i];
}
scanf("%d", &qu);
while(qu--){
scanf("%d", &q);
//每个顶点i来说,iq,qi 不为-1则变-1
for (int i = 0; i < maxn; i++) {
for (int j = 0; j < cop[i].size(); j++) {
//i->q
if (cop[i][j] == q) {
cop[i][j] = -1;
}
}
for (int j = 0; j < cop[q].size(); j++) {
//q->i
if (cop[q][j] == i) cop[q][j] = -1;
}
}
}
bool flag = true;
for (int i = 0; i < maxn; i++) {
for (auto it :cop[i]) {
if (it != -1) flag = false;
}
}
if (flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2020-2023 Jack Kong
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信