結果

問題 No.429 CupShuffle
ユーザー hirokazu1020hirokazu1020
提出日時 2016-10-29 03:51:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 98,144 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 22:12:27
合計ジャッジ時間 1,986 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 27 ms
4,380 KB
testcase_12 AC 26 ms
4,376 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:2: warning: ‘pb’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (pa > pb)swap(pa, pb);
  ^~

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())







int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	vector<int> s, t;
	int n,k,x;
	cin >> n >> k >> x;
	rep(i, n)s.push_back(i + 1);
	rep(i,k) {
		int a, b;
		if (i+1==x) {
			char ch;
			cin >> ch >> ch;
			t = s;
			continue;
		}
		cin >> a >> b;
		a--; b--;
		swap(s[a], s[b]);
	}
	int pa=-1, pb;
	rep(i,n) {
		int c;
		cin >> c;
		if (c != s[i]) {
			if (pa == -1)pa = find(all(t), c) - t.begin();
			else pb = find(all(t), c) - t.begin();
		}
	}
	if (pa > pb)swap(pa, pb);
	cout << pa + 1 << ' ' << pb + 1 << endl;

	return 0;
}
0