Submission #4540522
Source Code Expand
#include <bits/stdc++.h> #define rep(i, n) for (rint i = 1; i <= (n); i ++) #define re0(i, n) for (rint i = 0; i < (int) n; i ++) #define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt) #define rint register int using namespace std; typedef long long lo; template<typename tp> inline void read(tp &x) { x = 0; char c = getchar(); int f = 0; for (; c < '0' || c > '9'; f |= c == '-', c = getchar()); for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()); if (f) x = -x; } const int N = 3e5 + 233; int pre[N], id[N], n, m; inline int find(int x) { return pre[x] == x ? x : pre[x] = find(pre[x]); } inline void make(int x, int y) { pre[find(x)] = find(y); } int main(void) { read(n); read(m); rep (i, m) id[i] = i + n; rep (i, m + n) pre[i] = i; rep (i, n) { int p; read(p); rep (k, p) { int t; read(t); make(i, id[t]); } } set <int> s; rep (i, n) s.insert(find(i)); cout << (s.size() == 1 ? "YES" : "NO") << "\n"; }
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | foreverpiano |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1061 Byte |
Status | AC |
Exec Time | 12 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 | 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 | 1 ms | 256 KB |
01-07.txt | AC | 2 ms | 256 KB |
01-08.txt | AC | 1 ms | 256 KB |
01-09.txt | AC | 2 ms | 256 KB |
01-10.txt | AC | 1 ms | 256 KB |
02-01.txt | AC | 11 ms | 1024 KB |
02-02.txt | AC | 7 ms | 640 KB |
02-03.txt | AC | 10 ms | 640 KB |
02-04.txt | AC | 11 ms | 1280 KB |
02-05.txt | AC | 8 ms | 640 KB |
02-06.txt | AC | 12 ms | 1280 KB |
02-07.txt | AC | 8 ms | 640 KB |
02-08.txt | AC | 6 ms | 640 KB |
02-09.txt | AC | 9 ms | 1408 KB |
02-10.txt | AC | 8 ms | 1280 KB |
02-11.txt | AC | 8 ms | 1280 KB |
02-12.txt | AC | 8 ms | 896 KB |
02-13.txt | AC | 8 ms | 896 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |