結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
13,144 KB
testcase_01 AC 18 ms
8,908 KB
testcase_02 AC 19 ms
8,972 KB
testcase_03 AC 19 ms
8,768 KB
testcase_04 AC 18 ms
8,772 KB
testcase_05 AC 19 ms
8,912 KB
testcase_06 AC 234 ms
8,960 KB
testcase_07 AC 165 ms
8,884 KB
testcase_08 AC 1,398 ms
9,764 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(b, 10**6+1):
    S = [random.randint(97, 122) for _ in range(n)]
    S_hash = get_hash(S, a, b)
    for _ in range(10):
        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