結果

問題 No.429 CupShuffle
ユーザー mamekinmamekin
提出日時 2016-10-05 10:16:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,166 bytes
コンパイル時間 865 ms
コンパイル使用メモリ 105,336 KB
実行使用メモリ 4,668 KB
最終ジャッジ日時 2023-08-13 23:11:44
合計ジャッジ時間 2,141 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, k, x;
    cin >> n >> k >> x;
    -- x;

    vector<int> a(k), b(k);
    for(int i=0; i<k; ++i){
        if(i == x){
            char c;
            cin >> c >> c;
            a[i] = b[i] = -1;
        }
        else{
            cin >> a[i] >> b[i];
            -- a[i];
            -- b[i];
        }
    }

    vector<int> v(n), c(n);
    for(int i=0; i<n; ++i){
        v[i] = i + 1;
        cin >> c[i];
    }

    for(int i=0; i<x; ++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.push_back(i + 1);
    }
    cout << ans[0] << ' ' << ans[1] << endl;

    return 0;
}
0