結果

問題 No.429 CupShuffle
ユーザー gigime
提出日時 2016-10-02 22:47:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 165,652 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-21 13:23:53
合計ジャッジ時間 2,436 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N,K,X;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K >> X;
	vector< pair<int,int> > P(K + 1);
	for(int i = 1;i <= K;i++){
		if(i == X){
			char c,h;
			cin >> c >> h;
		}
		else{
			cin >> P [i].first >> P [i].second;
		}
	}
	vector<int> A(N + 1),C(N + 1);
	for(int i = 1;i <= N;i++){
		cin >> C [i];
		A [i] = i;
	}

	for(int i = 1;i < X;i++){
		swap(A [P [i].first],A [P [i].second]);
	}
	for(int i = K;i > X;i--){
		swap(C [P [i].first],C [P [i].second]);
	}
	vector<int> ans;
	for(int i = 1;i <= N;i++){
		if(A [i] != C [i]){
			ans.push_back(i);
		}
	}
	sort(ALL(ans));

	cout << ans [0] << " " << ans [1] << endl;

	return 0;
}
0