結果

問題 No.429 CupShuffle
ユーザー ふーらくたるふーらくたる
提出日時 2016-10-02 23:15:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 56,564 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 10:05:15
合計ジャッジ時間 1,283 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 64 ms
5,376 KB
testcase_12 AC 61 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

const int MAX_N = 100010;

int c[MAX_N];
int r1[MAX_N], r2[MAX_N];

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

    for (int i = 0; i < n; i++) {
        r1[i] = i;
    }

    for (int i = 0; i < k; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        if (i == x - 1) {
            for (int j = 0; j < n; j++) {
                r2[j] = r1[j];
            }
            continue;
        }
        int a = stoi(s1),
            b = stoi(s2);
        swap(r1[a - 1], r1[b - 1]);
    }

    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }

    int w1, w2;
    for (int i = 0; i < n; i++) {
        if (r1[i] != c[i]) {
            w1 = min(r2[r1[i]], r2[c[i]]) + 1;
            w2 = max(r2[r1[i]], r2[c[i]]) + 1;
            cout << w1 << " " << w2 << endl;
            break;
        }
    }

    return 0;
}
0