Skip to content

Commit

Permalink
Create 1154. Vertex Coloring (25).cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuo committed Dec 30, 2018
1 parent d8f5afa commit 0ca3575
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions AdvancedLevel_C++/1154. Vertex Coloring (25).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <vector>
#include <set>
using namespace std;
struct node {int t1, t2;};
int main() {
int n, m, k;
cin >> n >> m;
vector<node> v(m);
for (int i = 0; i < m; i++)
scanf("%d %d", &v[i].t1, &v[i].t2);
cin >> k;
while (k--) {
int a[10009] = {0};
bool flag = true;
set<int> se;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
se.insert(a[i]);
}
for (int i = 0; i < m; i++) {
if (a[v[i].t1] == a[v[i].t2]) {
flag = false;
break;
}
}
if (flag)
printf("%d-coloring\n", se.size());
else
printf("No\n");
}
return 0;
}

0 comments on commit 0ca3575

Please sign in to comment.