結果

問題 No.429 CupShuffle
ユーザー Manuel1024Manuel1024
提出日時 2023-01-10 23:23:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 73,196 KB
実行使用メモリ 4,632 KB
最終ジャッジ日時 2023-08-23 10:26:51
合計ジャッジ時間 2,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 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,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 78 ms
4,552 KB
testcase_12 AC 74 ms
4,632 KB
testcase_13 AC 79 ms
4,592 KB
testcase_14 AC 80 ms
4,592 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n, k, x; cin >> n >> k >> x;
    vector<int> a(k), b(k);
    for(int i = 0; i < k; i++){
        if(i == x-1){
            char t1, t2; cin >> t1 >> t2;
        }else{
            cin >> a[i] >> b[i];
            a[i]--; b[i]--;
        }
    }
    vector<int> c(n);
    for(auto &it: c) cin >> it;

    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i+1;
    for(int i = 0; i < x-1; i++) swap(v[a[i]], v[b[i]]);
    for(int i = k-1; i >= x; i--) swap(c[a[i]], c[b[i]]);

    vector<int> ans;
    for(int i = 0; i < n; i++){
        if(v[i] != c[i]) ans.emplace_back(i+1);
    }
    cout << ans[0] << " " << ans[1] << endl;
    return 0;
}
0