結果

問題 No.429 CupShuffle
ユーザー ldsybldsyb
提出日時 2016-10-03 00:15:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 65,544 KB
実行使用メモリ 5,172 KB
最終ジャッジ日時 2023-08-13 18:26:28
合計ジャッジ時間 1,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 66 ms
5,088 KB
testcase_12 AC 62 ms
5,172 KB
testcase_13 AC 66 ms
4,900 KB
testcase_14 AC 65 ms
4,876 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
	char drop;
	int n, k, x;
	cin >> n >> k >> x;
	int ans[2] = {-1}, a[k], b[k], c[n], cop[n];
	for(int i = 0; i < k; i++){
		if(i == x - 1){
			cin >> drop >> drop;
			a[i] = b[i] = -1;
			continue;
		}
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	for(int i = 0; i < n; i++){
		cin >> c[i];
		cop[i] = i + 1;
	}
	for(int i = 0; a[i] != -1; i++) swap(cop[a[i]], cop[b[i]]);
	for(int i = k; a[--i] != -1;) swap(c[a[i]], c[b[i]]);
	for(int i = 0; i < n; i++) if(cop[i] != c[i]) ans[ans[0] != -1] = i + 1;
	cout << ans[0] << ' ' << ans[1] << endl;
}
0