Submission #991874
Source Code Expand
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define MAX_N 200000
struct UF {
int par[MAX_N],rank[MAX_N];
void init(int n){
for(int i = 0; i < n; i++){
par[i] = i;
rank[i] = 0;
}
}
int find(int x){
if(par[x] == 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(rank[x] < rank[y]){
par[x] = y;
}else{
par[y] = par[x];
if(rank[x] == rank[y]) rank[y]++;
}
}
bool same(int x, int y){
return find(x) == find(y);
}
};
int n, m;
int l[MAX_N];
int main(){
mset(l, -1);
cin>>n>>m;
UF uf;
uf.init(n);
rep(i, n){
int k;
cin>>k;
rep(j, k){
int t;
cin>>t;
if(l[t]<0) l[t] = i;
else uf.unite(l[t], i);
}
}
bool ok = true;
rep(i, n) if(!uf.same(0, i)) ok = false;
cout<<(ok?"YES":"NO")<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Interpretation |
User |
Lepton |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2041 Byte |
Status |
AC |
Exec Time |
58 ms |
Memory |
1792 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 |
3 ms |
1024 KB |
01-02.txt |
AC |
4 ms |
1024 KB |
01-03.txt |
AC |
4 ms |
1024 KB |
01-04.txt |
AC |
4 ms |
1024 KB |
01-05.txt |
AC |
4 ms |
1024 KB |
01-06.txt |
AC |
4 ms |
1024 KB |
01-07.txt |
AC |
4 ms |
1024 KB |
01-08.txt |
AC |
4 ms |
1024 KB |
01-09.txt |
AC |
4 ms |
1024 KB |
01-10.txt |
AC |
4 ms |
1024 KB |
02-01.txt |
AC |
38 ms |
1024 KB |
02-02.txt |
AC |
51 ms |
1792 KB |
02-03.txt |
AC |
39 ms |
1152 KB |
02-04.txt |
AC |
49 ms |
1408 KB |
02-05.txt |
AC |
51 ms |
1664 KB |
02-06.txt |
AC |
51 ms |
1408 KB |
02-07.txt |
AC |
53 ms |
1792 KB |
02-08.txt |
AC |
45 ms |
1792 KB |
02-09.txt |
AC |
58 ms |
1792 KB |
02-10.txt |
AC |
47 ms |
1408 KB |
02-11.txt |
AC |
46 ms |
1408 KB |
02-12.txt |
AC |
45 ms |
1408 KB |
02-13.txt |
AC |
45 ms |
1408 KB |
sample-01.txt |
AC |
3 ms |
1024 KB |
sample-02.txt |
AC |
3 ms |
1024 KB |