結果

問題 No.2270 T0空間
ユーザー 👑 KazunKazun
提出日時 2023-04-14 22:20:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,428 ms / 2,000 ms
コード長 1,376 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 210,176 KB
最終ジャッジ日時 2024-04-18 19:49:58
合計ジャッジ時間 11,111 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,272 KB
testcase_01 AC 44 ms
54,016 KB
testcase_02 AC 42 ms
54,400 KB
testcase_03 AC 37 ms
54,272 KB
testcase_04 AC 38 ms
54,272 KB
testcase_05 AC 38 ms
54,048 KB
testcase_06 AC 39 ms
54,528 KB
testcase_07 AC 37 ms
54,272 KB
testcase_08 AC 36 ms
54,272 KB
testcase_09 AC 40 ms
54,272 KB
testcase_10 AC 36 ms
54,528 KB
testcase_11 AC 135 ms
89,552 KB
testcase_12 AC 100 ms
84,224 KB
testcase_13 AC 266 ms
110,636 KB
testcase_14 AC 287 ms
110,720 KB
testcase_15 AC 286 ms
110,720 KB
testcase_16 AC 553 ms
144,000 KB
testcase_17 AC 1,412 ms
210,176 KB
testcase_18 AC 1,428 ms
209,960 KB
testcase_19 AC 1,423 ms
209,560 KB
testcase_20 AC 1,416 ms
209,852 KB
testcase_21 AC 1,392 ms
210,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Hasher():
    def __init__(self, length, base, mod, type=0):
        self.length=length
        self.base=base
        self.mod=mod
        self.type=type

        self.power=pw=[1]*length
        for i in range(1, length):
            pw[i]=(base*pw[i-1])%mod

    def __repr__(self):
        return "length: {}\nbase: {}\nmod: {}".format(self.length, self.base, self.mod)

    def encode(self, S):
        code=0; N=len(S)
        for i in range(N):
            if self.type:
                code+=ord(S[i])*self.power[N-1-i]%self.mod
            else:
                code+=S[i]*self.power[N-1-i]%self.mod

        return code%self.mod

    def decode(self, S):
        pass

#==================================================
def solve():
    from random import randint
    N=int(input())
    M=int(input())

    T=[[0]*M for _ in range(N)]
    for i in range(M):
        S=input()
        for j in range(N):
            T[j][i]=int(S[j])

    E=set()
    Mod1=10**9+7; Mod2=10**9+9
    beta=randint(2,Mod1)
    H1=Hasher(M,beta,Mod1,0)
    H2=Hasher(M,beta,Mod2,0)

    for j in range(N):
        ha=H1.encode(T[j])*Mod2+H2.encode(T[j])
        if ha in E:
            return False
        E.add(ha)
    return True


#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

print("Yes" if solve() else "No")
0