結果
問題 | No.1717 Levi-Civita Triangle |
ユーザー |
![]() |
提出日時 | 2021-10-22 22:55:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 1,161 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,036 KB |
実行使用メモリ | 117,444 KB |
最終ジャッジ日時 | 2024-09-23 06:44:59 |
合計ジャッジ時間 | 4,471 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
mod = 1000000007eps = 10**-9def main():import sysinput = sys.stdin.readlinedef f(a, b, c):if (a+1)%3 == b and (b+1)%3 == c and (c+1)%3 == a:return 1elif (a+1)%3 == c and (c+1)%3 == b and (b+1)%3 == a:return 2else:return 0N = int(input())A = list(map(int, input().split()))if N == 1:print(f(A[0], A[1], A[2]))elif N == 2:B = []for i in range(3):B.append(f(A[i], A[i+1], A[i+2]))print(f(B[0], B[1], B[2]))else:B = []for i in range(2 * N - 1):B.append(f(A[i], A[i + 1], A[i + 2]))ok = 1for i in range(N * 2 - 1):if i & 1:if B[i] != 0:ok = 0else:if B[i] == 0:ok = 0if i > 0:if B[i] == B[i-2]:ok = 0if ok:if N & 1:print(B[0])else:print(B[0] ^ 3)else:print(0)if __name__ == '__main__':main()