Submission #992714
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i, s, n) for(int i = s; i < n; ++i) #define rep(i, n) REP(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define IINF INT_MAX #define LLINF LLONG_MAX typedef long long ll; typedef pair <int, int> ii; #define DEBUG false int main() { ll n, m; cin >> n >> m; vector <bool> check(n); vector <bool> used(m); map <ll, vector <int> > mp; ll k; vector <vector<int> > list(n); rep(j, n) { cin >> k; rep(i, k) { int tmp; cin >> tmp; list[j].push_back(tmp); mp[tmp].push_back(j); } } queue <int> qu; check[0] = true; rep(i, list[0].size()) { qu.push(list[0][i]); } while(!qu.empty()) { int num = qu.front(); qu.pop(); if(DEBUG) cout << "num:"<<num<<endl; if(used[num]) continue; used[num] = true; vector<int> vv = mp[num]; rep(i, vv.size()){ int id = vv[i]; if(!check[id]){ rep(j, list[id].size()){ if(!used[list[id][j]]) qu.push(list[id][j]); } } check[id] = true; } } bool ans = true; rep(i, n) if(!check[i]) ans = false; if(DEBUG) rep(i, n) cout << check[i] <<endl; if(ans) cout << "YES" <<endl; else cout <<"NO" <<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | letter |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1407 Byte |
Status | AC |
Exec Time | 101 ms |
Memory | 9208 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 | 2 ms | 256 KB |
01-02.txt | AC | 3 ms | 384 KB |
01-03.txt | AC | 3 ms | 384 KB |
01-04.txt | AC | 3 ms | 256 KB |
01-05.txt | AC | 3 ms | 256 KB |
01-06.txt | AC | 3 ms | 384 KB |
01-07.txt | AC | 3 ms | 256 KB |
01-08.txt | AC | 3 ms | 384 KB |
01-09.txt | AC | 3 ms | 256 KB |
01-10.txt | AC | 3 ms | 256 KB |
02-01.txt | AC | 101 ms | 8192 KB |
02-02.txt | AC | 59 ms | 6272 KB |
02-03.txt | AC | 84 ms | 6272 KB |
02-04.txt | AC | 97 ms | 8064 KB |
02-05.txt | AC | 75 ms | 6144 KB |
02-06.txt | AC | 97 ms | 8064 KB |
02-07.txt | AC | 76 ms | 6656 KB |
02-08.txt | AC | 45 ms | 6264 KB |
02-09.txt | AC | 58 ms | 6520 KB |
02-10.txt | AC | 67 ms | 9208 KB |
02-11.txt | AC | 65 ms | 9208 KB |
02-12.txt | AC | 78 ms | 8448 KB |
02-13.txt | AC | 78 ms | 8448 KB |
sample-01.txt | AC | 2 ms | 256 KB |
sample-02.txt | AC | 2 ms | 256 KB |