Submission #7564139
Source Code Expand
from collections import deque N,M = map(int, input().split()) es_lang = [[] for _ in range(M+1)] # 各言語の番号がidxで、それを話せる人が中身 es_p = [[] for _ in range(N+1)] # 各人の番号がidxで、その人の話せる言語が中身 for i in range(N): KL = list(map(int, input().split())) es_p[i+1].extend(KL[1:]) for j in KL[1:]: es_lang[j].append(i+1) checked_lang = [False] * (M+1) checked_p = [False] * (N+1) #人1からスタートする stack_p = [1] checked_p[1] = True while len(stack_p) > 0: for p in stack_p: #p = stack_p.pop() # 調べる人を取り出す checked_p[p] = True stack_lang = [] for lang in es_p[p]: #人pが話せる言語について調べる if checked_lang[lang] == False: # まだその言語を調査してないとき stack_lang.append(lang) checked_lang[lang] = True # 人pの持つ言語をだれが話せるか調べる new_stack_p = [] for lang in stack_lang: for pp in es_lang[lang]: if checked_p[pp] == False: new_stack_p.append(pp) checked_p[pp] = True if all(checked_p[1:]): print("YES") exit() if len(new_stack_p) > 0: stack_p = new_stack_p print("NO")
Submission Info
Submission Time | |
---|---|
Task | C - Interpretation |
User | nejiyoshida |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1401 Byte |
Status | TLE |
Exec Time | 2105 ms |
Memory | 38832 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 | AC | 21 ms | 3316 KB |
01-02.txt | TLE | 2104 ms | 3444 KB |
01-03.txt | TLE | 2104 ms | 3572 KB |
01-04.txt | AC | 26 ms | 3572 KB |
01-05.txt | TLE | 2104 ms | 3444 KB |
01-06.txt | TLE | 2104 ms | 3572 KB |
01-07.txt | TLE | 2104 ms | 3444 KB |
01-08.txt | TLE | 2104 ms | 3572 KB |
01-09.txt | TLE | 2104 ms | 3444 KB |
01-10.txt | AC | 25 ms | 3700 KB |
02-01.txt | TLE | 2105 ms | 22056 KB |
02-02.txt | TLE | 2105 ms | 27848 KB |
02-03.txt | TLE | 2105 ms | 17928 KB |
02-04.txt | TLE | 2105 ms | 28036 KB |
02-05.txt | TLE | 2105 ms | 27676 KB |
02-06.txt | TLE | 2105 ms | 27960 KB |
02-07.txt | TLE | 2105 ms | 28096 KB |
02-08.txt | TLE | 2105 ms | 27388 KB |
02-09.txt | AC | 506 ms | 38832 KB |
02-10.txt | AC | 284 ms | 26076 KB |
02-11.txt | TLE | 2105 ms | 25472 KB |
02-12.txt | TLE | 2105 ms | 24508 KB |
02-13.txt | TLE | 2105 ms | 24264 KB |
sample-01.txt | AC | 21 ms | 3316 KB |
sample-02.txt | TLE | 2104 ms | 3316 KB |