Submission #1006850
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <string> #include <set> #include <cmath> #include <map> #define rep(i,n) for(int i=0;i<n;++i) using namespace std; typedef long long ll; typedef pair<int,int> pii; #define maxn 300000 int par[maxn]; int size[maxn]; void init(int n){ rep(i,n){ size[i]=1; par[i]=i; } } int find(int x){ if(x==par[x])return x; return par[x]==find(par[x]); } void unite(int x,int y){ x = find(x); y = find(y); if(x==y)return; if(size[x]<size[y])swap(x,y); par[y]=x; size[x]+=size[y]; } bool same(int x,int y){ return find(x) == find(y); } int main(){ int n,m; cin >> n >> m; int k; int l; init(maxn-1); rep(i,n){ cin >> k; rep(j,k){ cin >> l; unite(i,l+1e5+1); } } int hoge = find(1); //cout << hoge << endl; for(int i=1;i<n-1;i++){ if(find(i)!=hoge) { cout << "NO" << endl; cout << i << endl; return 0; } } cout << "YES" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | polyomino |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1179 Byte |
Status | WA |
Exec Time | 58 ms |
Memory | 2560 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 5 ms | 2560 KB |
01-02.txt | WA | 6 ms | 2560 KB |
01-03.txt | WA | 5 ms | 2560 KB |
01-04.txt | WA | 6 ms | 2560 KB |
01-05.txt | WA | 5 ms | 2560 KB |
01-06.txt | WA | 6 ms | 2560 KB |
01-07.txt | WA | 6 ms | 2560 KB |
01-08.txt | WA | 6 ms | 2560 KB |
01-09.txt | WA | 6 ms | 2560 KB |
01-10.txt | WA | 6 ms | 2560 KB |
02-01.txt | WA | 41 ms | 2560 KB |
02-02.txt | WA | 52 ms | 2560 KB |
02-03.txt | WA | 42 ms | 2560 KB |
02-04.txt | WA | 51 ms | 2560 KB |
02-05.txt | WA | 52 ms | 2560 KB |
02-06.txt | WA | 51 ms | 2560 KB |
02-07.txt | WA | 53 ms | 2560 KB |
02-08.txt | WA | 45 ms | 2560 KB |
02-09.txt | WA | 58 ms | 2560 KB |
02-10.txt | WA | 48 ms | 2560 KB |
02-11.txt | WA | 48 ms | 2560 KB |
02-12.txt | WA | 46 ms | 2560 KB |
02-13.txt | WA | 47 ms | 2560 KB |
sample-01.txt | AC | 5 ms | 2560 KB |
sample-02.txt | WA | 5 ms | 2560 KB |