結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-27 17:04:06 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 692 bytes |
| コンパイル時間 | 839 ms |
| コンパイル使用メモリ | 108,340 KB |
| 実行使用メモリ | 7,156 KB |
| 最終ジャッジ日時 | 2024-06-12 22:10:16 |
| 合計ジャッジ時間 | 2,053 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd1 = readln.split.to!(int[]), n = rd1[0], k = rd1[1], x = rd1[2];
auto a = new int[](k), b = new int[](k);
foreach (i; 0..k) {
auto rd2 = readln.splitter;
if (i != x-1) {
a[i] = rd2.front.to!int-1; rd2.popFront();
b[i] = rd2.front.to!int-1;
}
}
auto c = readln.split.map!(to!int).map!"a-1".array;
auto d = new int[](n);
foreach (i; 0..n) d[i] = i;
foreach (i; 0..x-1) swap(d[a[i]], d[b[i]]);
foreach_reverse (i; x..k) swap(c[a[i]], c[b[i]]);
int[] ans;
foreach (i; 0..n)
if (d[i] != c[i]) ans ~= i;
ans.sort();
writeln(ans[0]+1, " ", ans[1]+1);
}