結果
問題 | No.2984 [Cherry Anniversary 4] 満開の願いを込めた 27 の桜 |
ユーザー | Shirotsume |
提出日時 | 2024-11-20 21:55:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,166 bytes |
コンパイル時間 | 475 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 86,992 KB |
最終ジャッジ日時 | 2024-12-08 23:30:55 |
合計ジャッジ時間 | 51,993 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
ソースコード
import sys, time, random from collections import deque, Counter, defaultdict def debug(*x):print('debug:',*x, file=sys.stderr) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 #3*3*3のマス目に対し、行を入れ替える操作繰り返してできるマス目を列挙 S = [[[(i, j, k) for k in range(3)] for j in range(3)] for i in range(3)] def swap1(S, i, j): S = [x[:] for x in S] S[i], S[j] = S[j], S[i] return S def swap2(S, i, j): S = [x[:] for x in S] for k in range(3): S[k][i], S[k][j] = S[k][j], S[k][i] return S def swap3(S, i, j): S = [x[:] for x in S] for k in range(3): for l in range(3): S[k][l][i], S[k][l][j] = S[k][l][j], S[k][l][i] return S allsigma = set() def dfs(S): if tuple(tuple(tuple(x) for x in y) for y in S) in allsigma: return allsigma.add(tuple(tuple(tuple(x) for x in y) for y in S)) for i in range(3): for j in range(3): for k in range(3): dfs(swap1(S, i, j)) dfs(swap2(S, i, k)) dfs(swap3(S, j, k)) dfs(S) def solve(): A = [[li() for _ in range(3)] for _ in range(3)] X = [li() for _ in range(3)] Y = [li() for _ in range(3)] Z = [li() for _ in range(3)] for S in allsigma: B = [[[0]*3 for _ in range(3)] for _ in range(3)] for i in range(3): for j in range(3): for k in range(3): B[i][j][k] = A[S[i][j][k][0]][S[i][j][k][1]][S[i][j][k][2]] #X,Y,Zの値を検算 ok = True for i in range(3): for j in range(3): if B[0][i][j] + B[1][i][j] + B[2][i][j] != X[i][j]: ok = False if B[i][0][j] + B[i][1][j] + B[i][2][j] != Y[j][i]: ok = False if B[i][j][0] + B[i][j][1] + B[i][j][2] != Z[i][j]: ok = False if ok: print('Yes') return print('No') for _ in range(ii()): solve()