結果

問題 No.429 CupShuffle
ユーザー sggkshiosggkshio
提出日時 2016-12-25 23:26:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,100 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 80,500 KB
実行使用メモリ 4,600 KB
最終ジャッジ日時 2023-08-21 09:02:37
合計ジャッジ時間 2,252 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,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 80 ms
4,584 KB
testcase_12 AC 75 ms
4,528 KB
testcase_13 AC 80 ms
4,592 KB
testcase_14 AC 80 ms
4,600 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {
	
	int n, k, x;
	cin >> n >> k >> x;
	vector<int>a, b, c;
	x--;
	for (int i = 0; i < n; i++) {
		int I = i + 1;
		a.push_back(I);
		b.push_back(I);
		
		//cout << a.size()<< b[i];
	}
	for (int i = 0; i < k; i++) {
		int w, h;
		char rr, rrr;
		if (i != x) { cin >> w >> h; w--, h--; }
		else cin >> rr >> rrr;
		if (i == x) { b = a;}
		if (i < x) {
			swap(a[w], a[h]);
		}
		else if (i > x) {
			swap(b[w], b[h]);
		}
	}
	for (int i = 0; i < n; i++) {
		int r; cin >> r;
		c.push_back(r);
		//cout << c[i];
	}
	vector<int>t;
	for (int i = 0; i < n; i++) {
		//cout << b[i] << c[i] << endl;;
		if (b[i] != c[i]) {
			for (int j = 0; j < n; j++) {
				if(a[j]==b[i]||a[j]==c[i])t.push_back(j);
			}
		}
		if (t.size())break;
	}
	cout << t[0]+1 << " " << t[1]+1 << endl;


	return 0;


}


0