-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL2-023.cpp
More file actions
60 lines (60 loc) · 1.02 KB
/
L2-023.cpp
File metadata and controls
60 lines (60 loc) · 1.02 KB
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
#include<stdio.h>
#include<set>
#include<string.h>
using namespace std;
int Map[510][510];
int visited[510];
int a[510],n,flag;
void DFS()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(Map[i][j]==1&&a[i]==a[j])
{
flag=1;
break;
}
}
}
}
int main()
{
int i,j,m,k,t,x,y;
scanf("%d %d %d",&n,&m,&k);
for(i=0;i<m;i++)
{
scanf("%d %d",&x,&y);
Map[x][y]=Map[y][x]=1;
}
scanf("%d",&t);
for(i=0;i<t;i++)
{
memset(visited,0,sizeof(visited));
flag=0;
set<int> s;
for(j=1;j<=n;j++)
{
scanf("%d",&a[j]);
s.insert(a[j]);
}
if(s.size()!=k)
{
printf("No\n");
}
else
{
DFS();
if(flag==0)
{
printf("Yes\n");
}
else
{
printf("No\n");
}
}
}
return 0;
}