結果

問題 No.1254 補強への架け橋
ユーザー ayaoniayaoni
提出日時 2020-10-29 23:39:32
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 831 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 86,396 KB
実行使用メモリ 122,040 KB
最終ジャッジ日時 2023-09-29 04:14:18
合計ジャッジ時間 28,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,292 KB
testcase_01 AC 74 ms
71,104 KB
testcase_02 AC 77 ms
70,908 KB
testcase_03 AC 74 ms
70,820 KB
testcase_04 AC 74 ms
70,740 KB
testcase_05 AC 75 ms
70,820 KB
testcase_06 AC 73 ms
71,024 KB
testcase_07 AC 74 ms
70,888 KB
testcase_08 AC 75 ms
70,728 KB
testcase_09 AC 75 ms
71,292 KB
testcase_10 AC 76 ms
71,168 KB
testcase_11 AC 74 ms
70,824 KB
testcase_12 AC 75 ms
71,288 KB
testcase_13 AC 77 ms
70,928 KB
testcase_14 AC 76 ms
71,036 KB
testcase_15 AC 77 ms
71,012 KB
testcase_16 AC 76 ms
70,932 KB
testcase_17 AC 76 ms
70,908 KB
testcase_18 AC 77 ms
70,820 KB
testcase_19 AC 77 ms
70,824 KB
testcase_20 AC 76 ms
71,020 KB
testcase_21 AC 74 ms
70,932 KB
testcase_22 AC 74 ms
71,016 KB
testcase_23 AC 75 ms
70,856 KB
testcase_24 AC 76 ms
71,020 KB
testcase_25 AC 76 ms
70,884 KB
testcase_26 AC 75 ms
71,016 KB
testcase_27 AC 75 ms
71,024 KB
testcase_28 AC 76 ms
70,928 KB
testcase_29 AC 76 ms
71,028 KB
testcase_30 AC 75 ms
71,036 KB
testcase_31 AC 77 ms
71,164 KB
testcase_32 AC 73 ms
70,888 KB
testcase_33 AC 75 ms
71,144 KB
testcase_34 AC 75 ms
70,880 KB
testcase_35 AC 75 ms
70,884 KB
testcase_36 AC 77 ms
71,020 KB
testcase_37 AC 75 ms
70,904 KB
testcase_38 AC 77 ms
70,820 KB
testcase_39 AC 76 ms
70,892 KB
testcase_40 AC 75 ms
70,732 KB
testcase_41 AC 75 ms
70,892 KB
testcase_42 AC 75 ms
71,168 KB
testcase_43 AC 78 ms
70,876 KB
testcase_44 AC 75 ms
71,060 KB
testcase_45 AC 75 ms
71,248 KB
testcase_46 AC 78 ms
70,812 KB
testcase_47 AC 76 ms
71,068 KB
testcase_48 AC 77 ms
71,036 KB
testcase_49 AC 75 ms
70,876 KB
testcase_50 AC 83 ms
74,928 KB
testcase_51 AC 79 ms
70,828 KB
testcase_52 AC 80 ms
74,684 KB
testcase_53 AC 78 ms
71,028 KB
testcase_54 AC 79 ms
70,820 KB
testcase_55 AC 81 ms
74,868 KB
testcase_56 AC 78 ms
70,712 KB
testcase_57 AC 79 ms
71,152 KB
testcase_58 AC 79 ms
71,176 KB
testcase_59 AC 75 ms
70,860 KB
testcase_60 AC 77 ms
70,912 KB
testcase_61 AC 80 ms
71,044 KB
testcase_62 AC 76 ms
71,028 KB
testcase_63 AC 126 ms
81,024 KB
testcase_64 AC 101 ms
76,588 KB
testcase_65 AC 125 ms
79,800 KB
testcase_66 AC 128 ms
79,832 KB
testcase_67 AC 100 ms
76,616 KB
testcase_68 AC 117 ms
79,472 KB
testcase_69 AC 125 ms
80,364 KB
testcase_70 AC 103 ms
76,740 KB
testcase_71 AC 102 ms
76,588 KB
testcase_72 AC 121 ms
80,112 KB
testcase_73 AC 100 ms
76,508 KB
testcase_74 AC 123 ms
80,316 KB
testcase_75 AC 117 ms
79,620 KB
testcase_76 AC 87 ms
76,484 KB
testcase_77 AC 124 ms
79,192 KB
testcase_78 AC 134 ms
80,300 KB
testcase_79 AC 121 ms
80,600 KB
testcase_80 AC 126 ms
80,164 KB
testcase_81 AC 120 ms
80,300 KB
testcase_82 AC 126 ms
79,852 KB
testcase_83 AC 366 ms
119,472 KB
testcase_84 AC 340 ms
113,876 KB
testcase_85 AC 225 ms
101,404 KB
testcase_86 AC 303 ms
108,888 KB
testcase_87 AC 310 ms
110,760 KB
testcase_88 AC 139 ms
83,168 KB
testcase_89 AC 338 ms
118,948 KB
testcase_90 AC 250 ms
104,160 KB
testcase_91 AC 218 ms
99,640 KB
testcase_92 AC 163 ms
93,636 KB
testcase_93 AC 265 ms
108,872 KB
testcase_94 AC 277 ms
109,228 KB
testcase_95 AC 274 ms
108,864 KB
testcase_96 AC 345 ms
114,016 KB
testcase_97 AC 197 ms
100,520 KB
testcase_98 AC 319 ms
113,976 KB
testcase_99 AC 232 ms
100,964 KB
testcase_100 AC 313 ms
119,052 KB
testcase_101 AC 161 ms
91,476 KB
testcase_102 AC 133 ms
81,924 KB
testcase_103 AC 163 ms
91,792 KB
testcase_104 AC 182 ms
97,964 KB
testcase_105 AC 273 ms
108,460 KB
testcase_106 AC 208 ms
100,396 KB
testcase_107 AC 360 ms
119,076 KB
testcase_108 AC 336 ms
113,916 KB
testcase_109 AC 297 ms
108,600 KB
testcase_110 AC 255 ms
108,832 KB
testcase_111 AC 293 ms
108,200 KB
testcase_112 AC 185 ms
97,428 KB
testcase_113 AC 265 ms
108,276 KB
testcase_114 AC 212 ms
99,664 KB
testcase_115 AC 140 ms
83,652 KB
testcase_116 AC 237 ms
100,636 KB
testcase_117 AC 188 ms
97,596 KB
testcase_118 AC 298 ms
113,048 KB
testcase_119 AC 243 ms
100,940 KB
testcase_120 AC 299 ms
110,328 KB
testcase_121 AC 171 ms
94,160 KB
testcase_122 AC 198 ms
100,796 KB
testcase_123 AC 75 ms
71,408 KB
testcase_124 RE -
testcase_125 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N = I()
Graph = [[] for _ in range(N+1)]
dict_edge = {}
for i in range(1,N+1):
    a,b = MI()
    Graph[a].append(b)
    Graph[b].append(a)
    dict_edge[(a,b)] = i
    dict_edge[(b,a)] = i

flag = [0]*(N+1)
previous = [0]*(N+1)
ANS = []


def dfs(i,par):
    flag[i] = 1
    for j in Graph[i]:
        if j == par:
            continue
        elif flag[j] == 0:
            flag[j] = 1
            previous[j] = i
            dfs(j,i)
        else:
            ANS.append(dict_edge[(i,j)])
            k = i
            while k != j:
                ANS.append(dict_edge[k,previous[k]])
                k = previous[k]
            print(len(ANS))
            print(*ANS)
            exit()


dfs(1,0)
0