CSES - Aalto Competitive Programming 2024 - wk11 - Wed - Results
Submission details
Task:Hacking hashes
Sender:aalto2024l_004
Submission time:2024-11-20 17:32:19 +0200
Language:Python3 (PyPy3)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.07 sdetails
#2ACCEPTED0.07 sdetails
#3ACCEPTED0.07 sdetails
#4ACCEPTED0.07 sdetails
#5ACCEPTED0.07 sdetails
#6ACCEPTED0.07 sdetails
#7ACCEPTED0.07 sdetails
#8ACCEPTED0.07 sdetails
#9ACCEPTED0.07 sdetails
#10ACCEPTED0.07 sdetails
#11ACCEPTED0.07 sdetails
#12ACCEPTED0.07 sdetails
#13ACCEPTED0.07 sdetails
#14ACCEPTED0.07 sdetails
#15ACCEPTED0.07 sdetails
#16ACCEPTED0.07 sdetails
#17ACCEPTED0.07 sdetails
#18ACCEPTED0.07 sdetails
#19ACCEPTED0.07 sdetails
#20ACCEPTED0.07 sdetails
#21ACCEPTED0.07 sdetails
#22ACCEPTED0.07 sdetails
#23ACCEPTED0.07 sdetails
#24ACCEPTED0.07 sdetails
#25ACCEPTED0.07 sdetails
#26ACCEPTED0.07 sdetails
#27ACCEPTED0.07 sdetails
#28ACCEPTED0.07 sdetails
#29ACCEPTED0.07 sdetails
#30ACCEPTED0.07 sdetails
#31ACCEPTED0.07 sdetails
#32ACCEPTED0.07 sdetails
#33ACCEPTED0.07 sdetails
#34ACCEPTED0.07 sdetails
#35ACCEPTED0.07 sdetails
#36ACCEPTED0.07 sdetails
#37ACCEPTED0.07 sdetails
#38ACCEPTED0.07 sdetails
#39ACCEPTED0.07 sdetails
#40ACCEPTED0.07 sdetails
#41ACCEPTED0.07 sdetails
#42ACCEPTED0.08 sdetails
#43ACCEPTED0.07 sdetails
#44ACCEPTED0.07 sdetails
#45ACCEPTED0.08 sdetails
#46ACCEPTED0.07 sdetails
#47ACCEPTED0.07 sdetails
#48ACCEPTED0.07 sdetails
#49ACCEPTED0.07 sdetails
#50ACCEPTED0.07 sdetails
#51ACCEPTED0.08 sdetails
#52ACCEPTED0.09 sdetails
#53ACCEPTED0.09 sdetails
#54ACCEPTED0.09 sdetails
#55ACCEPTED0.07 sdetails
#56ACCEPTED0.09 sdetails
#57ACCEPTED0.08 sdetails
#58ACCEPTED0.08 sdetails
#59ACCEPTED0.07 sdetails
#60ACCEPTED0.08 sdetails
#61ACCEPTED0.09 sdetails
#62ACCEPTED0.09 sdetails
#63ACCEPTED0.08 sdetails
#64ACCEPTED0.09 sdetails
#65ACCEPTED0.09 sdetails
#66ACCEPTED0.09 sdetails
#67ACCEPTED0.09 sdetails
#68ACCEPTED0.09 sdetails
#69ACCEPTED0.10 sdetails
#70ACCEPTED0.09 sdetails
#71ACCEPTED0.10 sdetails
#72ACCEPTED0.10 sdetails
#73ACCEPTED0.09 sdetails
#74ACCEPTED0.09 sdetails
#75ACCEPTED0.11 sdetails
#76ACCEPTED0.09 sdetails
#77ACCEPTED0.10 sdetails
#78ACCEPTED0.09 sdetails
#79ACCEPTED0.09 sdetails
#80ACCEPTED0.09 sdetails
#81ACCEPTED0.11 sdetails
#82ACCEPTED0.09 sdetails
#83ACCEPTED0.12 sdetails
#84ACCEPTED0.13 sdetails
#85ACCEPTED0.13 sdetails
#86ACCEPTED0.10 sdetails
#87ACCEPTED0.11 sdetails
#88ACCEPTED0.11 sdetails
#89ACCEPTED0.09 sdetails
#90ACCEPTED0.10 sdetails

Code

from itertools import product
import random
import string
def F(s):
    h = 0
    for c in s:
        h = (h * A + c) % B
    return h

def FF(s):
    h = 0
    for c in s:
        h = (h * A + ord(c)) % B
    return h

def FFF(s):
    h = (s[0] * AAAA + s[1] * AAA + s[2] * AA + s[1] * A + s[2]) % B
    return h

def num_to_s(x):
    s = ''
    for i in x:
        s += chr(i)
    return s


A, B = map(int, input().split())
AA = (A ** 2)% B
AAA = (AA * A) % B
AAAA = (AA ** 2) % B
# for x in range(0, 26):
#     for y in range(0, 26):
#         for z in range(-25, 26):
#             if F([x, y, z]) == 0 and (x != 0 or y != 0 or z != 0):
#                 print(x, y, z)
#                 s1 = ''
#                 s2 = ''
#                 for i in [x, y, z]:
#                     p, q = num_to_c(i)
#                     s1 += p
#                     s2 += q
#                 print(s1[::-1], s2[::-1])
#                 print(FF(s1[::-1]), FF(s2[::-1]))
h2s = dict()
hs = set()
while True:
    s = ''.join(random.choices(string.ascii_lowercase, k=7))
    h = FF(s)
    # print(h)
    if h in hs and h2s[h] != s:
        print(s, h2s[h])
        break
    hs.add(h)
    h2s[h] = s

Test details

Test 1

Verdict: ACCEPTED

input
6 6

correct output
dxvdzxfqi oheo

user output
prubbiq lnctsck

Test 2

Verdict: ACCEPTED

input
5 10

correct output
yzzzeszzyc uuhdakc

user output
zxktsnk cjjllfp

Test 3

Verdict: ACCEPTED

input
5 2

correct output
oheo yzzzeszzyc

user output
ddozaug rklzrtw

Test 4

Verdict: ACCEPTED

input
6 1

correct output
dxvdzxfqi oheo

user output
tdhfftt hnwzjpg

Test 5

Verdict: ACCEPTED

input
10 10

correct output
yzzzeszzyc uuhdakc

user output
xflmbvg jqtloqq

Test 6

Verdict: ACCEPTED

input
3 1

correct output
dxvdzxfqi oheo

user output
wihqnnq gdjmcms

Test 7

Verdict: ACCEPTED

input
9 10

correct output
oheo yzzzeszzyc

user output
hfjriqx klgmpmx

Test 8

Verdict: ACCEPTED

input
1 3

correct output
dxvdzxfqi oheo

user output
deuodof sfsfkcr

Test 9

Verdict: ACCEPTED

input
9 1

correct output
dxvdzxfqi oheo

user output
fuarshp dolubnx

Test 10

Verdict: ACCEPTED

input
1 4

correct output
oheo yzzzeszzyc

user output
distkau vievrxm

Test 11

Verdict: ACCEPTED

input
78 30

correct output
dxvdzxfqi uuhdakc

user output
auxnihy tzsgsyg

Test 12

Verdict: ACCEPTED

input
19 7

correct output
dxvdzxfqi uuhdakc

user output
hbuvfgp jbygnua

Test 13

Verdict: ACCEPTED

input
16 45

correct output
yrrkt aihwbdczv

user output
sxzefvl svudrjt

Test 14

Verdict: ACCEPTED

input
78 61

correct output
oedtdfgv zgivhgayf

user output
erraatw yctnaav

Test 15

Verdict: ACCEPTED

input
52 93

correct output
yzzzeszzyc uuhdakc

user output
miyyiwc ytxsdah

Test 16

Verdict: ACCEPTED

input
85 82

correct output
dxvdzxfqi onbkb

user output
dfarcgj lmijqpj

Test 17

Verdict: ACCEPTED

input
23 33

correct output
yzzzeszzyc aekmllmqu

user output
othbsru hqjgulq

Test 18

Verdict: ACCEPTED

input
30 19

correct output
oheo jftb

user output
pxtxyxz ggsbqsm

Test 19

Verdict: ACCEPTED

input
66 8

correct output
yzzzeszzyc uuhdakc

user output
zhxktrs ujamwce

Test 20

Verdict: ACCEPTED

input
10 44

correct output
uuhdakc gvnyskxly

user output
bnragvb hhsajkh

Test 21

Verdict: ACCEPTED

input
589 888

correct output
irnrs nvmno

user output
wehmhlx qfwrlzo

Test 22

Verdict: ACCEPTED

input
49 800

correct output
irnrs nvmno

user output
gfpnpyy sjttwob

Test 23

Verdict: ACCEPTED

input
209 702

correct output
yzzzeszzyc bpuse

user output
pivzufd dimysjx

Test 24

Verdict: ACCEPTED

input
518 670

correct output
nvmno mgmo

user output
jafgddg lranfsk

Test 25

Verdict: ACCEPTED

input
961 295

correct output
aekmllmqu wcpqoadrw

user output
wqdtnur cnxvcut

Test 26

Verdict: ACCEPTED

input
871 697

correct output
xfwgyq eokm

user output
dvmfibk ewpcwgd

Test 27

Verdict: ACCEPTED

input
308 714

correct output
nvmno lcwlpcmzza

user output
kcaadki oshxrew

Test 28

Verdict: ACCEPTED

input
426 481

correct output
onbkb kqupmfo

user output
axolobv yxltpwq

Test 29

Verdict: ACCEPTED

input
730 171

correct output
eqdlmuyo wpvfat

user output
wtpoixi sbuflno

Test 30

Verdict: ACCEPTED

input
864 801

correct output
wpvfat onbkb

user output
iihozcn hlhmude

Test 31

Verdict: ACCEPTED

input
6442 9170

correct output
wgqgje blui

user output
hphahnl xeuacgf

Test 32

Verdict: ACCEPTED

input
2861 290

correct output
wpvfat onbkb

user output
ixtvspq cxpwqsy

Test 33

Verdict: ACCEPTED

input
8589 597

correct output
oheo uuhdakc

user output
vclchlc chdvqzo

Test 34

Verdict: ACCEPTED

input
2486 6897

correct output
zlscxfnxo ngvkz

user output
ylakllw cjcxqnl

Test 35

Verdict: ACCEPTED

input
386 1958

correct output
vdihr miezzgst

user output
utlzavv csyfhdz

Test 36

Verdict: ACCEPTED

input
4581 4498

correct output
uxqojd rhvuifulrn

user output
uyzbdih ztmzedo

Test 37

Verdict: ACCEPTED

input
7286 877

correct output
irnrs iphgzlf

user output
dquxrwy ygfkqot

Test 38

Verdict: ACCEPTED

input
9445 1393

correct output
hdwsfcnq veukbhkw

user output
uvzipid yxswhal

Test 39

Verdict: ACCEPTED

input
3848 8971

correct output
xshrtktoj fcuzyfii

user output
rbvkpnl yfjmzkc

Test 40

Verdict: ACCEPTED

input
5469 57

correct output
dxvdzxfqi yzzzeszzyc

user output
usxkuwf suisgro

Test 41

Verdict: ACCEPTED

input
40770 64402

correct output
tced hbmnyt

user output
tnvaqyf gxtzhbp

Test 42

Verdict: ACCEPTED

input
25093 68059

correct output
ljrc wjxknzhykr

user output
ucmfxpj wxwifws

Test 43

Verdict: ACCEPTED

input
37455 79656

correct output
tppoycpya wviirv

user output
mwpkrat mohmtoz

Test 44

Verdict: ACCEPTED

input
11506 49687

correct output
xaupctgiid jcdd

user output
inxgwri jfgvjci

Test 45

Verdict: ACCEPTED

input
83486 43255

correct output
bodw cdmncijoh

user output
utbozpf qxlnowu

Test 46

Verdict: ACCEPTED

input
98903 30455

correct output
xshrtktoj pofnegkmkq

user output
glbjift ltmvrgg

Test 47

Verdict: ACCEPTED

input
78385 25806

correct output
fnyjzygwa zyfhqqpkk

user output
rrxmhdk iuldhuu

Test 48

Verdict: ACCEPTED

input
11350 85178

correct output
tsgztkzvwc rkra

user output
gqpeuaq uzpasre

Test 49

Verdict: ACCEPTED

input
1750 42650

correct output
rlmle czxwmutnse

user output
bbqfgqj osqqnvj

Test 50

Verdict: ACCEPTED

input
30097 47375

correct output
zlscxfnxo ayfmd

user output
cqgrabx stqewiz

Test 51

Verdict: ACCEPTED

input
494714 129204

correct output
czxwmutnse hudvk

user output
zphnjxz xlokucl

Test 52

Verdict: ACCEPTED

input
675884 327185

correct output
rlmle rejxztcu

user output
slywfsv xvtesum

Test 53

Verdict: ACCEPTED

input
823296 823560

correct output
ratyx aurscmksx

user output
sciehyz lqypoiz

Test 54

Verdict: ACCEPTED

input
846854 678908

correct output
rfpuucjk yjndrg

user output
josyapb injbzxf

Test 55

Verdict: ACCEPTED

input
420278 193978

correct output
begabk sqac

user output
axspele pyzalcy

Test 56

Verdict: ACCEPTED

input
93130 695227

correct output
nkomreccwl dfboyzq

user output
rorgkqw tcmffhn

Test 57

Verdict: ACCEPTED

input
984414 95962

correct output
plsmw rufywewnbq

user output
dbcgoou qwztkzq

Test 58

Verdict: ACCEPTED

input
87370 612080

correct output
psmbxgyf yzwvwyf

user output
jhsykov yegvtsb

Test 59

Verdict: ACCEPTED

input
365188 833610

correct output
jbbjpkxs asruylwnc

user output
frtjjir umogxpv

Test 60

Verdict: ACCEPTED

input
924244 804799

correct output
bxok beqs

user output
upqwrjf ufzszjp

Test 61

Verdict: ACCEPTED

input
3012218 7755483

correct output
rzhfdn bhig

user output
oioijqg ymfvpbe

Test 62

Verdict: ACCEPTED

input
8254242 8634301

correct output
gleo mavrtxor

user output
qjiswtr znzixjs

Test 63

Verdict: ACCEPTED

input
337938 5429289

correct output
hexlssw zxdfne

user output
tbjypjr jycjfxx

Test 64

Verdict: ACCEPTED

input
5545825 4865884

correct output
copwroka xebbxy

user output
qtxnzkp fakciyu

Test 65

Verdict: ACCEPTED

input
3795375 7727646

correct output
rgde yqleban

user output
qvfwcth paovetb

Test 66

Verdict: ACCEPTED

input
2188983 8702106

correct output
zmjbhiiqo gyrickzf

user output
wvrizng klxmcbd

Test 67

Verdict: ACCEPTED

input
1544663 1956286

correct output
lwvsjair peplyj

user output
nenepaj jkmcodu

Test 68

Verdict: ACCEPTED

input
5464835 7522941

correct output
wjctw wqbqsqcdqg

user output
desiobg wsjjkzs

Test 69

Verdict: ACCEPTED

input
2596718 4049688

correct output
nvyasakcug bsbyew

user output
yapdqxv ngzyozr

Test 70

Verdict: ACCEPTED

input
2965922 4020437

correct output
zthes oazfss

user output
nzaolpl ntqoxql

Test 71

Verdict: ACCEPTED

input
56122287 60624959

correct output
hgllxkyp oukmzblohw

user output
fiasxdx xufsnbh

Test 72

Verdict: ACCEPTED

input
42645140 73661194

correct output
xkdotul jvryawmaj

user output
modrwpg kyipqmc

Test 73

Verdict: ACCEPTED

input
44585330 18926703

correct output
yqmfko hogdxzgt

user output
kzfvcko bvcrzfc

Test 74

Verdict: ACCEPTED

input
56325214 7232406

correct output
wvmuumpi weyyifgfw

user output
mraidal vuehdfj

Test 75

Verdict: ACCEPTED

input
98889561 92098565

correct output
xcesn xvzzheobbo

user output
mdyjqzk pfblzfc

Test 76

Verdict: ACCEPTED

input
22701272 5642782

correct output
lescyxpmpw hkszwirdqk

user output
qftkugy uialuhq

Test 77

Verdict: ACCEPTED

input
91304885 96889971

correct output
rnve dxgzxms

user output
fefrkyf alkhdfu

Test 78

Verdict: ACCEPTED

input
7803372 23247950

correct output
aofeuxbryn bgcepuzv

user output
rtbqqss mreeora

Test 79

Verdict: ACCEPTED

input
89317875 1136575

correct output
kfdzbbelk esohyirdk

user output
czsmujl thvtpnl

Test 80

Verdict: ACCEPTED

input
1060874 37270195

correct output
pkkvrpnjgw aoljv

user output
cjumzqo enwgvmd

Test 81

Verdict: ACCEPTED

input
828199235 320792352

correct output
cmqjomgda cyptxxyb

user output
ijtuxah jqwcsli

Test 82

Verdict: ACCEPTED

input
193563111 73343920

correct output
gtswukro ziuzhijy

user output
ivazkwc pfffvst

Test 83

Verdict: ACCEPTED

input
165531091 479126951

correct output
ozbczatbfr nplek

user output
lvdzxmc jhltasr

Test 84

Verdict: ACCEPTED

input
835051605 652127789

correct output
ypkbe jvzy

user output
lbxwhma tnhdmjf

Test 85

Verdict: ACCEPTED

input
551842459 989875543

correct output
ajtuqsqbs tqboquks

user output
mqftrpq jsyobak

Test 86

Verdict: ACCEPTED

input
911411059 873575358

correct output
bhhhipl bcgsdgu

user output
txcqeoy xzolhwa

Test 87

Verdict: ACCEPTED

input
239756971 350744380

correct output
gddvcp osie

user output
slmlelu tphihyh

Test 88

Verdict: ACCEPTED

input
316394140 195182397

correct output
jthyube jxvfzsh

user output
mhsmali cbwukgn

Test 89

Verdict: ACCEPTED

input
698334027 81615941

correct output
ikrcixfxr ugacbxbd

user output
byekutn dhlxatc

Test 90

Verdict: ACCEPTED

input
104725912 462211740

correct output
alzppvu qlyi

user output
ckvtbjb cinifmj