Submission #1799242
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define sc second #define rep(i,x) for(int i=0;i<x;i++) #define repn(i,x) for(int i=1;i<=x;i++) #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) int n,m; int par[100005],ran[100005]; set<int>S; void init(){ for(int i=0;i<100005;i++) par[i] = i; } int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); } void unite(int x,int y){ x = find(x); y = find(y); if(x==y) return; if(ran[x] < ran[y]) par[x] = y; else{ par[y] = x; if(ran[x] == ran[y]) ran[x]++; } } bool same(int x,int y){ return find(x)==find(y); } int main(){ cin>>n>>m; init(); rep(i,n){ int x; cin>>x; int pre = -1; rep(j,x){ int a; cin>>a; S.insert(a); if(pre != -1){ unite(pre,a); } pre = a; } } set<int>SS; for(set<int>::iterator it=S.begin();it!=S.end();++it){ SS.insert(find(*it)); } puts((SS.size()==1?"YES":"NO")); }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | IH19980412 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1357 Byte |
Status | AC |
Exec Time | 65 ms |
Memory | 3968 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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 640 KB |
01-02.txt | AC | 2 ms | 640 KB |
01-03.txt | AC | 2 ms | 640 KB |
01-04.txt | AC | 2 ms | 640 KB |
01-05.txt | AC | 2 ms | 640 KB |
01-06.txt | AC | 2 ms | 640 KB |
01-07.txt | AC | 2 ms | 640 KB |
01-08.txt | AC | 2 ms | 640 KB |
01-09.txt | AC | 2 ms | 640 KB |
01-10.txt | AC | 2 ms | 640 KB |
02-01.txt | AC | 61 ms | 3968 KB |
02-02.txt | AC | 51 ms | 640 KB |
02-03.txt | AC | 56 ms | 2816 KB |
02-04.txt | AC | 65 ms | 3072 KB |
02-05.txt | AC | 53 ms | 1152 KB |
02-06.txt | AC | 65 ms | 3072 KB |
02-07.txt | AC | 55 ms | 1152 KB |
02-08.txt | AC | 33 ms | 640 KB |
02-09.txt | AC | 47 ms | 640 KB |
02-10.txt | AC | 49 ms | 2944 KB |
02-11.txt | AC | 47 ms | 2944 KB |
02-12.txt | AC | 52 ms | 2816 KB |
02-13.txt | AC | 52 ms | 2816 KB |
sample-01.txt | AC | 1 ms | 640 KB |
sample-02.txt | AC | 1 ms | 640 KB |