CODE FESTIVAL 2016 Final

Submission #3669863

Source codeソースコード

#include<stdio.h>
#include<stdlib.h>

int root(int *u,int x){
  if(u[x]==x) return x;
  return u[x]=root(u,u[x]);
}

int same(int *u,int x,int y){
  return root(u,x)==root(u,y);
}

void unite(int *u,int x,int y){
  x=root(u,x);
  y=root(u,y);
  if(x==y) return;
  u[x]=y;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *u=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=1;i<=n;i++) u[i]=i;
  int *d=(int *)calloc(m+1,sizeof(int));
  for(i=1;i<=n;i++){
    int k;
    scanf("%d",&k);
    while(k--){
      int l;
      scanf("%d",&l);
      if(d[l]==0){
	d[l]=i;
      } else {
	unite(u,d[l],i);
      }
    }
  }
  for(i=1;i<=n;i++) if(!same(u,1,i)) break;
  printf("%s\n",i>n?"YES":"NO");
}

int main(void){
  run();
  return 0;
}

Submission

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

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

./Main.c: In function ‘run’:
./Main.c:22:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.c:29:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&k);
^
./Main.c:32:7: 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 13 ms 512 KB
02-02.txt AC 21 ms 512 KB
02-03.txt AC 14 ms 384 KB
02-04.txt AC 20 ms 768 KB
02-05.txt AC 23 ms 512 KB
02-06.txt AC 19 ms 768 KB
02-07.txt AC 22 ms 512 KB
02-08.txt AC 17 ms 1280 KB
02-09.txt AC 21 ms 2176 KB
02-10.txt AC 16 ms 1280 KB
02-11.txt AC 16 ms 1280 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