結果

問題 No.429 CupShuffle
ユーザー hirokazu1020
提出日時 2016-10-29 03:51:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 99,292 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 07:08:09
合計ジャッジ時間 1,936 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:9: warning: ‘pb’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |         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