結果

問題 No.429 CupShuffle
ユーザー sugim48sugim48
提出日時 2016-10-02 22:29:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,343 bytes
コンパイル時間 1,012 ms
コンパイル使用メモリ 104,528 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-08-13 17:01:37
合計ジャッジ時間 2,380 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <list>
using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define pb push_back
 
int INF = INT_MAX / 10;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, M, j0; cin >> N >> M >> j0;
	j0--;
	vector<int> a(M), b(M);
	rep(j, M) {
		if (j == j0) {
			string s, t; cin >> s >> t;
		} else {
			cin >> a[j] >> b[j];
			a[j]--; b[j]--;
		}
	}
	vector<int> p(N);
	rep(i, N) p[i] = i + 1;
	rep(j, j0) swap(p[a[j]], p[b[j]]);
	vector<int> q(N);
	rep(i, N) cin >> q[i];
	for (int j = M - 1; j > j0; j--)
		swap(q[a[j]], q[b[j]]);
	vector<int> ans;
	rep(i, N) if (p[i] != q[i]) ans.pb(i);
	cout << ans[0] + 1 << ' ' << ans[1] + 1 << endl;
}
0