結果

問題 No.429 CupShuffle
ユーザー Kmcode1Kmcode1
提出日時 2016-10-02 22:29:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 1,167 ms
コンパイル使用メモリ 147,556 KB
実行使用メモリ 4,824 KB
最終ジャッジ日時 2023-08-13 17:01:43
合計ジャッジ時間 2,232 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 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,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 31 ms
4,472 KB
testcase_12 AC 30 ms
4,824 KB
testcase_13 AC 32 ms
4,812 KB
testcase_14 AC 31 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define MAX 100002

int n;
int k;
int x;

int a[MAX];

vector<pair<int, int> > v;
int c[MAX];

int main(){
	cin >> n >> k >> x;
	x--;
	for (int i = 0; i < n; i++)a[i] = i;
	for (int i = 0; i < x; i++){
		int aa, b;
		scanf("%d%d", &aa, &b);
		swap(a[aa - 1], a[b - 1]);
	}
	int aa, b;
	char aaa, bbb;
	cin >> aaa >> bbb;
	for (int i = x+1; i < k; i++){
		scanf("%d%d", &aa, &b);
		v.push_back(make_pair(aa-1, b-1));
	}
	for (int i = 0; i < n; i++){
		scanf("%d", &c[i]);
		c[i]--;
	}
	for (int i = v.size() - 1; i >= 0; i--){
		swap(c[v[i].first], c[v[i].second]);
	}
	bool flag = false;
	for (int i = 0; i < n; i++){
		if (c[i] != a[i]){
			if (flag){
				printf(" ");
			}
			printf("%d", i + 1);
			flag = true;
		}
	}
	puts("");
	return 0;
}
0