結果

問題 No.3015 アンチローリングハッシュ
ユーザー zutsuzutsu
提出日時 2022-05-14 21:02:50
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 590 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 13,376 KB
最終ジャッジ日時 2023-09-30 14:02:04
合計ジャッジ時間 9,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
13,376 KB
testcase_01 AC 20 ms
8,936 KB
testcase_02 AC 20 ms
8,772 KB
testcase_03 AC 18 ms
8,964 KB
testcase_04 AC 1,486 ms
8,764 KB
testcase_05 AC 19 ms
8,848 KB
testcase_06 AC 1,493 ms
8,760 KB
testcase_07 AC 1,490 ms
8,768 KB
testcase_08 AC 1,496 ms
8,760 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
a,b = map(int, input().split())

def get_hash(s, a, b):
    h = 0
    for i in range(len(s)):
        h = (h * a + s[i]) % b
    return h

for n in range(1, 10**6):
    S = [random.randint(97, 122) for _ in range(n)]
    S_hash = get_hash(S, a, b)
    for _ in range(10**6--n):
        T = [random.randint(97, 122) for _ in range(n)]
        if S_hash == get_hash(T, a, b) and S != T:
            ss = [chr(s) for s in S]
            print(''.join(ss))
            tt = [chr(t) for t in T]
            print(''.join(tt))
            break
    else:
        continue
    break
0