Submission #992125
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,LL> PII; const int MAXN = 300000; vector<int> graph[MAXN]; int main() { int N,M; cin >> N >> M; for(int i=0; i<N; i++) { int K; cin >> K; for(int j=0; j<K; j++) { int p; cin >> p; p--; graph[i].push_back(N+p); graph[N+p].push_back(i); } } vector<int> used(N+M, 0); used[0] = 1; queue<int> qu; qu.push(0); while(!qu.empty()) { int cur = qu.front(); qu.pop(); for(int i=0; i<graph[cur].size(); i++) { int next = graph[cur][i]; if(used[next]) continue; used[next] = true; qu.push(next); } } bool ok = true; for(int i=0; i<N; i++) { if(!used[i]) ok = false; } if(ok) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | tokoharu |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 835 Byte |
Status | AC |
Exec Time | 71 ms |
Memory | 12024 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 | 10 ms | 7296 KB |
01-02.txt | AC | 10 ms | 7296 KB |
01-03.txt | AC | 10 ms | 7296 KB |
01-04.txt | AC | 10 ms | 7296 KB |
01-05.txt | AC | 10 ms | 7296 KB |
01-06.txt | AC | 10 ms | 7296 KB |
01-07.txt | AC | 10 ms | 7296 KB |
01-08.txt | AC | 10 ms | 7296 KB |
01-09.txt | AC | 10 ms | 7296 KB |
01-10.txt | AC | 10 ms | 7296 KB |
02-01.txt | AC | 56 ms | 10496 KB |
02-02.txt | AC | 59 ms | 11520 KB |
02-03.txt | AC | 55 ms | 9728 KB |
02-04.txt | AC | 68 ms | 11008 KB |
02-05.txt | AC | 66 ms | 11008 KB |
02-06.txt | AC | 71 ms | 11008 KB |
02-07.txt | AC | 65 ms | 11264 KB |
02-08.txt | AC | 50 ms | 11384 KB |
02-09.txt | AC | 66 ms | 12024 KB |
02-10.txt | AC | 55 ms | 11512 KB |
02-11.txt | AC | 55 ms | 11512 KB |
02-12.txt | AC | 55 ms | 11136 KB |
02-13.txt | AC | 55 ms | 11136 KB |
sample-01.txt | AC | 10 ms | 7296 KB |
sample-02.txt | AC | 10 ms | 7296 KB |