結果

問題 No.429 CupShuffle
ユーザー finefine
提出日時 2016-10-02 23:22:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 172,164 KB
実行使用メモリ 4,548 KB
最終ジャッジ日時 2023-08-13 17:26:32
合計ジャッジ時間 2,428 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 28 ms
4,404 KB
testcase_12 AC 26 ms
4,496 KB
testcase_13 AC 27 ms
4,548 KB
testcase_14 AC 26 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, x;
    cin >> n >> k >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++) a[i] = i + 1;
    for (int i = 0; i < x - 1; i++) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        swap(a[p], a[q]);
    }
    char ax, bx;
    cin >> ax >> bx;
    vector<P> memo;
    for (int i = x; i < k; i++) {
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        memo.emplace_back(p, q);
    }
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    for (auto i = memo.rbegin(), e = memo.rend(); i != e; ++i) {
        swap(b[i->first], b[i->second]);
    }
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) ans.emplace_back(i + 1);
    }
    cout << ans[0] << " " << ans[1] << "\n";
    return 0;
}
0