結果

問題 No.429 CupShuffle
ユーザー imulanimulan
提出日時 2016-10-03 00:04:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 1,604 ms
コンパイル使用メモリ 168,712 KB
実行使用メモリ 4,724 KB
最終ジャッジ日時 2023-08-13 18:23:13
合計ジャッジ時間 2,575 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 27 ms
4,552 KB
testcase_12 AC 25 ms
4,724 KB
testcase_13 AC 26 ms
4,688 KB
testcase_14 AC 27 ms
4,600 KB
testcase_15 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,k,x;
    scanf(" %d %d %d", &n, &k, &x);
    --x;

    vector<int> a(k),b(k),c(n);
    rep(i,k)
    {
        if(i!=x) scanf(" %d %d", &a[i], &b[i]);
        else
        {
            char aa,bb;
            scanf(" %c %c", &aa, &bb);
            a[i]=b[i]=0;
        }
        --a[i];
        --b[i];
    }
    rep(i,n) scanf(" %d", &c[i]);

    vector<int> start(n);
    rep(i,n) start[i]=i+1;

    rep(i,x) swap(start[a[i]],start[b[i]]);
    for(int i=k-1; i>x; --i) swap(c[a[i]],c[b[i]]);

    vector<int> ans;
    rep(i,n)
    {
        if(start[i]!=c[i]) ans.pb(i+1);
    }

    printf("%d %d\n", ans[0], ans[1]);
    return 0;
}
0