結果

問題 No.429 CupShuffle
ユーザー treeonetreeone
提出日時 2016-10-02 22:41:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 148,312 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2023-08-13 17:09:54
合計ジャッジ時間 2,471 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,388 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 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,376 KB
testcase_11 AC 81 ms
6,144 KB
testcase_12 AC 77 ms
6,200 KB
testcase_13 AC 81 ms
6,400 KB
testcase_14 AC 81 ms
6,200 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    int n, k, x;
    cin >> n >> k >> x;
    vector<int> d(n), pa(x - 1), pb(x - 1), aa(k - x), ab(k - x), c(n);
    rep(i, 0, n) d[i] = i;
    rep(i, 0, x - 1){
        cin >> pa[i] >> pb[i];
        pa[i]--; pb[i]--;
    }
    char s;
    cin >> s >> s;
    rep(i, 0, k - x){
        cin >> aa[i] >> ab[i];
        aa[i]--; ab[i]--;
    }
    rep(i, 0, n){
        cin >> c[i];
        c[i]--;
    }
    rep(i, 0, x - 1){
        swap(d[pa[i]], d[pb[i]]);
    }
    repb(i, k - x - 1, 0){
        swap(c[aa[i]], c[ab[i]]);
    }
    vector<int> ans;
    rep(i, 0, n){
        if(d[i] != c[i]){
            ans.push_back(i);
        }
    }
    cout << ans[0] + 1 << ' ' << ans[1] + 1 << endl;
}
0