結果

問題 No.26 シャッフルゲーム
ユーザー kichirb3kichirb3
提出日時 2018-03-01 19:17:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 736 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 70,512 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 20:51:52
合計ジャッジ時間 1,193 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// No.26 シャッフルゲーム
// https://yukicoder.me/problems/no/26
//

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

void do_shuffle(vector<char> &cups, int M);


int main() {
    int N, M;
    cin >> N >> M;

    vector<char> cups(4, 'x');  // カップを0-3まで用意して全て'x'にする
    cups[N] = 'o';              // 最初の正解カップだけ'o'に

    do_shuffle(cups, M);        // カップをシャッフルする
    auto pos = find(cups.begin(), cups.end(), 'o');
    cout << pos - cups.begin() << endl;
}

void do_shuffle(vector<char> &cups, int M) {
    for (auto i = 0; i < M; ++i) {
        int p, q;
        cin >> p >> q;
        swap(cups[p], cups[q]);
    }
}
0