当前位置:网站首页>1149 dangerous goods packaging (25 points)
1149 dangerous goods packaging (25 points)
2022-06-30 14:55:00 【Xue Dongjing】
30min
1149 Dangerous Goods Packaging (25 branch )
The question
Give a set of numbers that cannot coexist , Give more n Group number , Determine whether the number of each group can coexist .
Ideas
Existence of incompatible numbers vector in , When adding a number , Mark numbers that are incompatible with him , When a marked number appears , The number of groups cannot coexist .
Code
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<set>
#include<vector>
#include<string.h>
using namespace std;
set<int>s;
vector<int>mp[100007];
int pre[1000007],vis[100007];
int main()
{
int n,k,x,y,m,p,q,flog=0,cont=0;
for(int i=0;i<1000007;i++){
pre[i]=i+3000000;
}
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++){
scanf("%d%d",&x,&y);
mp[x].push_back(y);
mp[y].push_back(x);
}
for(int i=0;i<m;i++){
scanf("%d",&k);
flog=0;
memset(vis,0,sizeof(vis));
for(int j=0;j<k;j++){
scanf("%d",&x);
if(vis[x]==1){
flog=1;
}
if(flog==1){
continue;
}
for(int l=0;l<mp[x].size();l++){
vis[mp[x][l]]=1;
}
}
if(flog==1){
printf("No\n");
}else{
printf("Yes\n");
}
}
return 0;
}
边栏推荐
- Text matching - [naacl 2021] augsbert
- CCF Z-scan (full mark code + problem solving ideas) 201412-2
- 1131: genetic correlation
- Color classification of sorting
- Double pointer letter matching
- JS time conversion standard format, timestamp conversion standard format
- JS array sorting method summary
- DefCamp Capture the Flag (D-CTF) 2021-22 web
- How does hbuilder display in columns?
- CCF date calculation (Full Score code + skill summary) February 2, 2015
猜你喜欢
ThinkPHP show method parameter controllable command execution
CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
Determine the number of digits of an integer in MATLAB (one line of code)
Shift operator (detailed)
@PathVariable
Lihongyi machine learning 2020 homework summary
CCF window (Full Score code + problem solving idea) March 2, 2014
DefCamp Capture the Flag (D-CTF) 2021-22 web
[buuctf] [actf2020 freshman competition]exec1
How to use Alibaba Vector Icon
随机推荐
How to realize selective screen recording for EV screen recording
Vue returns to the previous page without refreshing the page / Vue caches the page
One dimensional and two dimensional array addresses
文本匹配——【NAACL 2021】AugSBERT
高精度CNC加工中心为什么会出现误差?这4个原因你要注意!
August 24, 2021 deque queue and stack
2021-07-15Caused by: org. quartz. ObjectAlreadyExistsException: Unable to store Job : ‘DEFAULT. TASK_ 1‘
val_ Loss decreases first and then increases or does not decrease but only increases
Pseudocode writing specification
Using member variables and member functions of a class
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
Forward declaration of classes
DiceCTF - knock-knock
Summary of C language interview questions
Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~
【BUUCTF】 EasySql
Repair of incorrect deletion of win10 boot entry
Determine the number of digits of an integer in MATLAB (one line of code)
Effect of shadow around the block after mouse over
[extensive reading of papers] sentimental analysis of online reviews with a hierarchical attention network