結果

問題 No.326 あみだますたー
ユーザー 小指が強い人小指が強い人
提出日時 2015-12-19 01:30:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-04-25 11:55:28
合計ジャッジ時間 3,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
12,288 KB
testcase_01 AC 85 ms
12,032 KB
testcase_02 AC 82 ms
12,160 KB
testcase_03 AC 90 ms
12,160 KB
testcase_04 AC 84 ms
12,160 KB
testcase_05 AC 78 ms
12,160 KB
testcase_06 AC 83 ms
12,544 KB
testcase_07 AC 78 ms
12,288 KB
testcase_08 AC 83 ms
12,544 KB
testcase_09 AC 94 ms
12,160 KB
testcase_10 AC 93 ms
12,672 KB
testcase_11 AC 78 ms
12,160 KB
testcase_12 AC 86 ms
12,416 KB
testcase_13 AC 85 ms
12,416 KB
testcase_14 AC 79 ms
12,416 KB
testcase_15 AC 82 ms
12,288 KB
testcase_16 AC 83 ms
12,160 KB
testcase_17 AC 81 ms
12,288 KB
testcase_18 AC 79 ms
12,160 KB
testcase_19 AC 96 ms
12,416 KB
testcase_20 AC 76 ms
12,160 KB
testcase_21 AC 77 ms
12,288 KB
testcase_22 AC 85 ms
12,544 KB
testcase_23 AC 87 ms
12,416 KB
testcase_24 AC 92 ms
12,416 KB
testcase_25 AC 85 ms
12,416 KB
testcase_26 AC 78 ms
12,032 KB
testcase_27 AC 87 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:11: warning: assigned but unused variable - s2
Syntax OK

ソースコード

diff #

n = gets.to_i
k = gets.to_i
a = Array.new(n)
b = Array.new(n)
x = Array.new(n)
y = Array.new(n)
n.times do |i|
    a[i] = i + 1
end
k.times do
    s1, s2 = gets.split.map(&:to_i)
    a[s1 - 1], a[s1] = a[s1], a[s1 - 1]
end
b = gets.split.map(&:to_i)
n.times do |i|
    x[a[i] - 1] = i + 1
    y[b[i] - 1] = i + 1
end
res = Array.new(2).map{Array.new}
n.times do |i|
    next if a[i] == y[i]
    j = 0
    while y[i] != a[j]
        j += 1
    end
    while i != j
        a[j], a[j - 1] = a[j - 1], a[j]
        res[0].push(j)
        res[1].push(j + 1)
        j -= 1
    end
end
puts res[0].length
res[0].length.times do |i|
    print res[0][i], " ", res[1][i], "\n"
end
0