Submission #993363
Source Code Expand
from collections import defaultdict def main(): N, M = [int(i) for i in input().split()] L = [[] for _ in range(M+1)] for i in range(N): for j in map(int, input().split()[1:]): L[j].append(i) uf = UnionFind() for i, l in enumerate(L): #print("Lang {}".format(i)) if not l: continue a = l[0] for b in l[1:]: #print(a, b) uf.union(a, b) print(uf.table) print("YES" if uf.size(0) == N else "NO") class UnionFind(object): def __init__(self): self.table = defaultdict(lambda: -1) def find(self, x): if self.table[x] < 0: return x self.table[x] = self.find(self.table[x]) return self.table[x] def size(self, x): return -self.table[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def union(self, x, y): s1 = self.find(x) s2 = self.find(y) if s1 == s2: return False if self.table[s1] > self.table[s2]: s1, s2 = s2, s1 self.table[s1] += self.table[s2] self.table[s2] = s1 return True if __name__ == "__main__": main()
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | puyopop |
Language | PyPy3 (2.4.0) |
Score | 0 |
Code Size | 1275 Byte |
Status | WA |
Exec Time | 912 ms |
Memory | 115872 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | WA | 187 ms | 38384 KB |
01-02.txt | WA | 191 ms | 38384 KB |
01-03.txt | WA | 233 ms | 40304 KB |
01-04.txt | WA | 224 ms | 39536 KB |
01-05.txt | WA | 219 ms | 38896 KB |
01-06.txt | WA | 205 ms | 38256 KB |
01-07.txt | WA | 207 ms | 38896 KB |
01-08.txt | WA | 205 ms | 38256 KB |
01-09.txt | WA | 209 ms | 38768 KB |
01-10.txt | WA | 224 ms | 39024 KB |
02-01.txt | WA | 524 ms | 70816 KB |
02-02.txt | WA | 740 ms | 107224 KB |
02-03.txt | WA | 498 ms | 67292 KB |
02-04.txt | WA | 797 ms | 104992 KB |
02-05.txt | WA | 762 ms | 102104 KB |
02-06.txt | WA | 912 ms | 115872 KB |
02-07.txt | WA | 797 ms | 111064 KB |
02-08.txt | WA | 633 ms | 92244 KB |
02-09.txt | WA | 657 ms | 98204 KB |
02-10.txt | WA | 485 ms | 78852 KB |
02-11.txt | WA | 479 ms | 77700 KB |
02-12.txt | WA | 509 ms | 78940 KB |
02-13.txt | WA | 503 ms | 79324 KB |
sample-01.txt | WA | 191 ms | 38384 KB |
sample-02.txt | WA | 186 ms | 38256 KB |