結果
問題 | No.608 God's Maze |
ユーザー | fine |
提出日時 | 2017-12-08 01:36:44 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,583 bytes |
コンパイル時間 | 254 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-05-06 19:45:21 |
合計ジャッジ時間 | 10,846 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
12,160 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 83 ms
12,160 KB |
testcase_05 | AC | 77 ms
12,160 KB |
testcase_06 | WA | - |
testcase_07 | AC | 81 ms
12,160 KB |
testcase_08 | WA | - |
testcase_09 | AC | 82 ms
12,032 KB |
testcase_10 | AC | 80 ms
12,032 KB |
testcase_11 | WA | - |
testcase_12 | AC | 79 ms
12,032 KB |
testcase_13 | AC | 82 ms
12,160 KB |
testcase_14 | WA | - |
testcase_15 | AC | 76 ms
12,160 KB |
testcase_16 | AC | 78 ms
12,160 KB |
testcase_17 | AC | 78 ms
12,416 KB |
testcase_18 | AC | 76 ms
12,160 KB |
testcase_19 | AC | 77 ms
12,160 KB |
testcase_20 | AC | 79 ms
12,160 KB |
testcase_21 | AC | 78 ms
12,032 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 79 ms
12,032 KB |
testcase_25 | AC | 81 ms
12,416 KB |
testcase_26 | AC | 78 ms
12,032 KB |
testcase_27 | AC | 78 ms
12,160 KB |
testcase_28 | AC | 81 ms
12,160 KB |
testcase_29 | AC | 214 ms
12,288 KB |
testcase_30 | AC | 386 ms
12,416 KB |
testcase_31 | AC | 262 ms
12,288 KB |
testcase_32 | AC | 315 ms
12,544 KB |
testcase_33 | AC | 409 ms
12,416 KB |
testcase_34 | AC | 337 ms
12,544 KB |
testcase_35 | AC | 129 ms
12,288 KB |
testcase_36 | AC | 174 ms
12,288 KB |
testcase_37 | AC | 192 ms
12,160 KB |
testcase_38 | AC | 317 ms
12,416 KB |
testcase_39 | AC | 126 ms
12,544 KB |
testcase_40 | AC | 209 ms
12,544 KB |
testcase_41 | AC | 189 ms
12,288 KB |
testcase_42 | AC | 410 ms
12,416 KB |
testcase_43 | AC | 170 ms
12,416 KB |
testcase_44 | AC | 346 ms
12,416 KB |
testcase_45 | AC | 348 ms
12,416 KB |
testcase_46 | AC | 136 ms
12,544 KB |
testcase_47 | AC | 86 ms
12,288 KB |
testcase_48 | AC | 362 ms
12,544 KB |
testcase_49 | AC | 171 ms
12,288 KB |
testcase_50 | AC | 81 ms
12,032 KB |
testcase_51 | WA | - |
testcase_52 | AC | 81 ms
12,160 KB |
testcase_53 | AC | 81 ms
12,032 KB |
testcase_54 | AC | 80 ms
12,416 KB |
testcase_55 | AC | 79 ms
12,160 KB |
testcase_56 | AC | 79 ms
12,288 KB |
testcase_57 | AC | 79 ms
12,288 KB |
testcase_58 | AC | 80 ms
12,032 KB |
testcase_59 | AC | 81 ms
12,160 KB |
testcase_60 | AC | 81 ms
12,288 KB |
testcase_61 | AC | 80 ms
12,160 KB |
testcase_62 | WA | - |
testcase_63 | AC | 79 ms
12,160 KB |
testcase_64 | AC | 77 ms
12,160 KB |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.to_i - 1 s = gets.chomp m = s.size l = -1 n.times do |i| if s[i] == ?# l = i break end end r = -1 (m-1).downto(n+1) do |i| if s[i] == ?# r = i break end end ans = 1000000000 if l != -1 ans1 = 0 s1 = ?. * m l.upto(n-1) do |i| s1[i] = ?# ans1 += 1 end cnt = 0 m.times do |i| if s[i] != s1[i] cnt += 1 end end (l + 1).upto(m - 1) do |i| if cnt == 0 break end s1[i] = (s1[i] == ?. ? ?# : ?.) ans1 += 1 if s1[i] != s[i] ans1 += 2 s1[i] = s[i] s1[i + 1] = (s1[i + 1] == ?. ? ?# : ?.) if s1[i + 1] == s[i + 1] cnt -= 1 else cnt += 1 end else cnt -= 1 end end ans = [ans, ans1].min end if r != -1 ans2 = 0 s2 = ?. * m r.downto(n+1) do |i| s2[i] = ?# ans2 += 1 end cnt = 0 m.times do |i| if s[i] != s2[i] cnt += 1 end end (r - 1).downto(0) do |i| if cnt == 0 break end s2[i] = (s2[i] == ?. ? ?# : ?.) ans2 += 1 if s2[i] != s[i] ans2 += 2 s2[i] = s[i] s2[i - 1] = (s2[i - 1] == ?. ? ?# : ?.) if s2[i - 1] == s[i - 1] cnt -= 1 else cnt += 1 end else cnt -= 1 end end ans = [ans, ans2].min end p ans