Submission #1613192


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
//int *v,*e;
int *par;
int *rank;
void init_union(int size){
	int i;
	par = (int*)calloc(size,sizeof(int));
	rank = (int*)calloc(size,sizeof(int));
	//v = (int*)calloc(size,sizeof(int));
	//e = (int*)calloc(size,sizeof(int));
	FOR(i,0,size) par[i]=i;
	return;
}

int root(int a){
 	if(par[a]==a) return a;
 	else{
 		par[a]=root(par[a]);
 		return par[a];
 	}
}
 
int is_same(int a,int b){
 	return root(a)==root(b);
}
 
void unite(int a,int b){
	a=root(a);
	b=root(b);
	if(a==b){
		//e[a]++;
		return;
	}
	if(rank[a]>rank[b]){
		par[b]=a;
		//v[a]++,e[a]++;
	}
	else{
		par[a]=b;
		//v[b]++,e[b]++;
		if(rank[a]==rank[b]) rank[b]++;
	}
	return;
}
int main(void)
{
	int n,m,k,l,i;
	scanf("%d%d",&n,&m);
	init_union(n+m);
	FOR(i,0,n){
		scanf("%d",&k);
		while(k-->0){
			scanf("%d",&l);
			unite(i,n+l-1);
		}
	}
	FOR(i,1,n){
		if(!is_same(0,i)){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Submission Info

Submission Time
Task C - Interpretation
User trainstation
Language C (GCC 5.4.1)
Score 400
Code Size 1051 Byte
Status
Exec Time 21 ms
Memory 1152 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:50:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ^
./Main.c:53:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&k);
   ^
./Main.c:55:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&l);
    ^

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 sample-01.txt, sample-02.txt
dataset1 200 / 200 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
dataset2 200 / 200 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt 1 ms 128 KB
01-02.txt 1 ms 128 KB
01-03.txt 1 ms 128 KB
01-04.txt 1 ms 128 KB
01-05.txt 1 ms 128 KB
01-06.txt 1 ms 128 KB
01-07.txt 1 ms 128 KB
01-08.txt 1 ms 128 KB
01-09.txt 1 ms 128 KB
01-10.txt 1 ms 128 KB
02-01.txt 14 ms 1024 KB
02-02.txt 18 ms 512 KB
02-03.txt 14 ms 640 KB
02-04.txt 21 ms 1152 KB
02-05.txt 19 ms 512 KB
02-06.txt 19 ms 1152 KB
02-07.txt 20 ms 640 KB
02-08.txt 17 ms 512 KB
02-09.txt 20 ms 896 KB
02-10.txt 16 ms 512 KB
02-11.txt 16 ms 512 KB
02-12.txt 16 ms 640 KB
02-13.txt 15 ms 640 KB
sample-01.txt 1 ms 128 KB
sample-02.txt 1 ms 128 KB