結果

問題 No.397 NO MORE KADOMATSU
ユーザー te-shte-sh
提出日時 2017-07-27 12:11:53
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 89,164 KB
実行使用メモリ 24,300 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-03 15:33:37
合計ジャッジ時間 2,599 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,364 KB
testcase_01 AC 26 ms
23,412 KB
testcase_02 AC 26 ms
24,300 KB
testcase_03 AC 26 ms
23,388 KB
testcase_04 AC 25 ms
23,628 KB
testcase_05 AC 26 ms
23,412 KB
testcase_06 AC 25 ms
23,448 KB
testcase_07 AC 26 ms
23,556 KB
testcase_08 AC 26 ms
24,048 KB
testcase_09 AC 26 ms
23,856 KB
testcase_10 AC 25 ms
23,616 KB
testcase_11 AC 25 ms
23,820 KB
testcase_12 AC 26 ms
23,520 KB
testcase_13 AC 26 ms
23,556 KB
testcase_14 AC 26 ms
23,676 KB
testcase_15 AC 26 ms
23,376 KB
testcase_16 AC 26 ms
23,628 KB
testcase_17 AC 26 ms
23,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(int[]);

  size_t[][] r;
  foreach (i; 0..n) {
    auto j = a[i..$].minIndex + i;
    if (i != j) {
      swap(a[i], a[j]);
      r ~= [i, j];
    }
  }

  writeln(r.length);
  foreach (ri; r)
    writeln(ri[0], " ", ri[1]);
  stdout.flush();

  readln;
}
0