結果

問題 No.429 CupShuffle
ユーザー olpheolphe
提出日時 2016-11-14 03:19:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 52,224 KB
実行使用メモリ 4,924 KB
最終ジャッジ日時 2023-08-17 04:32:47
合計ジャッジ時間 1,711 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "iostream"
using namespace std;

int N, K, X;
int place[100001];
int last[100001];
char box;
int num;
int change[100001][2];
int ans[2];

int main() {
	cin >> N >> K >> X;
	for (int i = 1; i <= N; i++) {
		place[i] = i;
	}
	for (int i = 1; i <= K; i++) {
		if (i != X) {
			cin >> change[i][0] >> change[i][1];
		}
		else cin >> box >> box;
	}
	for (int i = 1; i <= N; i++) {
		cin >> last[i];
	}
	for (int i = 1; i < X; i++) {
		num = place[change[i][0]];
		place[change[i][0]] = place[change[i][1]];
		place[change[i][1]] = num;
	}
	for (int i = K; i > X; i--) {
		num = last[change[i][0]];
		last[change[i][0]] = last[change[i][1]];
		last[change[i][1]] = num;
	}
	num = 0;
	for (int i = 1; i <= N; i++) {
		if (place[i] != last[i])ans[num++] = i;
	}
	if (ans[0] > ans[1])cout << ans[1] << " " << ans[0] << "\n";
	else cout << ans[0] << " " << ans[1] << "\n";
	return 0;
}
0