Submission #1443697
Source Code Expand
#include<cstdio> #include<cstdlib> #include<cmath> #include<iostream> #include<string> #include<stack> #include<queue> #include<vector> #include<map> #include<set> #include<algorithm> #include<numeric> #define rep(n) for(int i=0;i<n;i++) #define repp(j, n) for(int j=0;j<n;j++) #define reppp(i, m, n) for(int i=m;i<=n;i++) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define pb(x) push_back(x) #define eb(x,y) emplace_back(x,y) #define MOD 1000000007 #define MAX 100001 #define INF 1410065408 #define EPS 1e-9 using namespace std; typedef long long ll; typedef pair<ll, ll> Pll; typedef pair<int, int> Pii; struct edge{int from, to; ll cost;}; vector<int> es[2 * MAX]; vector<int> use(2 * MAX, 0); void bfs(int start){ int node; queue<int> q; q.push(start); use[start] = 1; while(!q.empty()){ node = q.front(); q.pop(); for(int next: es[node]){ if(use[next] == 0){ q.push(next); use[next] = 1; } } } } signed main(){ int n, m, k, tmp; cin >> n >> m; rep(n){ cin >> k; repp(j, k){ cin >> tmp; es[i].pb(tmp+MAX); es[tmp+MAX].pb(i); } } bfs(0); int flag = 1; rep(n){ if(use[i] == 0){ flag = 0; break; } } if(flag == 1){ cout << "YES"; }else{ cout << "NO"; } }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | Noimin |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1541 Byte |
Status | AC |
Exec Time | 57 ms |
Memory | 9592 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 | 5760 KB |
01-02.txt | AC | 4 ms | 5760 KB |
01-03.txt | AC | 4 ms | 5760 KB |
01-04.txt | AC | 4 ms | 5760 KB |
01-05.txt | AC | 4 ms | 5760 KB |
01-06.txt | AC | 4 ms | 5760 KB |
01-07.txt | AC | 3 ms | 5760 KB |
01-08.txt | AC | 4 ms | 5760 KB |
01-09.txt | AC | 4 ms | 5760 KB |
01-10.txt | AC | 4 ms | 5760 KB |
02-01.txt | AC | 46 ms | 8448 KB |
02-02.txt | AC | 49 ms | 9472 KB |
02-03.txt | AC | 45 ms | 7936 KB |
02-04.txt | AC | 57 ms | 8832 KB |
02-05.txt | AC | 53 ms | 9088 KB |
02-06.txt | AC | 57 ms | 8832 KB |
02-07.txt | AC | 55 ms | 9216 KB |
02-08.txt | AC | 40 ms | 9464 KB |
02-09.txt | AC | 54 ms | 9592 KB |
02-10.txt | AC | 45 ms | 9592 KB |
02-11.txt | AC | 46 ms | 9464 KB |
02-12.txt | AC | 45 ms | 9216 KB |
02-13.txt | AC | 45 ms | 9216 KB |
sample-01.txt | AC | 3 ms | 5760 KB |
sample-02.txt | AC | 3 ms | 5760 KB |