結果
問題 | No.326 あみだますたー |
ユーザー | Leonardone |
提出日時 | 2015-12-19 02:55:16 |
言語 | Ruby (3.2.2) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 958 bytes |
コンパイル時間 | 73 ms |
コンパイル使用メモリ | 11,488 KB |
実行使用メモリ | 16,004 KB |
最終ジャッジ日時 | 2023-08-07 18:26:32 |
合計ジャッジ時間 | 4,223 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
15,116 KB |
testcase_01 | AC | 79 ms
15,136 KB |
testcase_02 | AC | 80 ms
15,112 KB |
testcase_03 | AC | 91 ms
15,440 KB |
testcase_04 | AC | 83 ms
15,316 KB |
testcase_05 | AC | 79 ms
15,260 KB |
testcase_06 | AC | 86 ms
15,448 KB |
testcase_07 | AC | 81 ms
15,284 KB |
testcase_08 | AC | 85 ms
15,968 KB |
testcase_09 | AC | 92 ms
16,004 KB |
testcase_10 | AC | 90 ms
15,812 KB |
testcase_11 | AC | 79 ms
15,248 KB |
testcase_12 | AC | 86 ms
15,628 KB |
testcase_13 | AC | 88 ms
15,512 KB |
testcase_14 | AC | 81 ms
15,340 KB |
testcase_15 | AC | 85 ms
15,372 KB |
testcase_16 | AC | 88 ms
15,280 KB |
testcase_17 | AC | 82 ms
15,484 KB |
testcase_18 | AC | 82 ms
15,240 KB |
testcase_19 | AC | 85 ms
15,296 KB |
testcase_20 | AC | 79 ms
15,236 KB |
testcase_21 | AC | 79 ms
15,340 KB |
testcase_22 | AC | 87 ms
15,532 KB |
testcase_23 | AC | 85 ms
15,624 KB |
testcase_24 | AC | 90 ms
15,484 KB |
testcase_25 | AC | 87 ms
15,488 KB |
testcase_26 | AC | 81 ms
15,252 KB |
testcase_27 | AC | 87 ms
15,616 KB |
コンパイルメッセージ
Syntax OK
ソースコード
#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU ############################################################ def gs() gets.chomp end def gi() gets.to_i end def gss() gets.chomp.split end def gis() gss.map(&:to_i) end def nmapf(n,f) n.times.map{ __send__ f } end def arr2d(h,w,v=0) h.times.map{[v] * w} end def ngs(n) nmapf n,:gs end def ngi(n) nmapf n,:gi end def ngss(n) nmapf n,:gss end def ngis(n) nmapf n,:gis end def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end def nsum(n) n * (n + 1) / 2 end ############################################################ N = gi f = (0..N).to_a K = gi K.times do x, y = gis f[x], f[y] = f[y], f[x] end A = gis (1..N).each do |i| f[i] = A[f[i] - 1] end ans = [] (1..N).each do |i| next if f[i] == i j = f.index(i) while j > i ans << "%d %d" % [j - 1, j] f[j - 1], f[j] = f[j], f[j - 1] j -= 1 end end puts ans.size puts ans * "\n"