結果
問題 | No.2301 Namorientation |
ユーザー | Shirotsume |
提出日時 | 2023-03-16 00:11:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 974 ms / 3,000 ms |
コード長 | 1,248 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 81,732 KB |
実行使用メモリ | 228,380 KB |
最終ジャッジ日時 | 2023-10-18 12:56:57 |
合計ジャッジ時間 | 25,147 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
55,528 KB |
testcase_01 | AC | 40 ms
55,528 KB |
testcase_02 | AC | 40 ms
55,528 KB |
testcase_03 | AC | 40 ms
55,528 KB |
testcase_04 | AC | 41 ms
55,528 KB |
testcase_05 | AC | 41 ms
55,528 KB |
testcase_06 | AC | 41 ms
55,528 KB |
testcase_07 | AC | 42 ms
55,528 KB |
testcase_08 | AC | 42 ms
55,528 KB |
testcase_09 | AC | 42 ms
55,528 KB |
testcase_10 | AC | 41 ms
55,528 KB |
testcase_11 | AC | 41 ms
55,528 KB |
testcase_12 | AC | 573 ms
146,532 KB |
testcase_13 | AC | 509 ms
139,696 KB |
testcase_14 | AC | 973 ms
197,764 KB |
testcase_15 | AC | 630 ms
152,012 KB |
testcase_16 | AC | 806 ms
181,572 KB |
testcase_17 | AC | 597 ms
147,780 KB |
testcase_18 | AC | 818 ms
182,656 KB |
testcase_19 | AC | 495 ms
134,024 KB |
testcase_20 | AC | 831 ms
182,020 KB |
testcase_21 | AC | 632 ms
147,824 KB |
testcase_22 | AC | 516 ms
195,636 KB |
testcase_23 | AC | 506 ms
194,660 KB |
testcase_24 | AC | 418 ms
163,640 KB |
testcase_25 | AC | 399 ms
178,320 KB |
testcase_26 | AC | 520 ms
228,380 KB |
testcase_27 | AC | 954 ms
198,184 KB |
testcase_28 | AC | 974 ms
198,200 KB |
testcase_29 | AC | 949 ms
198,204 KB |
testcase_30 | AC | 968 ms
198,136 KB |
testcase_31 | AC | 953 ms
198,088 KB |
ソースコード
import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() graph = [set() for _ in range(n)] d = {} ans = [None] * n for i in range(n): u, v = mi() u -= 1; v -= 1 d[u, v] = d[v, u] = i graph[u].add(v) graph[v].add(u) q = [] for i in range(n): if len(graph[i]) == 1: q.append(i) while q: now = q.pop() to = graph[now].pop() if now < to: ans[d[now, to]] = "->" else: ans[d[now, to]] = "<-" graph[to].discard(now) if len(graph[to]) == 1: q.append(to) for i in range(n): if len(graph[i]) > 1: now = i to = graph[i].pop() if now < to: ans[d[now, to]] = "->" else: ans[d[now, to]] = "<-" graph[to].discard(now) if len(graph[to]) == 1: q.append(to) break while q: now = q.pop() to = graph[now].pop() if now < to: ans[d[now, to]] = "->" else: ans[d[now, to]] = "<-" graph[to].discard(now) if len(graph[to]) == 1: q.append(to) for v in ans: print(v)