結果

問題 No.1254 補強への架け橋
ユーザー 37zigen37zigen
提出日時 2020-10-09 23:09:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 801 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 79,236 KB
最終ジャッジ日時 2023-09-27 19:33:38
合計ジャッジ時間 23,766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,796 KB
testcase_01 AC 13 ms
7,864 KB
testcase_02 AC 13 ms
7,796 KB
testcase_03 AC 14 ms
7,812 KB
testcase_04 AC 13 ms
7,928 KB
testcase_05 AC 15 ms
7,764 KB
testcase_06 AC 13 ms
7,812 KB
testcase_07 AC 13 ms
7,836 KB
testcase_08 AC 14 ms
7,728 KB
testcase_09 AC 14 ms
7,860 KB
testcase_10 AC 14 ms
7,808 KB
testcase_11 AC 13 ms
7,856 KB
testcase_12 AC 14 ms
7,916 KB
testcase_13 AC 14 ms
7,844 KB
testcase_14 AC 14 ms
7,776 KB
testcase_15 AC 14 ms
7,928 KB
testcase_16 AC 14 ms
7,836 KB
testcase_17 AC 15 ms
7,864 KB
testcase_18 AC 14 ms
7,764 KB
testcase_19 AC 15 ms
7,872 KB
testcase_20 AC 14 ms
7,868 KB
testcase_21 AC 14 ms
7,836 KB
testcase_22 AC 14 ms
7,796 KB
testcase_23 AC 15 ms
7,732 KB
testcase_24 AC 14 ms
7,800 KB
testcase_25 AC 14 ms
7,796 KB
testcase_26 AC 14 ms
8,332 KB
testcase_27 AC 14 ms
7,796 KB
testcase_28 AC 14 ms
7,812 KB
testcase_29 AC 14 ms
7,868 KB
testcase_30 AC 14 ms
7,864 KB
testcase_31 AC 15 ms
7,868 KB
testcase_32 AC 13 ms
7,868 KB
testcase_33 AC 14 ms
8,136 KB
testcase_34 AC 14 ms
7,904 KB
testcase_35 AC 13 ms
8,240 KB
testcase_36 AC 14 ms
7,792 KB
testcase_37 AC 13 ms
7,840 KB
testcase_38 AC 15 ms
7,732 KB
testcase_39 AC 14 ms
7,844 KB
testcase_40 AC 15 ms
7,800 KB
testcase_41 AC 14 ms
7,868 KB
testcase_42 AC 14 ms
7,868 KB
testcase_43 AC 18 ms
8,572 KB
testcase_44 AC 14 ms
8,276 KB
testcase_45 AC 16 ms
8,196 KB
testcase_46 AC 17 ms
8,520 KB
testcase_47 AC 17 ms
8,472 KB
testcase_48 AC 16 ms
8,444 KB
testcase_49 AC 14 ms
7,920 KB
testcase_50 AC 18 ms
8,632 KB
testcase_51 AC 17 ms
8,548 KB
testcase_52 AC 17 ms
8,608 KB
testcase_53 AC 17 ms
8,448 KB
testcase_54 AC 17 ms
8,680 KB
testcase_55 AC 17 ms
8,512 KB
testcase_56 AC 16 ms
8,212 KB
testcase_57 AC 16 ms
8,424 KB
testcase_58 AC 17 ms
8,464 KB
testcase_59 AC 14 ms
8,212 KB
testcase_60 AC 16 ms
8,196 KB
testcase_61 AC 18 ms
8,564 KB
testcase_62 AC 14 ms
8,344 KB
testcase_63 AC 53 ms
11,612 KB
testcase_64 AC 25 ms
9,056 KB
testcase_65 AC 41 ms
10,804 KB
testcase_66 AC 34 ms
9,892 KB
testcase_67 AC 22 ms
9,052 KB
testcase_68 AC 37 ms
10,764 KB
testcase_69 AC 42 ms
10,868 KB
testcase_70 AC 28 ms
9,408 KB
testcase_71 AC 23 ms
9,116 KB
testcase_72 AC 43 ms
10,864 KB
testcase_73 AC 25 ms
9,500 KB
testcase_74 AC 42 ms
10,988 KB
testcase_75 AC 34 ms
10,172 KB
testcase_76 AC 17 ms
8,704 KB
testcase_77 AC 30 ms
9,748 KB
testcase_78 AC 48 ms
11,336 KB
testcase_79 AC 50 ms
11,372 KB
testcase_80 AC 52 ms
11,068 KB
testcase_81 AC 52 ms
11,436 KB
testcase_82 AC 47 ms
11,212 KB
testcase_83 AC 476 ms
51,964 KB
testcase_84 AC 482 ms
51,820 KB
testcase_85 AC 280 ms
31,604 KB
testcase_86 AC 399 ms
39,152 KB
testcase_87 AC 436 ms
41,236 KB
testcase_88 AC 71 ms
13,660 KB
testcase_89 AC 473 ms
51,804 KB
testcase_90 AC 297 ms
32,688 KB
testcase_91 AC 238 ms
29,592 KB
testcase_92 AC 135 ms
18,784 KB
testcase_93 AC 414 ms
37,748 KB
testcase_94 AC 345 ms
35,272 KB
testcase_95 AC 349 ms
35,260 KB
testcase_96 AC 481 ms
51,508 KB
testcase_97 AC 205 ms
23,184 KB
testcase_98 AC 470 ms
51,520 KB
testcase_99 AC 272 ms
30,828 KB
testcase_100 AC 504 ms
52,104 KB
testcase_101 AC 120 ms
18,456 KB
testcase_102 AC 68 ms
13,348 KB
testcase_103 AC 127 ms
18,712 KB
testcase_104 AC 181 ms
21,196 KB
testcase_105 AC 392 ms
37,752 KB
testcase_106 AC 224 ms
29,200 KB
testcase_107 AC 499 ms
51,948 KB
testcase_108 AC 493 ms
51,796 KB
testcase_109 AC 383 ms
37,352 KB
testcase_110 AC 335 ms
34,900 KB
testcase_111 AC 383 ms
36,428 KB
testcase_112 AC 165 ms
20,632 KB
testcase_113 AC 330 ms
34,476 KB
testcase_114 AC 228 ms
24,140 KB
testcase_115 AC 82 ms
14,044 KB
testcase_116 AC 262 ms
30,012 KB
testcase_117 AC 160 ms
20,472 KB
testcase_118 AC 470 ms
51,516 KB
testcase_119 AC 282 ms
30,484 KB
testcase_120 AC 445 ms
41,140 KB
testcase_121 AC 141 ms
19,128 KB
testcase_122 AC 256 ms
29,760 KB
testcase_123 AC 15 ms
7,732 KB
testcase_124 AC 799 ms
79,204 KB
testcase_125 AC 801 ms
79,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)
N=int(input())
g=[[] for i in range(N+1)]
id=dict()
for i in range(N):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
    id[a+b*N]=i+1
    id[b+a*N]=i+1

ans=[]
vis=[-1]*(N+1)
stk=[]
def dfs(cur,par):
    vis[cur]=0
    stk.append((cur,par))
    for dst in g[cur]:
        if dst==par:
            continue
        if vis[dst]==-1:
            dfs(dst,cur)
        elif vis[dst]==0:
            ans.append(id[cur+dst*N])
            while stk:
                e=stk.pop()
                ans.append(id[e[0]+e[1]*N])
                if e[1]==dst:
                    break
    vis[cur]=1
    if stk:
        stk.pop()
dfs(1,0)
print(len(ans))
print(*ans)
0