結果

問題 No.26 シャッフルゲーム
ユーザー itok217
提出日時 2017-05-10 22:51:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 55,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-15 07:13:59
合計ジャッジ時間 915 ms
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main() {
    int n, m, p, q, t;
    cin >> n >> m;
    int c[3] = {};
    c[n - 1] = 1;
    while (m--) {
        cin >> p >> q;
        t = c[p - 1];
        c[p - 1] = c[q - 1];
        c[q - 1] = t;
    }
    int ans = -1;
    for (int i = 0; i < 3; i++) {
        if (c[i] == 1) {
            ans = i + 1;
            break;
        }
    }
    cout << ans << endl;
}
0