Submission #991630
Source Code Expand
#include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<map> #include<queue> #include<cassert> #define PB push_back #define MP make_pair #define sz(v) (in((v).size())) #define forn(i,n) for(in i=0;i<(n);++i) #define forv(i,v) forn(i,sz(v)) #define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i) #define all(v) (v).begin(),(v).end() using namespace std; typedef long long in; typedef vector<in> VI; typedef vector<VI> VVI; struct unifnd{ VI ht,pr; in fnd(in a){ in ta=a; while(a!=pr[a])a=pr[a]; in tt=ta; while(ta!=a){ tt=pr[ta]; pr[ta]=a; ta=tt; } return a; } void uni(in a, in b){ a=fnd(a); b=fnd(b); if(a==b)return; if(ht[b]<ht[a])swap(a,b); pr[a]=b; ht[b]+=(ht[a]==ht[b]); } void ini(in n){ ht.resize(n); pr.resize(n); forn(i,n){ ht[i]=0; pr[i]=i; } } }; unifnd tfd; const in tn=1e5+9; int main(){ ios::sync_with_stdio(0); cin.tie(0); tfd.ini(2*tn); in n,m; cin>>n>>m; in k,a; forn(z,n){ cin>>k; forn(zz,k){ cin>>a; tfd.uni(z,tn+a); } } for(in i=1;i<n;++i){ if(tfd.fnd(i)!=tfd.fnd(0)){ cout<<"NO"<<endl; return 0; } } cout<<"YES"<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | w4yneb0t |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1328 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 3328 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 | 6 ms | 3328 KB |
01-02.txt | AC | 7 ms | 3328 KB |
01-03.txt | AC | 7 ms | 3328 KB |
01-04.txt | AC | 7 ms | 3328 KB |
01-05.txt | AC | 7 ms | 3328 KB |
01-06.txt | AC | 7 ms | 3328 KB |
01-07.txt | AC | 7 ms | 3328 KB |
01-08.txt | AC | 7 ms | 3328 KB |
01-09.txt | AC | 7 ms | 3328 KB |
01-10.txt | AC | 7 ms | 3328 KB |
02-01.txt | AC | 16 ms | 3328 KB |
02-02.txt | AC | 18 ms | 3328 KB |
02-03.txt | AC | 16 ms | 3328 KB |
02-04.txt | AC | 20 ms | 3328 KB |
02-05.txt | AC | 19 ms | 3328 KB |
02-06.txt | AC | 19 ms | 3328 KB |
02-07.txt | AC | 20 ms | 3328 KB |
02-08.txt | AC | 17 ms | 3328 KB |
02-09.txt | AC | 20 ms | 3328 KB |
02-10.txt | AC | 17 ms | 3328 KB |
02-11.txt | AC | 17 ms | 3328 KB |
02-12.txt | AC | 17 ms | 3328 KB |
02-13.txt | AC | 17 ms | 3328 KB |
sample-01.txt | AC | 6 ms | 3328 KB |
sample-02.txt | AC | 6 ms | 3328 KB |