CODE FESTIVAL 2016 Final

Submission #1613192

Source codeソースコード

#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

Task問題 C - Interpretation
User nameユーザ名 stranger
Created time投稿日時
Language言語 C (GCC 5.4.1)
Status状態 AC
Score得点 400
Source lengthソースコード長 1051 Byte
File nameファイル名
Exec time実行時間 21 ms
Memory usageメモリ使用量 1152 KB

Compiler messageコンパイルメッセージ

./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);
^

Test case

Set

Set name Score得点 / Max score Cases
sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 1 ms 128 KB
01-02.txt AC 1 ms 128 KB
01-03.txt AC 1 ms 128 KB
01-04.txt AC 1 ms 128 KB
01-05.txt AC 1 ms 128 KB
01-06.txt AC 1 ms 128 KB
01-07.txt AC 1 ms 128 KB
01-08.txt AC 1 ms 128 KB
01-09.txt AC 1 ms 128 KB
01-10.txt AC 1 ms 128 KB
02-01.txt AC 14 ms 1024 KB
02-02.txt AC 18 ms 512 KB
02-03.txt AC 14 ms 640 KB
02-04.txt AC 21 ms 1152 KB
02-05.txt AC 19 ms 512 KB
02-06.txt AC 19 ms 1152 KB
02-07.txt AC 20 ms 640 KB
02-08.txt AC 17 ms 512 KB
02-09.txt AC 20 ms 896 KB
02-10.txt AC 16 ms 512 KB
02-11.txt AC 16 ms 512 KB
02-12.txt AC 16 ms 640 KB
02-13.txt AC 15 ms 640 KB
sample-01.txt AC 1 ms 128 KB
sample-02.txt AC 1 ms 128 KB