#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<unordered_map>
#include<cmath>
using namespace std;
const int maxn = 10001;
int main()
{
int n, m, t1, t2;
cin >> n >> m;
vector<int>v[maxn];
int a[maxn];
for (int i = 0; i < m; i++)
{
cin >> t1 >> t2;
v[t1].push_back(t2);
v[t2].push_back(t1);
}
int k; cin >> k;
for (int j = 0; j < k; j++)
{
set<int>s;
for (int i = 0; i < n; i++)
{
cin >> a[i];
s.insert(a[i]);
}
int flag = 1;
for (int q = 0; q < n; q++)
{
if (flag == 0)
break;
for (int i = 0; i < v[q].size(); i++)
{
if (a[q] == a[v[q][i]])
{
flag = 0;
break;
}
}
}
if (flag == 0)
cout << "No" << endl;
else
cout << s.size() << "-coloring" << endl;
}
}
A1154 Vertex Coloring
最新推荐文章于 2023-02-12 20:19:43 发布