結果

問題 No.429 CupShuffle
ユーザー MayimgMayimg
提出日時 2019-01-17 00:06:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 174,344 KB
実行使用メモリ 5,588 KB
最終ジャッジ日時 2023-09-13 22:18:20
合計ジャッジ時間 3,447 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, x;
	cin >> n >> k >> x;
	vector<vector<int>> v(2, vector<int>(n));
	iota(v[0].begin(), v[0].end(), 1);
	vector<vector<pair<int, int>>> s(2);
	for(int i = 1; i <= k; i++) {
		if(i == x) {
			char c, d;
			cin >> c >> d;
			continue;
		}
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(i < x) s[0].emplace_back(a, b);
		if(i > x) s[1].emplace_back(a, b);
	}
	for(int i = 0; i < n; i++) {
		cin >> v[1][i];
	}
	reverse(s[1].begin(), s[1].end());
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < (int)s[i].size(); j++) {
			int a = s[i][j].first;
			int b = s[i][j].second;
			swap(v[i][a], v[i][b]);
		}
	}
	int p = -1, q = -1;
	for(int i = 0; i < n; i++) {
		if(v[0][i] != v[1][i]) {
			if(p < 0) p = i;
			else q = i;
		}
	}
	cout << p + 1 << " " << q + 1<< endl;
	return 0;	
}
0