当前位置:网站首页>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;
}
边栏推荐
- Querywrapper in mybaits plus
- [untitled]
- 这种零件该怎么编程加工?
- V3 03_ Getting started
- Machine learning feature selection
- Effect of shadow around the block after mouse over
- DiceCTF - knock-knock
- How many questions can you answer for the interview of Mechanical Engineer?
- Matlab to find prime pairs within 100
- V3 02——What‘s new in Chrome extensions
猜你喜欢

Component communication mode

PS dynamic drawing

JS to realize simple lottery function

How to realize selective screen recording for EV screen recording
[email protected][])"/>NoViableAltException([email protected][])

Database connection to company database denied

Solve the problem that codeblocks20.03 on win11 cannot run for the first time

Computer screenshot how to cut the mouse in

V3 03_ Getting started

Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
随机推荐
How to realize selective screen recording for EV screen recording
【BUUCTF】 Have Fun
Knowledge learned from the water resources institute project
Machine learning feature selection
高精度CNC加工中心为什么会出现误差?这4个原因你要注意!
ThinkPHP show method parameter controllable command execution
DR-TANet: Dynamic Receptive Temporal Attention Network for Street Scene Change Detection
左旋梯形螺纹的编程
JS time conversion standard format, timestamp conversion standard format
Text matching - [naacl 2021] augsbert
Sum of CCF digits (full mark code + problem solving idea) 201512-1
Programming exercises: whole point and circle (solution ideas and code implementation)
PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available
@PathVariable
Non decreasing column
JS array sorting method summary
Svn password forgetting solution
Effect of shadow around the block after mouse over
Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
ES6 notes