当前位置:网站首页>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;
}
边栏推荐
- IO interview questions
- The first dark spring cup dnuictf
- ThinkPHP v3.2 comment annotation injection write shell
- JS array
- @PathVariable
- How does hbuilder display in columns?
- Matlab finds a prime number that is greater than a given integer and follows this integer
- One dimensional and two dimensional array addresses
- Solve the problem that codeblocks20.03 on win11 cannot run for the first time
- KnightCTF WEB
猜你喜欢
[email protected][])"/>NoViableAltException([email protected][])

Clear the route cache in Vue

Error $(...) size is not a function

day02

Repair of incorrect deletion of win10 boot entry

Database connection to company database denied

CCF image rotation (Full Score code + problem solving idea) 201503-01

Matlab construction operation example

CCF adjacent number pairs (Full Score code + problem solving ideas + skill summary) 201409-1

CCF access control system (Full Score code + problem solving idea) 201412-1
随机推荐
2021 geek challenge Web
Component communication mode
Location of dichotomy
Using member variables and member functions of a class
PHP generate images into Base64
Basic requirements for tool use in NC machining of vertical machining center
JS array sorting method summary
Svn password forgetting solution
Basic learning notes of C language
1 figure to explain the difference and connection between nodejs and JS
Repair of incorrect deletion of win10 boot entry
Add attributes to multimode
catkin_ Make reports an error, transfers the location of the workspace, and uses other people's workspace files to cause compilation errors
[buuctf] [actf2020 freshman competition]exec1
CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)
Forward declaration of classes
Finding the root of an integer by dichotomy
LIS error: this configuration section cannot be used in this path
Knowledge learned from the water resources institute project