結果
| 問題 | No.608 God's Maze |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-28 02:42:38 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 72 ms / 2,000 ms |
| + 980µs | |
| コード長 | 821 bytes |
| 記録 | |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 11,920 KB |
| 最終ジャッジ日時 | 2026-10-26 11:21:22 |
| 合計ジャッジ時間 | 4,595 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 65 |
ソースコード
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = [int(x) % 2 for x in read().rstrip()]
def solve(S, N):
ret = 0
L = S.index(1)
while N > L:
N -= 1
ret += 1
S[N] ^= 1
if S[N] == 1:
if N == len(S) - 1:
return 3
S[N + 1] ^= 1
S[N] = 0
ret += 2
if sum(S) == 0:
return ret
R = max(n for n, x in enumerate(S) if x == 1)
while N < R:
N += 1
ret += 1
S[N] ^= 1
if S[N] == 1:
if N + 1 == R:
return ret + 2
ret += 2
S[N] = 0
S[N + 1] ^= 1
return ret
print(min(solve(S[:], N - 1), solve(S[::-1], len(S) - N)))
maspy