Submission #11232286
Source Code Expand
class UnionFind: def __init__(self, n): self.par = [i for i in range(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 unit(self, x, y): x = self.find(x) y = self.find(y) if x==y: return elif self.rank[x]<self.rank[y]: self.par[x] = y return elif self.rank[y]<self.rank[x]: self.par[y] = x else: self.par[y] = x self.rank[x] += 1 def same(self, x, y): return self.find(x)==self.find(y) N,M = map(int, input().split()) u = UnionFind(N+M) for i in range(N): inf = list(map(int, input().split())) for l in inf[1:]: u.unit(i,N+l-1) ans = all(u.same(i,i+1) for i in range(N-1)) if ans: print('YES') else: print('NO')
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | SA4504 |
Language | Python (3.4.3) |
Score | 400 |
Code Size | 863 Byte |
Status | AC |
Exec Time | 644 ms |
Memory | 12948 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 | 17 ms | 3064 KB |
01-02.txt | AC | 19 ms | 3064 KB |
01-03.txt | AC | 22 ms | 3188 KB |
01-04.txt | AC | 23 ms | 3188 KB |
01-05.txt | AC | 22 ms | 3188 KB |
01-06.txt | AC | 22 ms | 3188 KB |
01-07.txt | AC | 21 ms | 3064 KB |
01-08.txt | AC | 21 ms | 3188 KB |
01-09.txt | AC | 22 ms | 3064 KB |
01-10.txt | AC | 23 ms | 3188 KB |
02-01.txt | AC | 203 ms | 8112 KB |
02-02.txt | AC | 502 ms | 7704 KB |
02-03.txt | AC | 218 ms | 5936 KB |
02-04.txt | AC | 473 ms | 10544 KB |
02-05.txt | AC | 557 ms | 7344 KB |
02-06.txt | AC | 415 ms | 10544 KB |
02-07.txt | AC | 644 ms | 7856 KB |
02-08.txt | AC | 500 ms | 7856 KB |
02-09.txt | AC | 635 ms | 12596 KB |
02-10.txt | AC | 406 ms | 12948 KB |
02-11.txt | AC | 341 ms | 12408 KB |
02-12.txt | AC | 396 ms | 8240 KB |
02-13.txt | AC | 348 ms | 8240 KB |
sample-01.txt | AC | 17 ms | 3064 KB |
sample-02.txt | AC | 17 ms | 3064 KB |