Submission #993161


Source Code Expand

#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

vector<bool> visited;
vector<set<int>> lang;
vector<set<int>> langlist;

void saiki(int node) {
	visited[node] = true;
	for (auto l : lang[node]) {
		for (auto nn : langlist[l]) {
			if (nn != node && !visited[nn]) {
				saiki(nn);
			}
		}
	}
}

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

	lang.resize(n);
	langlist.resize(m);
	FOR(i, 0, n) {
		int k;
		cin >> k;
		FOR(j, 0, k) {
			int l;
			cin >> l;
			l--;
			lang[i].insert(l);
			langlist[l].insert(i);
		}
	}


	visited.resize(n, false);

	saiki(0);
	bool result = true;
	for (auto t : visited) {
		if (t == false) {
			result = false;
			break;
		}
	}

	cout << (result ? "YES" : "NO") << endl;



	return 0;
}

Submission Info

Submission Time
Task C - Interpretation
User peradfn1126
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1364 Byte
Status TLE
Exec Time 2103 ms
Memory 20224 KB

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 0 / 200
Status
AC × 2
AC × 12
AC × 19
TLE × 6
Set Name Test Cases
sample sample-01.txt, sample-02.txt
dataset1 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 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
Case Name Status Exec Time Memory
01-01.txt AC 2 ms 256 KB
01-02.txt AC 3 ms 384 KB
01-03.txt AC 3 ms 384 KB
01-04.txt AC 7 ms 384 KB
01-05.txt AC 3 ms 384 KB
01-06.txt AC 3 ms 384 KB
01-07.txt AC 3 ms 384 KB
01-08.txt AC 3 ms 384 KB
01-09.txt AC 3 ms 384 KB
01-10.txt AC 10 ms 512 KB
02-01.txt AC 90 ms 14848 KB
02-02.txt AC 184 ms 17664 KB
02-03.txt AC 85 ms 12928 KB
02-04.txt AC 96 ms 16896 KB
02-05.txt AC 122 ms 16256 KB
02-06.txt AC 100 ms 16896 KB
02-07.txt AC 109 ms 14336 KB
02-08.txt TLE 2103 ms 15360 KB
02-09.txt TLE 2103 ms 20224 KB
02-10.txt TLE 2103 ms 15488 KB
02-11.txt TLE 2103 ms 15616 KB
02-12.txt TLE 2103 ms 14976 KB
02-13.txt TLE 2103 ms 14720 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 3 ms 256 KB