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 };

原文地址:https://www.cnblogs.com/wsggb123/p/10225999.html

时间: 2024-10-10 11:14:20

1149 Dangerous Goods Packaging的相关文章

pat 1149 Dangerous Goods Packaging(25 分)

1149 Dangerous Goods Packaging(25 分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be

PAT A1149 Dangerous Goods Packaging (25 分)

When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易燃液体),

A题目

1 1001 A+B Format(20) 2 1002 A+B for Polynomials(25) 3 1003 Emergency(25) 4 1004 Counting Leaves(30) 5 1005 Spell It Right(20) 6 1006 Sign In and Sign Out(25) 7 1007 Maximum Subsequence Sum(25) 8 1008 Elevator(20) 9 1009 Product of Polynomials(25) 10

PAT 2018 秋

A 1148 Werewolf - Simple Version 思路比较直接:模拟就行.因为需要序列号最小的两个狼人,所以以狼人为因变量进行模拟. 1 #include <cstdio> 2 #include <cstdlib> 3 #include <iostream> 4 #include <algorithm> 5 #include <vector> 6 7 using namespace std; 8 int N; 9 vector&l

2018.9.8pat秋季甲级考试

第一次参加pat考试,结果很惨,只做了中间两道题,还有一个测试点错误,所以最终只得了不到50分.题目是甲级练习题的1148-1151. 考试时有些紧张,第一题第二题开始测试样例都运行不正确,但是调试程序考场的vs2013不能粘贴,还得一点点输上去.浪费了很多时间. 1.Werewolf - Simple Version 之前遇到这种题目较少,所以刚开始没什么思路.后来想到的方法是假设撒谎的两个人分别是i.j,然后遍历所有i.j,找出符合条件的.当时总共用了得有一个小时,但程序一直得不到正确答案,

SAP BAPI一览 史上最全

全BADI一览  List of BAPI's       BAPI WG Component Function module name Description Description Obj. Type Object name Method name Release Message type   1 RW TR BAPI_SECURITYPRICE_GETDETAIL Security price Import a single security price BUS1099 SecurityP

BAPI list

[转自] BAPI WG Component Function module name Description Description Obj. Type Object name Method name Release Message type 1 RW TR BAPI_SECURITYPRICE_GETDETAIL Security price Import a single security price BUS1099 SecurityPrice GetDetail 46C 2 RW IM-

BADI:LE_SHP_DELIVERY_PROC-增强在交货处理中

1.所得方法清单: CHANGE_FCODE_ATTRIBUTES Control Activation of Function CodesCHANGE_FIELD_ATTRIBUTES Control Input Attributes of Delivery FieldsREAD_DELIVERY Read Own Data After Delivery Has Been ReadINITIALIZE_DELIVERY Initialize Own DataCHECK_ITEM_DELETIO

The parent project must have a packaging type of POM

在Eclipse中使用Maven添加模块时报错:The parent project must have a packaging type of POM 解决办法: 是将pom.xml 中的  <packaging>jar</packaging> 改成  <packaging>pom</packaging> 见下图: 用"Overview"视图查看,做如下设置: 再切换到xml视图,就可以看到packaging已经修改为pom了.