Submission #5889714
Source Code Expand
n, m = [int(item) for item in input().split()] query = [] appeared = set() for i in range(n): line = [int(item) for item in input().split()] appeared.update(line[1:]) query.append(line[1:]) class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.size = [1] * n self.rank = [0] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def same_check(self, x, y): return self.find(x) == self.find(y) def get_size(self, x): return self.size[self.find(x)] def union(self, x, y): x = self.find(x) y = self.find(y) if self.rank[x] < self.rank[y]: self.par[x] = y else: self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 uf = UnionFind(m) for q in query: if len(q) == 1: continue for item in q[1:]: if not uf.same_check(q[0]-1, item-1): uf.union(q[0]-1, item-1) par = uf.find(appeared.pop() - 1) for item in appeared: if uf.find(item - 1) != par: print("No") exit() print("Yes")
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | nagitaosu |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1298 Byte |
Status | WA |
Exec Time | 418 ms |
Memory | 22036 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | 0 / 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 | WA | 17 ms | 3064 KB |
01-02.txt | WA | 20 ms | 3188 KB |
01-03.txt | WA | 21 ms | 3188 KB |
01-04.txt | WA | 21 ms | 3064 KB |
01-05.txt | WA | 21 ms | 3064 KB |
01-06.txt | WA | 21 ms | 3188 KB |
01-07.txt | WA | 21 ms | 3188 KB |
01-08.txt | WA | 20 ms | 3188 KB |
01-09.txt | WA | 21 ms | 3188 KB |
01-10.txt | WA | 21 ms | 3188 KB |
02-01.txt | WA | 315 ms | 14936 KB |
02-02.txt | WA | 393 ms | 15332 KB |
02-03.txt | WA | 280 ms | 12680 KB |
02-04.txt | WA | 413 ms | 19460 KB |
02-05.txt | WA | 381 ms | 15340 KB |
02-06.txt | WA | 418 ms | 19500 KB |
02-07.txt | WA | 392 ms | 16392 KB |
02-08.txt | WA | 385 ms | 13280 KB |
02-09.txt | WA | 386 ms | 22036 KB |
02-10.txt | WA | 322 ms | 16888 KB |
02-11.txt | WA | 307 ms | 16920 KB |
02-12.txt | WA | 340 ms | 16472 KB |
02-13.txt | WA | 344 ms | 16468 KB |
sample-01.txt | WA | 18 ms | 3064 KB |
sample-02.txt | WA | 17 ms | 3064 KB |