結果

問題 No.26 シャッフルゲーム
ユーザー dazydazy
提出日時 2016-09-08 17:29:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 2,807 ms
コンパイル使用メモリ 74,192 KB
実行使用メモリ 54,384 KB
最終ジャッジ日時 2024-04-27 17:58:57
合計ジャッジ時間 4,696 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
54,128 KB
testcase_01 AC 116 ms
53,680 KB
testcase_02 AC 137 ms
54,136 KB
testcase_03 AC 119 ms
53,924 KB
testcase_04 AC 122 ms
53,956 KB
testcase_05 AC 140 ms
54,136 KB
testcase_06 AC 134 ms
54,008 KB
testcase_07 AC 136 ms
54,128 KB
testcase_08 AC 146 ms
54,384 KB
testcase_09 AC 147 ms
54,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        if (N < 1||N > 3||M < 1||M > 200) System.exit(1);
        int P,Q;
        for (int i = 0; i < M; i++) {
            P = scan.nextInt();
            Q = scan.nextInt();
            if (P < 1||P > 3||Q < 1||Q > 3||P==Q) System.exit(1);
            if (P==N) N = Q;
            else if (Q==N) N = P;
        }
        System.out.println(N);
    }
}
0