結果
問題 | No.608 God's Maze |
ユーザー | fine |
提出日時 | 2017-12-08 01:48:08 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,621 bytes |
コンパイル時間 | 78 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2024-05-06 19:46:22 |
合計ジャッジ時間 | 11,301 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 92 ms
12,160 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 87 ms
12,032 KB |
testcase_05 | AC | 90 ms
12,288 KB |
testcase_06 | WA | - |
testcase_07 | AC | 85 ms
12,160 KB |
testcase_08 | WA | - |
testcase_09 | AC | 89 ms
12,288 KB |
testcase_10 | AC | 88 ms
12,416 KB |
testcase_11 | WA | - |
testcase_12 | AC | 86 ms
12,416 KB |
testcase_13 | AC | 85 ms
12,288 KB |
testcase_14 | WA | - |
testcase_15 | AC | 86 ms
12,032 KB |
testcase_16 | AC | 87 ms
12,416 KB |
testcase_17 | AC | 86 ms
12,160 KB |
testcase_18 | AC | 87 ms
12,288 KB |
testcase_19 | AC | 86 ms
12,160 KB |
testcase_20 | AC | 84 ms
12,416 KB |
testcase_21 | AC | 84 ms
12,032 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 88 ms
12,160 KB |
testcase_25 | AC | 88 ms
12,160 KB |
testcase_26 | AC | 89 ms
12,160 KB |
testcase_27 | AC | 91 ms
12,288 KB |
testcase_28 | AC | 87 ms
12,032 KB |
testcase_29 | AC | 232 ms
12,416 KB |
testcase_30 | AC | 409 ms
12,544 KB |
testcase_31 | AC | 274 ms
12,288 KB |
testcase_32 | AC | 330 ms
12,416 KB |
testcase_33 | AC | 428 ms
12,544 KB |
testcase_34 | AC | 357 ms
12,672 KB |
testcase_35 | AC | 140 ms
12,288 KB |
testcase_36 | AC | 182 ms
12,288 KB |
testcase_37 | AC | 204 ms
12,544 KB |
testcase_38 | AC | 337 ms
12,544 KB |
testcase_39 | AC | 145 ms
12,288 KB |
testcase_40 | AC | 221 ms
12,416 KB |
testcase_41 | AC | 212 ms
12,544 KB |
testcase_42 | AC | 437 ms
12,544 KB |
testcase_43 | AC | 188 ms
12,160 KB |
testcase_44 | AC | 380 ms
12,288 KB |
testcase_45 | AC | 377 ms
12,544 KB |
testcase_46 | AC | 153 ms
12,544 KB |
testcase_47 | AC | 97 ms
12,416 KB |
testcase_48 | AC | 397 ms
12,544 KB |
testcase_49 | AC | 192 ms
12,544 KB |
testcase_50 | AC | 94 ms
12,288 KB |
testcase_51 | AC | 90 ms
12,416 KB |
testcase_52 | AC | 88 ms
12,032 KB |
testcase_53 | AC | 87 ms
12,160 KB |
testcase_54 | AC | 87 ms
12,160 KB |
testcase_55 | AC | 89 ms
12,160 KB |
testcase_56 | AC | 87 ms
12,160 KB |
testcase_57 | AC | 94 ms
12,416 KB |
testcase_58 | AC | 89 ms
12,032 KB |
testcase_59 | AC | 88 ms
12,416 KB |
testcase_60 | AC | 88 ms
12,160 KB |
testcase_61 | AC | 86 ms
12,416 KB |
testcase_62 | WA | - |
testcase_63 | AC | 86 ms
12,288 KB |
testcase_64 | AC | 87 ms
12,416 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 if ans == 1000000000 ans = 3 end p ans