题目:https://www.patest.cn/contests/gplt/L2-023
竟然是必须用k种,少用了还不行。
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int maxn=100005;
struct node{
int v,u;
}edge[250005];
int a[505];
set<int> s;
int main(){
int V,E,K,n;
cin>>V>>E>>K;
for(int i=1;i<=E;i++)
cin>>edge[i].v>>edge[i].u;
cin>>n;
for(int i=1;i<=n;i++){
int flg=0;
s.clear();
for(int j=1;j<=V;j++){
cin>>a[j];
s.insert(a[j]);
}
if(s.size()!=K){
cout<<"No"<<endl;
continue;
}
for(int j=1;j<=E;j++){
if(a[edge[j].v]==a[edge[j].u]){
flg=1;
break;
}
}
if(flg)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
return 0;
}