Submission #5379531
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define REP(i, n) for(int i=0; i<n; i++) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } const ll MOD = 1e9+7; vector<int> G[100100]; vector<int> L[100100]; bool isvisit[100100]; void dfs(int v, int x){ isvisit[v] = true; for(auto l : L[v]){ if(l == x) continue; for(auto next : G[l]) { if(isvisit[next]) continue; dfs(next, l); } } } int main(){ int N, M; cin >> N >> M; REP(i,N){ int K; cin >> K; REP(j,K){ int l; cin >> l; l--; L[i].push_back(l); G[l].push_back(i); } } dfs(0, -1); bool ans = true; REP(i,N){ if(!isvisit[i]) ans = false; } if(ans) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | kurakura |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1137 Byte |
Status | AC |
Exec Time | 69 ms |
Memory | 8960 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 | 3 ms | 4992 KB |
01-02.txt | AC | 3 ms | 4992 KB |
01-03.txt | AC | 4 ms | 4992 KB |
01-04.txt | AC | 3 ms | 4992 KB |
01-05.txt | AC | 4 ms | 4992 KB |
01-06.txt | AC | 4 ms | 4992 KB |
01-07.txt | AC | 4 ms | 4992 KB |
01-08.txt | AC | 4 ms | 4992 KB |
01-09.txt | AC | 4 ms | 4992 KB |
01-10.txt | AC | 4 ms | 4992 KB |
02-01.txt | AC | 51 ms | 7808 KB |
02-02.txt | AC | 57 ms | 8832 KB |
02-03.txt | AC | 52 ms | 7552 KB |
02-04.txt | AC | 67 ms | 8192 KB |
02-05.txt | AC | 63 ms | 8960 KB |
02-06.txt | AC | 69 ms | 8192 KB |
02-07.txt | AC | 64 ms | 8576 KB |
02-08.txt | AC | 45 ms | 8568 KB |
02-09.txt | AC | 64 ms | 8568 KB |
02-10.txt | AC | 54 ms | 8568 KB |
02-11.txt | AC | 55 ms | 8568 KB |
02-12.txt | AC | 53 ms | 8448 KB |
02-13.txt | AC | 53 ms | 8448 KB |
sample-01.txt | AC | 3 ms | 4992 KB |
sample-02.txt | AC | 3 ms | 4992 KB |