結果

問題 No.26 シャッフルゲーム
ユーザー te-sh
提出日時 2017-01-11 14:47:39
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 376 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 103,296 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 06:19:04
合計ジャッジ時間 1,336 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto n = readln.chomp.to!int - 1;
  auto m = readln.chomp.to!size_t;

  auto ci = new bool[](3);
  ci[n] = true;

  foreach (_; m.iota) {
    auto rd = readln.split.to!(int[]), p = rd[0] - 1, q = rd[1] - 1;
    swap(ci[p], ci[q]);
  }

  auto r = ci.countUntil!"a".to!int + 1;
  writeln(r);
}
0