hiho week 161 register

Ended

Participants:317

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-03 12:23:17

Lang:G++

Edit
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
#include<cstdio>
#include<cstring>
typedef unsigned int uint;
inline void read(short &res){
    static char ch;register short flag=1;
    while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
    while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}
const short maxn=509;
short n,m,t,p[maxn],vis[maxn];
short find(short x){
    return x==p[x]?x:p[x]=find(p[x]);
}
int main(){
    read(t);
    while(t--){
        read(n),read(m);
        for(register int i=0;i<=n;i++)p[i]=i;
        short a,b,edge=0,v=0,flag=0,x,y;
        memset(vis,0,sizeof(vis));
        while(m--){
            read(a),read(b);
            if(a==0&&b==0)puts("YES");
            if(a==b){flag=1;continue;}
            else{
                if(!vis[a]){
                    vis[a]=1;
                    v++;
                }
                if(!vis[b]){
                    vis[b]=1;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX