結果
問題 | No.2727 Tetrahedron Game |
ユーザー | rikein12 |
提出日時 | 2024-04-12 23:11:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 303 ms / 2,000 ms |
コード長 | 1,568 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 77,696 KB |
最終ジャッジ日時 | 2024-04-12 23:11:31 |
合計ジャッジ時間 | 3,005 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
67,340 KB |
testcase_01 | AC | 303 ms
77,696 KB |
testcase_02 | AC | 236 ms
77,204 KB |
testcase_03 | AC | 166 ms
76,504 KB |
testcase_04 | AC | 154 ms
76,244 KB |
testcase_05 | AC | 171 ms
76,708 KB |
testcase_06 | AC | 160 ms
76,656 KB |
testcase_07 | AC | 144 ms
76,472 KB |
testcase_08 | AC | 163 ms
76,664 KB |
testcase_09 | AC | 168 ms
77,244 KB |
ソースコード
from collections import deque def solve(): N,K = list(map(int,input().split())) p11, p12, p13 = list(map(int,input().split())) p21, p22, p23 = list(map(int,input().split())) p31, p32, p33 = list(map(int,input().split())) A = list(map(int,input().split())) S = input() V6 = p11 * p22 * p33 + p12*p23*p31 + p13*p21*p32 - p11*p23*p32 - p12*p21*p33 - p13*p22*p31 V6 = abs(V6) if V6 == 0: print("D") return DP = [0]*606 for i in range(606): if i%6 == 0: if i//6 >= K: DP[i] = 1 else: DP[i] = 2 for i in range(N-1,-1,-1): a = A[i] DP1 = [0]*606 if S[i] == "K": for j in range(606): nxt1 = j nxt2 = j * (1+a) % 606 if DP[nxt1] == 1 or DP[nxt2] == 1: DP1[j] = 1 elif DP[nxt1] == 2 and DP[nxt2] == 2: DP1[j] = 2 else: DP1[j] = 0 else: for j in range(606): nxt1 = j nxt2 = j * (1+a) % 606 if DP[nxt1] == 2 or DP[nxt2] == 2: DP1[j] = 2 elif DP[nxt1] == 1 and DP[nxt2] == 1: DP1[j] = 1 else: DP1[j] = 0 DP = DP1 #print(V6) #print(DP) if DP[V6%606] == 1: print("K") elif DP[V6%606] == 2: print("P") else: print("D") T = int(input()) for i in range(T): solve()