結果
問題 |
No.2301 Namorientation
|
ユーザー |
![]() |
提出日時 | 2023-05-12 23:04:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 984 bytes |
コンパイル時間 | 113 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 108,672 KB |
最終ジャッジ日時 | 2024-11-28 19:45:08 |
合計ジャッジ時間 | 29,183 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 8 WA * 22 |
ソースコード
import sys input = sys.stdin.readline N=int(input()) EDGE=[list(map(int,input().split())) for i in range(N)] E=[[] for i in range(N+1)] DEG=[0]*(N+1) for i in range(N): a,b=EDGE[i] E[a].append((b,0,i)) E[b].append((a,1,i)) DEG[a]+=1 DEG[b]+=1 ANS=[""]*N Q=[] for i in range(1,N+1): if DEG[i]==1: Q.append(i) while Q: x=Q.pop() for to ,com, ind in E[x]: DEG[to]-=1 if com==0: ANS[ind]="->" else: ANS[ind]="<-" if DEG[to]==1: Q.append(to) USE=[0]*(N+1) for i in range(1,N+1): if DEG[i]==2: now=i else: USE[i]=1 initial = now while USE[now]==0: #print("!",now) USE[now]=1 for to ,com, ind in E[now]: if USE[to]==0 or to==initial: if com==0: ANS[ind]="->" else: ANS[ind]="<-" now=to break for ans in ANS: print(ans)