Submission #5394444
Source Code Expand
#include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putchar('\n') #define eps 1e-10 #define MAXN 200005 //#define ivorysi using namespace std; typedef long long int64; typedef unsigned int u32; typedef double db; template<class T> void read(T &res) { res = 0;T f = 1;char c = getchar(); while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9') { res = res * 10 +c - '0'; c = getchar(); } res *= f; } template<class T> void out(T x) { if(x < 0) {x = -x;putchar('-');} if(x >= 10) { out(x / 10); } putchar('0' + x % 10); } int fa[MAXN * 2],N,M,K; int getfa(int x) { return x == fa[x] ? x : fa[x] = getfa(fa[x]); } void Solve() { read(N);read(M); for(int i = 1 ; i <= N + M ; ++i) fa[i] = i; int a; for(int i = 1 ; i <= N ; ++i) { read(K); for(int j = 1 ; j <= K ; ++j) { read(a); fa[getfa(i)] = getfa(a + N); } } for(int i = 1 ; i <= N ; ++i) { if(getfa(i) != getfa(1)) {puts("NO");return;} } puts("YES"); } int main() { #ifdef ivorysi freopen("f1.in","r",stdin); #endif Solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | sigongzi |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1314 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 1408 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 | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | AC | 1 ms | 256 KB |
01-07.txt | AC | 1 ms | 256 KB |
01-08.txt | AC | 1 ms | 256 KB |
01-09.txt | AC | 1 ms | 256 KB |
01-10.txt | AC | 1 ms | 256 KB |
02-01.txt | AC | 9 ms | 640 KB |
02-02.txt | AC | 7 ms | 640 KB |
02-03.txt | AC | 9 ms | 512 KB |
02-04.txt | AC | 10 ms | 896 KB |
02-05.txt | AC | 9 ms | 640 KB |
02-06.txt | AC | 9 ms | 896 KB |
02-07.txt | AC | 8 ms | 640 KB |
02-08.txt | AC | 5 ms | 640 KB |
02-09.txt | AC | 8 ms | 1024 KB |
02-10.txt | AC | 8 ms | 1408 KB |
02-11.txt | AC | 7 ms | 1408 KB |
02-12.txt | AC | 8 ms | 768 KB |
02-13.txt | AC | 8 ms | 768 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |