-
Notifications
You must be signed in to change notification settings - Fork 0
/
1154.cpp
62 lines (58 loc) · 1.24 KB
/
1154.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// main.cpp
// test
//
// Created by 李寻欢 on 2019/10/20.
// Copyright © 2019 李寻欢. All rights reserved.
//
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <set>
#include <deque>
using namespace std;
const int MAXN = 10010;
vector<int> G[MAXN];
int n,m;
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<m;i++){
int a,b;
scanf("%d%d",&a,&b);
G[a].push_back(b);
G[b].push_back(a);
}
int times;
scanf("%d",×);
while(times--){
set<int> s;
int color[n+1];
for(int i=0;i<n;i++){
scanf("%d",&color[i]);
s.insert(color[i]);
}
bool flag = true;
for(int i=0;i<n;i++){
for(int j=0;j<G[i].size();j++){
if(color[i] == color[G[i][j]]){
printf("No\n");
flag = false;
break;
}
}
if(!flag)
break;
}
if(!flag) continue;
printf("%d-coloring\n",(int)s.size() );
}
}