結果

問題 No.1156 Nada Picnic 2
ユーザー MaboyMaboy
提出日時 2023-02-08 19:42:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,212 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 8,256 KB
最終ジャッジ日時 2023-09-20 10:19:37
合計ジャッジ時間 3,867 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 970 ms
8,136 KB
testcase_01 AC 1,212 ms
8,256 KB
testcase_02 AC 78 ms
8,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

def ucc(n):
    s = ["シイタ+ケヤマ=イキタイ","オオツカ+コクサイ=ビジツカン","spring+eight=picnic"][n-1]
    key = sorted(set([x for x in s if x not in "+="]))
    r = [x for x in range(10)][::1-(n==2)*2]
    p = itertools.permutations(r)
    for _,i in enumerate(p):
        if n == 3 and _ < 559720:
            continue
        t = s
        for j,k in enumerate(key):
            t = t.replace(k,str(i[j]))
        if "0" not in [t[0],t[t.find("+")+1],t[t.find("=")+1]]:
            if eval(t.replace("=","==")):
                return t[t.find("=")+1:]

print(ucc(int(input())))
0