結果
問題 | No.608 God's Maze |
ユーザー | mkawa2 |
提出日時 | 2021-12-03 00:51:36 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,394 bytes |
コンパイル時間 | 93 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-07-05 03:15:05 |
合計ジャッジ時間 | 4,412 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 31 ms
10,624 KB |
testcase_02 | AC | 31 ms
10,624 KB |
testcase_03 | AC | 31 ms
10,752 KB |
testcase_04 | AC | 29 ms
10,752 KB |
testcase_05 | AC | 29 ms
10,752 KB |
testcase_06 | AC | 29 ms
10,752 KB |
testcase_07 | WA | - |
testcase_08 | AC | 29 ms
10,752 KB |
testcase_09 | AC | 30 ms
10,752 KB |
testcase_10 | AC | 30 ms
10,880 KB |
testcase_11 | AC | 29 ms
10,880 KB |
testcase_12 | AC | 29 ms
10,880 KB |
testcase_13 | AC | 28 ms
10,752 KB |
testcase_14 | AC | 29 ms
10,624 KB |
testcase_15 | AC | 29 ms
10,752 KB |
testcase_16 | AC | 29 ms
10,752 KB |
testcase_17 | AC | 29 ms
10,752 KB |
testcase_18 | AC | 30 ms
10,752 KB |
testcase_19 | AC | 29 ms
10,752 KB |
testcase_20 | AC | 32 ms
10,624 KB |
testcase_21 | AC | 29 ms
10,624 KB |
testcase_22 | AC | 29 ms
10,752 KB |
testcase_23 | AC | 29 ms
10,624 KB |
testcase_24 | AC | 31 ms
10,752 KB |
testcase_25 | AC | 30 ms
10,624 KB |
testcase_26 | AC | 28 ms
10,624 KB |
testcase_27 | AC | 29 ms
10,880 KB |
testcase_28 | AC | 29 ms
10,880 KB |
testcase_29 | WA | - |
testcase_30 | AC | 83 ms
12,400 KB |
testcase_31 | AC | 60 ms
11,904 KB |
testcase_32 | AC | 69 ms
11,888 KB |
testcase_33 | AC | 86 ms
12,288 KB |
testcase_34 | AC | 70 ms
12,160 KB |
testcase_35 | AC | 37 ms
10,880 KB |
testcase_36 | AC | 47 ms
11,392 KB |
testcase_37 | AC | 50 ms
11,392 KB |
testcase_38 | AC | 72 ms
11,776 KB |
testcase_39 | AC | 38 ms
11,008 KB |
testcase_40 | AC | 51 ms
11,520 KB |
testcase_41 | AC | 49 ms
11,520 KB |
testcase_42 | AC | 87 ms
12,544 KB |
testcase_43 | AC | 45 ms
11,264 KB |
testcase_44 | AC | 75 ms
12,160 KB |
testcase_45 | AC | 76 ms
12,288 KB |
testcase_46 | AC | 39 ms
11,264 KB |
testcase_47 | AC | 30 ms
10,624 KB |
testcase_48 | AC | 82 ms
12,160 KB |
testcase_49 | AC | 45 ms
11,392 KB |
testcase_50 | AC | 29 ms
10,752 KB |
testcase_51 | AC | 29 ms
10,880 KB |
testcase_52 | AC | 30 ms
10,880 KB |
testcase_53 | AC | 29 ms
10,624 KB |
testcase_54 | AC | 28 ms
10,880 KB |
testcase_55 | AC | 29 ms
10,752 KB |
testcase_56 | AC | 29 ms
10,880 KB |
testcase_57 | AC | 29 ms
10,880 KB |
testcase_58 | WA | - |
testcase_59 | AC | 29 ms
10,752 KB |
testcase_60 | AC | 30 ms
10,752 KB |
testcase_61 | AC | 29 ms
10,624 KB |
testcase_62 | AC | 31 ms
10,624 KB |
testcase_63 | AC | 29 ms
10,880 KB |
testcase_64 | AC | 28 ms
10,880 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 18446744073709551615 inf = 4294967295 # md = 10**9+7 md = 998244353 def rindex(aa, v): for i in range(len(aa))[::-1]: if aa[i] == v: return i return -1 def solve(aa, si): res = -1 if len(aa)-1 < si: return inf l = aa.index(1) r = rindex(aa, 1) if l==r==si: return 3 if l < si: res += si-l for i in range(l, si): aa[i] ^= 1 si = l aa[si] ^= 1 for i in range(si, r): if i == r and aa[i] == 0: break res += 1 aa[i] ^= 1 if aa[i]: aa[i] ^= 1 aa[i+1] ^= 1 res += 2 if aa[r]: res += 1 return res si = II()-1 aa = [(c == "#")*1 for c in SI()] n = len(aa) if sum(aa) == 0: print(0) exit() ans = min(solve(aa[:], si), solve(aa[::-1], n-1-si)) print(ans)