結果

問題 No.2684 折々の色
ユーザー nikoro256
提出日時 2024-03-22 18:04:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 212,632 KB
最終ジャッジ日時 2024-09-30 10:42:28
合計ジャッジ時間 24,204 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 55 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a % b)
        y -= (a // b) * x
        return d, x, y
    return a, 1, 0

#以下modinv
def mod_inv(a, m):
    g, x, y = extgcd(a, m)

    if g != 1:
        raise Exception()

    if x < 0:
        x += m

    return x

import sys
input=sys.stdin.readline
N,M=map(int,input().split())
X=list(map(int,input().split()))
C=[]
T=[]
Cset=set()
p=998244353
inv100=mod_inv(100,p)
for i in range(N):
    c=list(map(int,input().split()))
    C.append(c[:-1])
    T.append(c[-1])
    Ct=c[:-1]
    for i in range(M):
        Ct[i]*=T[-1]*inv100
        Ct[i]%=p
    Cset.add(tuple(Ct))
for i in range(N):
    if T[i]==100:
        if C[i]==X:
            print('Yes')
            exit(0)
        continue
    tinv=mod_inv((1-T[i]*inv100)%p,p)
    for j in range(M):
        C[i][j]*=T[i]*inv100%p
        C[i][j]%=p
        C[i][j]=X[j]-C[i][j]
        C[i][j]%=p
        C[i][j]*=tinv
        C[i][j]%=p
    if tuple(C[i]) in Cset:
        print('Yes')
        exit(0)
print('No')
0