結果
| 問題 |
No.1371 交換門松列・松
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:17:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 791 bytes |
| コンパイル時間 | 303 ms |
| コンパイル使用メモリ | 82,668 KB |
| 実行使用メモリ | 269,456 KB |
| 最終ジャッジ日時 | 2025-06-12 14:17:51 |
| 合計ジャッジ時間 | 7,454 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 TLE * 1 -- * 13 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
n = int(input[0])
a = list(map(int, input[1:n+1]))
valid = 0
for i in range(n):
for j in range(i+1, n):
# Check all triplets affected by i and j
# Create a copy to test the swap
a_swapped = a.copy()
a_swapped[i], a_swapped[j] = a_swapped[j], a_swapped[i]
# Check all triplets
is_valid = True
for k in range(n-2):
x, y, z = a_swapped[k], a_swapped[k+1], a_swapped[k+2]
if y != max(x, y, z) and y != min(x, y, z):
is_valid = False
break
if is_valid:
valid += 1
print(valid)
if __name__ == "__main__":
main()
gew1fw