結果

問題 No.429 CupShuffle
ユーザー ldsyb
提出日時 2016-10-03 00:15:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 65,600 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 15:00:27
合計ジャッジ時間 1,583 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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