CODE FESTIVAL 2016 Final

Submission #6870552

Source codeソースコード

#include <iostream>
#include <vector>

using namespace std;
int Par(int n, vector<int> &d) {
	if (d[n] == n)
		return n;
	int ans = Par(d[n], d);
	d[n] = ans;
	return ans;
}

int main(void) {
	int num, m, k, i, j, a, b;
	cin >> num >> m;
	vector<int> d(m + 1), l(m + 1, 0), t(num);
	for (i = 1; i <= m; i++)
		d[i] = i;
	for (i = 0; i < num; i++) {
		scanf("%d%d", &k, &t[i]);
		t[i] = Par(t[i], d);
		while (k > 1) {
			scanf("%d", &a);
			a = Par(a, d);
			if (l[t[i]] < l[a]) {
				d[t[i]] = a;
				t[i] = a;
			}
			else {
				d[a] = t[i];
				if (l[t[i]] == l[a])
					l[t[i]]++;
			}
			k--;
		}
	}
	a = Par(t[0], d);
	for (i = 1; i < num; i++) {
		if (a != Par(t[i], d)) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Submission

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

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

./Main.cpp: In function ‘int main()’:
./Main.cpp:20:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &k, &t[i]);
^
./Main.cpp:23:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a);
^

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 256 KB
01-02.txt AC 1 ms 256 KB
01-03.txt AC 1 ms 256 KB
01-04.txt AC 1 ms 256 KB
01-05.txt AC 1 ms 256 KB
01-06.txt AC 1 ms 256 KB
01-07.txt AC 1 ms 256 KB
01-08.txt AC 1 ms 256 KB
01-09.txt AC 1 ms 256 KB
01-10.txt AC 1 ms 256 KB
02-01.txt AC 14 ms 1024 KB
02-02.txt AC 15 ms 640 KB
02-03.txt AC 13 ms 640 KB
02-04.txt AC 17 ms 1280 KB
02-05.txt AC 15 ms 640 KB
02-06.txt AC 16 ms 1280 KB
02-07.txt AC 16 ms 640 KB
02-08.txt AC 14 ms 640 KB
02-09.txt AC 16 ms 1408 KB
02-10.txt AC 14 ms 768 KB
02-11.txt AC 14 ms 768 KB
02-12.txt AC 14 ms 768 KB
02-13.txt AC 14 ms 768 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB