結果

問題 No.429 CupShuffle
ユーザー gigimegigime
提出日時 2016-10-02 22:47:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 152,260 KB
実行使用メモリ 4,676 KB
最終ジャッジ日時 2023-08-13 17:13:44
合計ジャッジ時間 2,544 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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