結果

問題 No.429 CupShuffle
ユーザー hiyokko2hiyokko2
提出日時 2017-08-16 10:09:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 145,320 KB
実行使用メモリ 5,112 KB
最終ジャッジ日時 2023-08-03 15:59:40
合計ジャッジ時間 2,736 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N, K, X;
int A[101010], B[101010];
int C[101010];
int k;
int ini[101010];
int fi[101010];

signed main()
{
    cin >> N >> K >> X;
    REP(i,K) {
        string tA, tB;
        cin >> tA >> tB;

        if (tA == "?" && tB == "?") {
            k = i;
            continue;
        }

        A[i] = stoi(tA);
        B[i] = stoi(tB);
    }
    REP(i,N) cin >> C[i+1];

    for (int i=1; i<=N; i++) ini[i] = i;
    REP(i,k) swap(ini[A[i]], ini[B[i]]);

    for (int i=K-1; i>k; i--) swap(C[A[i]], C[B[i]]);

    bool first = true;
    for (int i=1; i<=N; i++) {
        if (ini[i] != C[i]) {
            if (first) first = false;
            else cout << " ";
            cout << i;
        }
    }
    cout << endl;
}
0