結果

問題 No.1267 Stop and Coin Game
ユーザー hir355hir355
提出日時 2020-10-23 23:46:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,411 ms / 2,000 ms
コード長 893 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 324,804 KB
最終ジャッジ日時 2023-09-28 19:05:14
合計ジャッジ時間 13,502 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,084 KB
testcase_01 AC 75 ms
71,460 KB
testcase_02 AC 77 ms
71,080 KB
testcase_03 AC 76 ms
71,228 KB
testcase_04 AC 79 ms
71,480 KB
testcase_05 AC 90 ms
76,688 KB
testcase_06 AC 84 ms
76,324 KB
testcase_07 AC 73 ms
71,388 KB
testcase_08 AC 158 ms
93,596 KB
testcase_09 AC 81 ms
76,492 KB
testcase_10 AC 792 ms
241,092 KB
testcase_11 AC 341 ms
130,800 KB
testcase_12 AC 144 ms
82,140 KB
testcase_13 AC 76 ms
71,144 KB
testcase_14 AC 75 ms
71,316 KB
testcase_15 AC 94 ms
76,600 KB
testcase_16 AC 1,315 ms
279,720 KB
testcase_17 AC 76 ms
71,392 KB
testcase_18 AC 110 ms
78,224 KB
testcase_19 AC 75 ms
71,144 KB
testcase_20 AC 82 ms
76,372 KB
testcase_21 AC 77 ms
71,420 KB
testcase_22 AC 112 ms
78,084 KB
testcase_23 AC 75 ms
71,164 KB
testcase_24 AC 296 ms
148,668 KB
testcase_25 AC 959 ms
253,304 KB
testcase_26 AC 73 ms
71,368 KB
testcase_27 AC 98 ms
78,728 KB
testcase_28 AC 76 ms
71,224 KB
testcase_29 AC 104 ms
76,976 KB
testcase_30 AC 563 ms
206,300 KB
testcase_31 AC 118 ms
78,728 KB
testcase_32 AC 119 ms
89,380 KB
testcase_33 AC 265 ms
146,188 KB
testcase_34 AC 708 ms
206,384 KB
testcase_35 AC 537 ms
214,836 KB
testcase_36 AC 74 ms
71,460 KB
testcase_37 AC 274 ms
112,564 KB
testcase_38 AC 1,411 ms
324,804 KB
testcase_39 AC 175 ms
89,688 KB
testcase_40 AC 74 ms
71,464 KB
testcase_41 AC 188 ms
91,680 KB
testcase_42 AC 76 ms
71,080 KB
testcase_43 AC 369 ms
129,204 KB
testcase_44 AC 76 ms
71,392 KB
testcase_45 AC 74 ms
70,968 KB
testcase_46 AC 76 ms
71,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, v = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) <= v:
    print('Draw')
    exit(0)

g = [[] for _ in range(1 << n)]
inv = [0] * (1 << n)
for i in range(1, 1 << n):
    t = 0
    for j in range(n):
        if (i >> j) & 1:
            t += a[j]
    if t <= v:
        for j in range(n):
            if (i >> j) & 1:
                g[i].append(i - (1 << j))
                g[i - (1 << j)].append(i)
                inv[i - (1 << j)] += 1
s = []
for i in range(1 << n):
    if inv[i] == 0:
        s.append(i)
wl = [-1] * (1 << n)
while s:
    p = s.pop()
    for node in g[p]:
        if wl[node] == -1:
            inv[node] -= 1
            if inv[node] == 0:
                s.append(node)
        else:
            if wl[node] == 0:
                wl[p] = 1
    if wl[p] == -1:
        wl[p] = 0
if wl[0] == 0:
    print('Second')
else:
    print('First')
0