当前位置:网站首页>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;
}
边栏推荐
- 浅析卧式加工中心上不规则台阶孔存在问题
- Lost connection to the flow server (0 retries remaining): |Out of retries, exiting! Error reporting solution (flow)
- Summary of C language interview questions
- V3 02——What‘s new in Chrome extensions
- How to program and process such parts?
- Greedy interval problem (5)
- 【BUUCTF】 EasySql
- Add attributes to multimode
- August 24, 2021 deque queue and stack
- Analysis on the problems of irregular step hole on horizontal machining center
猜你喜欢

Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)

day02

CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014

ctfshow nodejs

CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1

Shift operator (detailed)

KnightCTF WEB

PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available

Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package

Knowledge learned from the water resources institute project
随机推荐
左旋梯形螺纹的编程
Error $(...) size is not a function
Using member variables and member functions of a class
2021 geek challenge Web
2021-05-12
Sum of CCF digits (full mark code + problem solving idea) 201512-1
Matlab to find prime pairs within 100
Summary of C language interview questions
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
Machine learning feature selection
MV3 04_ Introducing Manifest V3
CCF image rotation (Full Score code + problem solving idea) 201503-01
高清机械原理 · 机械设计经典动图
CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
Matlab judge palindrome number (only numbers)
Sorting by character frequency
The first dark spring cup dnuictf
IO interview questions
[extensive reading of papers] sentimental analysis of online reviews with a hierarchical attention network
Analysis on the problems of irregular step hole on horizontal machining center