Submission #1800798
Source Code Expand
#include <iostream> #include <iomanip> // << fixed << setprecision(xxx) #include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ; #include <vector> #include <string> // to_string(nnn) // substr(m, n) // stoi(nnn) #include <complex> #include <tuple> // get<n>(xxx) #include <queue> #include <stack> #include <map> // if (M.find(key) != M.end()) { } #include <set> // S.insert(M); // if (S.find(key) != S.end()) { } // for (auto it=S.begin(); it != S.end(); it++) { } // auto it = S.lower_bound(M); #include <random> // random_device rd; mt19937 mt(rd()); #include <cctype> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> // atoi(xxx) using namespace std; #define DEBUG 0 // change 0 -> 1 if we need debug. // insert #if<tab> by my emacs. #if DEBUG == 1 ... #end typedef long long ll; // const int dx[4] = {1, 0, -1, 0}; // const int dy[4] = {0, 1, 0, -1}; const int C = 1e5+5; // const ll M = 1000000007; int N, M; int K[100010]; vector<int> L[100010]; vector<int> V[200010]; int main () { cin >> N >> M; for (auto i = 0; i < N; ++i) { cin >> K[i]; for (auto j = 0; j < K[i]; ++j) { int l; cin >> l; L[i].push_back(l); V[i].push_back(l+C); V[l+C].push_back(i); } } bool visited[200010]; fill(visited, visited+200010, false); stack<int> S; S.push(0); while (!S.empty()) { int src = S.top(); S.pop(); if (!visited[src]) { visited[src] = true; for (auto x : V[src]) { if (!visited[x]) { S.push(x); } } } } for (auto i = 0; i < N; ++i) { if (!visited[i]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | kazunetakahashi |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1778 Byte |
Status | AC |
Exec Time | 66 ms |
Memory | 14968 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 200 / 200 | ||||||
Status |
|
|
|
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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 4 ms | 7424 KB |
01-02.txt | AC | 4 ms | 7552 KB |
01-03.txt | AC | 4 ms | 7552 KB |
01-04.txt | AC | 4 ms | 7552 KB |
01-05.txt | AC | 4 ms | 7552 KB |
01-06.txt | AC | 4 ms | 7552 KB |
01-07.txt | AC | 4 ms | 7552 KB |
01-08.txt | AC | 4 ms | 7552 KB |
01-09.txt | AC | 4 ms | 7552 KB |
01-10.txt | AC | 4 ms | 7552 KB |
02-01.txt | AC | 49 ms | 11008 KB |
02-02.txt | AC | 57 ms | 14720 KB |
02-03.txt | AC | 49 ms | 10624 KB |
02-04.txt | AC | 64 ms | 12544 KB |
02-05.txt | AC | 61 ms | 13696 KB |
02-06.txt | AC | 66 ms | 12544 KB |
02-07.txt | AC | 63 ms | 14208 KB |
02-08.txt | AC | 47 ms | 14712 KB |
02-09.txt | AC | 61 ms | 14968 KB |
02-10.txt | AC | 49 ms | 13172 KB |
02-11.txt | AC | 49 ms | 13300 KB |
02-12.txt | AC | 50 ms | 12928 KB |
02-13.txt | AC | 50 ms | 13056 KB |
sample-01.txt | AC | 4 ms | 7424 KB |
sample-02.txt | AC | 4 ms | 7424 KB |