結果

問題 No.326 あみだますたー
ユーザー te-sh
提出日時 2017-06-28 12:28:12
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 103,556 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 20:35:58
合計ジャッジ時間 5,258 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 3 WA * 23
権限があれば一括ダウンロードができます

ソースコード

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 = a.countUntil(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