Submission #1678307
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<bool> used; vector<vector<int> > l; void search(int idx){ for(int i=0; i<(int)l.size(); i++){ if(used[i]) continue; int a=0, b=0; while(a<(int)l[idx].size() && b<(int)l[i].size()){ if(l[idx][a]==l[i][b]){ used[i] = true; search(i); break; }else if(l[idx][a] < l[i][b]){ a++; }else{ b++; } } } } int main(){ int n,m; cin >> n >> m; vector<vector<int> > lang(n); for(int i=0; i<n; i++){ int k; cin >> k; lang[i].resize(k); for(int j=0; j<k; j++){ cin >> lang[i][j]; } sort(lang[i].begin(), lang[i].end()); } vector<bool> u(n, false); u[0] = true; used = u; l = lang; search(0); bool success = true; for(int i=0; i<n; i++){ if(!used[i]){ success = false; } } if(success){ cout << "YES" << endl; }else{ cout << "NO" << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | syl659 |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1096 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 15744 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 0 / 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 | 1 ms | 256 KB |
01-02.txt | AC | 2 ms | 256 KB |
01-03.txt | AC | 2 ms | 384 KB |
01-04.txt | AC | 4 ms | 384 KB |
01-05.txt | AC | 5 ms | 384 KB |
01-06.txt | AC | 5 ms | 256 KB |
01-07.txt | AC | 4 ms | 256 KB |
01-08.txt | AC | 5 ms | 256 KB |
01-09.txt | AC | 5 ms | 256 KB |
01-10.txt | AC | 4 ms | 512 KB |
02-01.txt | AC | 368 ms | 1792 KB |
02-02.txt | TLE | 2104 ms | 11904 KB |
02-03.txt | AC | 812 ms | 2560 KB |
02-04.txt | TLE | 2104 ms | 6400 KB |
02-05.txt | TLE | 2104 ms | 9856 KB |
02-06.txt | TLE | 2104 ms | 6400 KB |
02-07.txt | TLE | 2104 ms | 12160 KB |
02-08.txt | TLE | 2104 ms | 12800 KB |
02-09.txt | TLE | 2104 ms | 15744 KB |
02-10.txt | TLE | 2104 ms | 10624 KB |
02-11.txt | TLE | 2104 ms | 10624 KB |
02-12.txt | TLE | 2104 ms | 7808 KB |
02-13.txt | TLE | 2104 ms | 7680 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |