CODE FESTIVAL 2016 Final

Submission #991633

Source codeソースコード

#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
vector<int> L[101010];

int uf[303030];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
void join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p == q) return;
	uf[p] += uf[q];
	uf[q] = p;
}

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; ++i) {
		int k;
		scanf("%d", &k);
		for (; k--;) {
			int v;
			scanf("%d", &v);
			--v;
			L[i].push_back(v);
		}
	}
	for (int i = 0; i < N + M; ++i) uf[i] = -1;
	for (int i = 0; i < N; ++i) {
		for (int l : L[i]) {
			join(i, l + N);
		}
	}
	int rt = root(0);
	for (int i = 1; i < N; ++i) {
		if (rt != root(i)) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:40: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:43:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &k);
^
./Main.cpp:46:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &v);
^

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 4 ms 2688 KB
01-02.txt AC 5 ms 2560 KB
01-03.txt AC 5 ms 2688 KB
01-04.txt AC 5 ms 2688 KB
01-05.txt AC 5 ms 2688 KB
01-06.txt AC 5 ms 2688 KB
01-07.txt AC 5 ms 2688 KB
01-08.txt AC 5 ms 2688 KB
01-09.txt AC 5 ms 2688 KB
01-10.txt AC 5 ms 2688 KB
02-01.txt AC 19 ms 3712 KB
02-02.txt AC 31 ms 6016 KB
02-03.txt AC 21 ms 3584 KB
02-04.txt AC 28 ms 4992 KB
02-05.txt AC 31 ms 5504 KB
02-06.txt AC 28 ms 4992 KB
02-07.txt AC 31 ms 5760 KB
02-08.txt AC 28 ms 6912 KB
02-09.txt AC 32 ms 8064 KB
02-10.txt AC 23 ms 5504 KB
02-11.txt AC 23 ms 5500 KB
02-12.txt AC 23 ms 4864 KB
02-13.txt AC 23 ms 4864 KB
sample-01.txt AC 4 ms 2560 KB
sample-02.txt AC 4 ms 2560 KB