結果

問題 No.429 CupShuffle
ユーザー startcppstartcpp
提出日時 2016-01-06 16:28:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 64,504 KB
実行使用メモリ 5,252 KB
最終ジャッジ日時 2023-10-19 16:09:48
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//想定WA解法(x回目の交換だけ飛ばして行い、配列Cとのdiffを取る)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n, k, x;
int a[100001], b[100001];
int c[100001];
int d[100001];

int main()
{
	int i;
	cin >> n >> k >> x;
	for( i = 1; i <= k; i++ ){
		if( i == x ){
			string yuki, coder;
			cin >> yuki >> coder;
		}
		else{
			cin >> a[i] >> b[i];
		}
	}
	for( i = 1; i <= n; i++ ){
		cin >> c[i];
	}
	
	for( i = 1; i <= n; i++ ){
		d[i] = i;
	}
	
	for( i = 1; i <= k; i++ ){
		if( i != x ){
			swap(d[a[i]], d[b[i]]);
		}
	}
	
	vector<int> out;
	for( i = 1; i <= n; i++ ){
		if( c[i] != d[i] ){
			out.push_back(i);
		}
	}
	cout << out[0] << " " << out[1] << endl;
	return 0;
}
0