1149 Dangerous Goods Packaging

Posted wsggb123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1149 Dangerous Goods Packaging相关的知识,希望对你有一定的参考价值。

感觉又学到了。。。

 1 #include <iostream>
 2 #include <stdlib.h>
 3 #include <string>
 4 #include<algorithm>
 5 #include<vector>
 6 #include<cmath>
 7 #include<map>
 8 #include<set>
 9 #include <unordered_map>
10 using namespace std;
11 
12 int main(){
13     static vector<int> m1[100000];
14 
15     int n, m;
16     cin >> n >> m;
17     for (int i = 0; i < n; i++) {
18         int t1, t2;
19         cin >> t1 >> t2;
20         m1[t1].push_back(t2);
21         m1[t2].push_back(t1);
22     }
23 
24     for (int i = 0; i < m; i++) {
25         int num;
26         cin >> num;
27         int list[1001];
28         for (int j = 0; j < num; j++) {
29             cin >> list[j];
30         }
31         bool f = 0;
32         for (int j = 0; j < num; j++) {
33             for (int k = j; k < num; k++) {
34                 if (find(m1[list[j]].begin(), m1[list[j]].end(), list[k]) != m1[list[j]].end()) {
35                     f = 1;
36                 }
37             }
38         }
39         if (f == 0) {
40             cout << "Yes" << endl;
41         }
42         else {
43             cout << "No" << endl;
44         }
45     }
46     
47     system("pause");
48 };

 

以上是关于1149 Dangerous Goods Packaging的主要内容,如果未能解决你的问题,请参考以下文章

PAT A1149 Dangerous Goods Packaging (25 分)

1149 Dangerous Goods Packaging

A1149:Dangerous Goods Packaging (25)

1149 Dangerous Goods Packaging (25 分)难度: 一般 / 知识点: 哈希表

A1149 Dangerous Goods Packaging (25分)

UVAlive--4529--Dangerous Tunnels(二分+拆点最大流)