結果

問題 No.326 あみだますたー
ユーザー te-shte-sh
提出日時 2017-06-27 19:19:21
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 90,460 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-03 14:52:23
合計ジャッジ時間 5,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto n = readln.chomp.to!size_t;
  auto k = readln.chomp.to!size_t;

  auto b = n.iota.array;

  foreach (_; 0..k) {
    auto rd = readln.split.to!(size_t[]).map!"a-1".array, x = rd[0], y = rd[1];
    swap(b[x], b[y]);
  }

  auto a = readln.split.to!(size_t[]).map!"a-1".array;
  size_t[] r;

  foreach (i; 0..n-1) {
    auto j = b.countUntil(a[i]);
    foreach_reverse (s; i..j) {
      r ~= s;
      swap(b[s], b[s+1]);
    }
  }

  writeln(r.length);
  foreach (ri; r)
    writeln(ri+1, " ", ri+2);
}
0