Submission #992006
Source Code Expand
#include<bits/stdc++.h> using namespace std; struct uni{ int d[100005]; void init(){ memset(d,-1,sizeof(d));} int find(int a){ return ( d[a]<0?a:(d[a]=find(d[a])) ); } void merge(int a,int b){ a = find(a); b = find(b); if( a == b ) return; if( d[a] > d[b] ) swap( a, b ); d[a] += d[b]; d[b] = a; } int size(int a){ return -d[find(a)]; } }; int N,M; vector<int> L[100005]; uni U; int main(){ cin >> N >> M; for(int i=0;i<N;i++){ int k; cin >> k; for(int j=0;j<k;j++){ int l; cin >> l; --l; L[l].push_back( i ); } } U.init(); for(int i=0;i<M;i++){ for( int j=1;j<(int)L[i].size();j++) U.merge( L[i][j-1], L[i][j] ); } if( U.size(0) == N ) cout << "YES" << endl; else cout << "NO" << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | sate3saku3 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 811 Byte |
Status | AC |
Exec Time | 60 ms |
Memory | 4992 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 | 5 ms | 2944 KB |
01-02.txt | AC | 6 ms | 2944 KB |
01-03.txt | AC | 6 ms | 2944 KB |
01-04.txt | AC | 6 ms | 2944 KB |
01-05.txt | AC | 6 ms | 2944 KB |
01-06.txt | AC | 6 ms | 2944 KB |
01-07.txt | AC | 6 ms | 2944 KB |
01-08.txt | AC | 6 ms | 2944 KB |
01-09.txt | AC | 6 ms | 2944 KB |
01-10.txt | AC | 6 ms | 2944 KB |
02-01.txt | AC | 49 ms | 4992 KB |
02-02.txt | AC | 53 ms | 3584 KB |
02-03.txt | AC | 48 ms | 4352 KB |
02-04.txt | AC | 59 ms | 4352 KB |
02-05.txt | AC | 56 ms | 3712 KB |
02-06.txt | AC | 59 ms | 4352 KB |
02-07.txt | AC | 58 ms | 3712 KB |
02-08.txt | AC | 46 ms | 3428 KB |
02-09.txt | AC | 60 ms | 3448 KB |
02-10.txt | AC | 52 ms | 4732 KB |
02-11.txt | AC | 52 ms | 4732 KB |
02-12.txt | AC | 51 ms | 4736 KB |
02-13.txt | AC | 51 ms | 4736 KB |
sample-01.txt | AC | 5 ms | 2944 KB |
sample-02.txt | AC | 5 ms | 2944 KB |