Submission #991892
Source Code Expand
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
struct UF{
vector<int> data;
UF(int size):data(size,-1){}
bool unite(int x,int y){
x=root(x); y=root(y);
if(x!=y){
if(data[y]<data[x]) swap(x,y);
data[x]+=data[y]; data[y]=x;
}
return x!=y;
}
bool findSet(int x,int y){return root(x)==root(y);}
int root(int x){return data[x]<0?x:data[x]=root(data[x]);}
int size(int x) {return -data[root(x)];}
};
int main(){
ios_base::sync_with_stdio(false);
cout<<fixed<<setprecision(0);
int n,m;
cin>>n>>m;
UF uf(n+m);
rep(i,n){
int t,x;
cin>>t;
rep(j,t){
cin>>x; --x;
uf.unite(i,x+n);
}
}
int f=1;
rep(i,n) if(!uf.findSet(i,0)) f=0;
cout<<(f?"YES":"NO")<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Interpretation |
User |
nuip |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2231 Byte |
Status |
AC |
Exec Time |
17 ms |
Memory |
1024 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 |
2 ms |
256 KB |
01-02.txt |
AC |
2 ms |
256 KB |
01-03.txt |
AC |
2 ms |
256 KB |
01-04.txt |
AC |
2 ms |
256 KB |
01-05.txt |
AC |
2 ms |
256 KB |
01-06.txt |
AC |
2 ms |
256 KB |
01-07.txt |
AC |
2 ms |
256 KB |
01-08.txt |
AC |
2 ms |
256 KB |
01-09.txt |
AC |
2 ms |
256 KB |
01-10.txt |
AC |
2 ms |
256 KB |
02-01.txt |
AC |
12 ms |
640 KB |
02-02.txt |
AC |
16 ms |
640 KB |
02-03.txt |
AC |
12 ms |
512 KB |
02-04.txt |
AC |
16 ms |
896 KB |
02-05.txt |
AC |
16 ms |
640 KB |
02-06.txt |
AC |
16 ms |
896 KB |
02-07.txt |
AC |
16 ms |
640 KB |
02-08.txt |
AC |
14 ms |
640 KB |
02-09.txt |
AC |
17 ms |
1024 KB |
02-10.txt |
AC |
14 ms |
640 KB |
02-11.txt |
AC |
14 ms |
640 KB |
02-12.txt |
AC |
14 ms |
640 KB |
02-13.txt |
AC |
14 ms |
640 KB |
sample-01.txt |
AC |
2 ms |
256 KB |
sample-02.txt |
AC |
2 ms |
256 KB |