結果
問題 | No.416 旅行会社 |
ユーザー | Tawara |
提出日時 | 2016-08-27 06:56:57 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 851 ms / 4,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 708 ms |
コンパイル使用メモリ | 76,928 KB |
実行使用メモリ | 242,820 KB |
最終ジャッジ日時 | 2024-04-26 06:03:53 |
合計ジャッジ時間 | 10,663 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 343 ms
142,628 KB |
testcase_01 | AC | 84 ms
75,108 KB |
testcase_02 | AC | 87 ms
75,520 KB |
testcase_03 | AC | 86 ms
75,136 KB |
testcase_04 | AC | 88 ms
75,520 KB |
testcase_05 | AC | 88 ms
75,136 KB |
testcase_06 | AC | 91 ms
77,184 KB |
testcase_07 | AC | 101 ms
78,208 KB |
testcase_08 | AC | 127 ms
79,872 KB |
testcase_09 | AC | 186 ms
85,504 KB |
testcase_10 | AC | 349 ms
142,636 KB |
testcase_11 | AC | 518 ms
242,820 KB |
testcase_12 | AC | 484 ms
210,872 KB |
testcase_13 | AC | 467 ms
211,356 KB |
testcase_14 | AC | 739 ms
202,720 KB |
testcase_15 | AC | 794 ms
202,588 KB |
testcase_16 | AC | 822 ms
209,316 KB |
testcase_17 | AC | 851 ms
202,972 KB |
testcase_18 | AC | 764 ms
202,840 KB |
testcase_19 | AC | 705 ms
173,820 KB |
testcase_20 | AC | 567 ms
153,084 KB |
ソースコード
import sys def dfs(b,h,E,ans,reachable,turn): if reachable[h]: return reachable[h] = 1 ans[h] = turn for nxt in E[h]: if b == nxt: continue dfs(h,nxt,E,ans,reachable,turn) def solve(): ofs = 10**6 sys.setrecursionlimit(ofs) N,M,Q = map(int,raw_input().split()) reachable = [False]*N EL = [[] for i in xrange(N)] ans = [0]*N Break = set() Edges = map(lambda x: map(lambda x:int(x)-1,x.split()),sys.stdin.readlines()) for i in xrange(Q): Break.add(Edges[M+i][0]+Edges[M+i][1]*ofs) Break.add(Edges[M+i][0]*ofs+Edges[M+i][1]) for i in xrange(M): f,t = Edges[i] if (f+t*ofs) in Break: continue EL[f].append(t) EL[t].append(f) dfs(-1,0,EL,ans,reachable,-1) for i in xrange(Q,0,-1): f,t = Edges[M+i-1] EL[f].append(t) EL[t].append(f) if reachable[f]: dfs(f,t,EL,ans,reachable,i) elif reachable[t]: dfs(t,f,EL,ans,reachable,i) for i in xrange(1,N): print ans[i] solve()