結果
| 問題 |
No.1717 Levi-Civita Triangle
|
| コンテスト | |
| ユーザー |
Koi
|
| 提出日時 | 2025-07-15 18:28:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 2,000 ms |
| コード長 | 1,664 bytes |
| コンパイル時間 | 375 ms |
| コンパイル使用メモリ | 82,328 KB |
| 実行使用メモリ | 99,100 KB |
| 最終ジャッジ日時 | 2025-07-15 18:28:16 |
| 合計ジャッジ時間 | 4,080 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
# N = int(input())
# A = list(map(int, input().split()))
def gutyoku(A):
L = A[:]
while len(L) > 1:
Q = []
for i in range(len(L) - 2):
T = (L[i], L[i + 1], L[i + 2])
if(T in ((0, 1, 2), (1, 2, 0), (2, 0, 1))):
Q.append(1)
elif(T in ((2,1,0),(1,0,2),(0,2,1))):
Q.append(2)
else:
Q.append(0)
# print(L, Q)
L = Q[:]
return L[0]
# N = 7
#L = [ [1, 0, 2, 0], [0, 2, 1, 2], [2, 1, 0, 1], [1, 2, 0, 2], [2, 0, 1, 0], [0, 1, 2, 1]]
def solve(A):
L = [[2, 1, 0, 1], [0, 2, 1, 2], [1, 0, 2, 0], [1, 2, 0, 2], [2, 0, 1, 0], [0, 1, 2, 1]]
Nxts = [4, 4, 4, 2, 2, 2]
NN = 2 * N + 1
# print(N, NN)
for j in range(len(L)):
is_j = True
for i in range(2 * N + 1):
if(A[i] != L[j][i % 4]):
is_j = False
break
if(is_j):
nowj = j
# print(nowj)
# print(NN)
while NN > 4:
NN -= 2
nowj = Nxts[nowj]
# print(NN, nowj)
B = []
for i in range(2 * NN + 1):
B.append(L[nowj][i % 4])
# print(nowj, N, B)
return (gutyoku(B))
return 0
# N = 4
# for i in range(3 ** (2 * N + 1)):
# x = i
# A = []
# for j in range(2 * N + 1):
# A.append(x % 3)
# x //= 3
# ans0 = gutyoku(A)
# ans1 = solve(A)
# if(ans0 != ans1):
# print(ans0, ans1)
# print(A)
# break
N = int(input())
A = list(map(int, input().split()))
# print(gutyoku(A))
print(solve(A))
Koi