結果

問題 No.2301 Namorientation
ユーザー flygonflygon
提出日時 2023-05-12 21:55:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 702 ms / 3,000 ms
コード長 1,282 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 343,296 KB
最終ジャッジ日時 2024-05-06 11:44:53
合計ジャッジ時間 19,285 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
55,040 KB
testcase_01 AC 48 ms
54,528 KB
testcase_02 AC 49 ms
55,168 KB
testcase_03 AC 42 ms
54,400 KB
testcase_04 AC 46 ms
54,656 KB
testcase_05 AC 45 ms
54,528 KB
testcase_06 AC 43 ms
54,784 KB
testcase_07 AC 46 ms
54,656 KB
testcase_08 AC 43 ms
54,656 KB
testcase_09 AC 45 ms
54,656 KB
testcase_10 AC 44 ms
54,912 KB
testcase_11 AC 44 ms
54,400 KB
testcase_12 AC 404 ms
156,288 KB
testcase_13 AC 383 ms
137,856 KB
testcase_14 AC 684 ms
177,280 KB
testcase_15 AC 446 ms
143,232 KB
testcase_16 AC 569 ms
162,892 KB
testcase_17 AC 407 ms
157,568 KB
testcase_18 AC 581 ms
166,628 KB
testcase_19 AC 348 ms
125,824 KB
testcase_20 AC 560 ms
165,940 KB
testcase_21 AC 452 ms
144,768 KB
testcase_22 AC 697 ms
343,296 KB
testcase_23 AC 695 ms
340,992 KB
testcase_24 AC 569 ms
290,048 KB
testcase_25 AC 329 ms
166,400 KB
testcase_26 AC 405 ms
181,500 KB
testcase_27 AC 696 ms
177,408 KB
testcase_28 AC 700 ms
177,280 KB
testcase_29 AC 699 ms
177,280 KB
testcase_30 AC 702 ms
178,560 KB
testcase_31 AC 692 ms
177,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')

n = int(input())
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
e = []
for i in range(n):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
    deg[a] += 1
    deg[b] += 1
    e.append((a,b))

que = []
use = set()
ans = []
for  i in range(1,n+1):
    if deg[i] == 1:
        que.append(i)
    
while que:
    crr = que.pop()
    use.add(crr)
    for nxt in graph[crr]:
        if nxt in use: continue
        ans.append([crr, nxt])
        deg[nxt] -= 1
        if deg[nxt] == 1:
            que.append(nxt)

v = [0]*(n+1)
for i in range(1,n+1):
    if i in use:
        v[i] = 1
ord = []
def dfs(crr):
    v[crr] = 1
    ord.append(crr)
    for nxt in graph[crr]:
        if v[nxt]: continue
        dfs(nxt)
for i in range(1,n+1):
    if i not in use:
        dfs(i)
        break

for i in range(len(ord)):
    ans.append([ord[i], ord[i-1]])

ans = set([(a,b) for a,b in ans ])
for a,b in e:
    if (a,b) in ans:
        print("->")
    else:
        print("<-")
0