結果

問題 No.233 めぐるはめぐる (3)
ユーザー 小指が強い人小指が強い人
提出日時 2015-12-13 23:57:28
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 11,324 KB
実行使用メモリ 15,460 KB
最終ジャッジ日時 2023-10-13 15:03:18
合計ジャッジ時間 11,572 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 75 ms
15,060 KB
testcase_10 AC 74 ms
15,176 KB
testcase_11 AC 74 ms
15,152 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

h = Hash.new{|h, k| h[k] = {}}
n = gets.to_i
if n == 0
   puts "inabameguru"
   exit
end
n.times do
    str = gets.strip
    str.length.times do |i|
        h[i][str[i]] = true
    end
end
s = ["a", "i", "u", "e", "n", "b", "m", "g", "r"]
ki = -1
kc = ""
h.length.times do |i|
    s.each do |c|
        if h[i][c] == nil
            ki = i
            kc = c
            break
        end
    end
    break if ki != -1
end
if ki != -1
    b = "inabameguru"
    bc = b[ki]
    if bc == kc
        puts b
        exit
    end
    h2 = {}
    h2["a"] = true; h2["i"] = true; h2["u"] = true; h2["e"] = true
    h2["b"] = false; h2["g"] = false; h2["m"] = false; h2["r"] = false; h2["n"] = false
    if (h2[bc] && !h2[kc]) || (!h2[bc] && h2[kc])
        b = "nabamegurui"
    end
    b.length.times do |i|
        if (h2[b[i]] == h2[kc]) && b[i] == kc
            b[i], b[ki] = b[ki], b[i]
            puts b
            exit
        end
    end
else
    puts "NO"
end
0