結果
| 問題 |
No.1717 Levi-Civita Triangle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-14 20:04:44 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 671 ms / 2,000 ms |
| コード長 | 824 bytes |
| コンパイル時間 | 365 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 84,432 KB |
| 最終ジャッジ日時 | 2024-06-14 20:05:17 |
| 合計ジャッジ時間 | 31,499 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
import numpy as np
def conv(xs):
n = xs.shape[0]
ys = np.zeros(n - 2, dtype=np.int32)
d0 = xs[0:-2] - xs[1:-1]
d1 = xs[1:-1] - xs[2:]
d0 = (d0 + 3) % 3
d1 = (d1 + 3) % 3
ys[(d0 == 1) * (d1 == 1)] = 2
ys[(d0 == 2) * (d1 == 2)] = 1
return ys
def main():
n = int(input())
xs = np.array(list(map(int, input().split())), dtype=np.int32)
xs = conv(xs)
if n == 1:
return xs[0]
# 1 0 2 0 1 0 2 0 1
# 2 0 1 0 2 0 1
r = (len(xs) - 1) // 2
if not np.all(xs[1::2] == 0):
return 0
if (
np.all(xs[0::4] == 1) and np.all(xs[2::4] == 2)
) or (
np.all(xs[0::4] == 2) and np.all(xs[2::4] == 1)
):
if r % 2 == 0:
return xs[0]
else:
return 3 - xs[0]
return 0
print(main())