CODE FESTIVAL 2016 Final

Submission #992593

Source codeソースコード

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#define F first
#define S second
using namespace std;

int p[111111];
void init(int x){
  for(int i = 0; i <= x; i++) p[i] = i;
}
int find(int x){
  return p[x]==x?x:p[x]=find(p[x]);
}

bool same(int x,int y){
  return find(x) == find(y);
}

void merge(int x,int y){
  p[find(x)] = find(y);
}


int n,m;
int k[111111];
vector<int> l[111111];
int main(void){
  scanf("%d %d",&n,&m);


  init(m);
  for(int i = 0; i < n; i++){
    scanf("%d",k+i);
    for(int j = 0; j < k[i]; j++){
      int ll;
      scanf("%d",&ll);
      l[i].push_back(ll);
      if(j){
	merge(l[i][0],l[i][j]);
      }
    }
  }

  bool f = true;
  for(int i = 1; i < n; i++){
    if(!same(l[0][0],l[i][0])) f = false;
  }
  if(f) puts("YES");
  else puts("NO");
}

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:36:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&n,&m);
^
./Main.cpp:41:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",k+i);
^
./Main.cpp:44:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&ll);
^

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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 5 ms 2816 KB
01-02.txt AC 5 ms 2816 KB
01-03.txt AC 5 ms 2944 KB
01-04.txt AC 5 ms 2944 KB
01-05.txt AC 5 ms 2816 KB
01-06.txt AC 5 ms 2816 KB
01-07.txt AC 5 ms 2816 KB
01-08.txt AC 5 ms 2816 KB
01-09.txt AC 5 ms 2816 KB
01-10.txt AC 5 ms 2944 KB
02-01.txt AC 21 ms 3840 KB
02-02.txt AC 29 ms 6272 KB
02-03.txt AC 23 ms 3712 KB
02-04.txt AC 28 ms 5248 KB
02-05.txt AC 29 ms 5760 KB
02-06.txt AC 28 ms 5248 KB
02-07.txt AC 29 ms 6016 KB
02-08.txt AC 28 ms 6400 KB
02-09.txt AC 30 ms 6784 KB
02-10.txt AC 23 ms 4992 KB
02-11.txt AC 23 ms 4988 KB
02-12.txt AC 23 ms 4992 KB
02-13.txt AC 23 ms 4992 KB
sample-01.txt AC 5 ms 2816 KB
sample-02.txt AC 5 ms 2816 KB