Submission #992031
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 <cctype> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> // atoi(xxx) using namespace std; typedef long long ll; //const int dx[4] = {1, 0, -1, 0}; //const int dy[4] = {0, 1, 0, -1}; // const int C ; // const int M = 1000000007; int N; int M; int K[100010]; vector<int> L[200100]; bool visited[200100]; 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+100010); L[l+100010].push_back(i); } } fill(visited, visited+200100, false); stack<int> S; S.push(0); while (!S.empty()) { int now = S.top(); S.pop(); if (!visited[now]) { visited[now] = true; for (auto x : L[now]) { 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 | 1543 Byte |
Status | AC |
Exec Time | 63 ms |
Memory | 9464 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 7 ms | 5120 KB |
01-02.txt | AC | 7 ms | 5120 KB |
01-03.txt | AC | 7 ms | 5120 KB |
01-04.txt | AC | 8 ms | 5120 KB |
01-05.txt | AC | 8 ms | 5120 KB |
01-06.txt | AC | 7 ms | 5120 KB |
01-07.txt | AC | 8 ms | 5120 KB |
01-08.txt | AC | 8 ms | 5120 KB |
01-09.txt | AC | 7 ms | 5120 KB |
01-10.txt | AC | 8 ms | 5120 KB |
02-01.txt | AC | 53 ms | 8064 KB |
02-02.txt | AC | 56 ms | 9344 KB |
02-03.txt | AC | 50 ms | 7552 KB |
02-04.txt | AC | 63 ms | 8448 KB |
02-05.txt | AC | 59 ms | 8832 KB |
02-06.txt | AC | 63 ms | 8448 KB |
02-07.txt | AC | 60 ms | 9088 KB |
02-08.txt | AC | 46 ms | 9208 KB |
02-09.txt | AC | 60 ms | 9464 KB |
02-10.txt | AC | 52 ms | 9080 KB |
02-11.txt | AC | 51 ms | 9208 KB |
02-12.txt | AC | 50 ms | 8832 KB |
02-13.txt | AC | 51 ms | 8960 KB |
sample-01.txt | AC | 7 ms | 5120 KB |
sample-02.txt | AC | 7 ms | 5120 KB |