結果

問題 No.429 CupShuffle
ユーザー olpheolphe
提出日時 2016-11-14 02:56:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 884 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 52,136 KB
実行使用メモリ 5,040 KB
最終ジャッジ日時 2023-08-17 04:32:29
合計ジャッジ時間 1,747 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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 <= K; 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