CODE FESTIVAL 2016 Final

Submission #5425549

Source codeソースコード

#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <math.h>
#include <map>

using namespace std;
using ll = long long;

int main()
{
	int n, m;
	cin >> n >> m;

	vector <vector <int> > adj(n + m);

	for (int i = 0; i < n; ++i)
	{
		int k;
		cin >> k;
		k;

		for (int j = 0; j < k; ++j)
		{
			int l;
			cin >> l;
			l--;
			adj[i].push_back(n + l);
			adj[n + l].push_back(i);
		}
	}

	stack<int> s;
	vector<bool>cat(n+m, false);


	s.push(0);
	cat[0] = true;

	while (!s.empty())
	{
		int oya = s.top();
		s.pop();

		for (int child : adj[oya])
		{
			if (!cat[child])
			{
				s.push(child);
				cat[child] = true;
			}
		}
	}

	bool flag = true;

	for (int i = 0; i < n; i++)
	{
		flag = flag && cat[i];
	}
	
	if (flag)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	return 0;
}

Submission

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

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 2 ms 256 KB
01-03.txt AC 2 ms 384 KB
01-04.txt AC 2 ms 256 KB
01-05.txt AC 2 ms 256 KB
01-06.txt AC 2 ms 256 KB
01-07.txt AC 2 ms 256 KB
01-08.txt AC 2 ms 256 KB
01-09.txt AC 2 ms 256 KB
01-10.txt AC 2 ms 384 KB
02-01.txt AC 43 ms 5504 KB
02-02.txt AC 49 ms 6400 KB
02-03.txt AC 45 ms 3840 KB
02-04.txt AC 57 ms 7040 KB
02-05.txt AC 53 ms 5760 KB
02-06.txt AC 59 ms 7040 KB
02-07.txt AC 55 ms 6144 KB
02-08.txt AC 39 ms 6264 KB
02-09.txt AC 54 ms 8952 KB
02-10.txt AC 46 ms 6392 KB
02-11.txt AC 46 ms 6520 KB
02-12.txt AC 45 ms 6144 KB
02-13.txt AC 45 ms 6272 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB