結果

問題 No.26 シャッフルゲーム
ユーザー SagTokiSagToki
提出日時 2018-05-09 15:58:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 975 bytes
コンパイル時間 4,582 ms
コンパイル使用メモリ 72,500 KB
実行使用メモリ 56,252 KB
最終ジャッジ日時 2023-09-10 11:24:20
合計ジャッジ時間 5,794 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
55,792 KB
testcase_01 AC 122 ms
55,696 KB
testcase_02 AC 159 ms
56,252 KB
testcase_03 AC 136 ms
55,780 KB
testcase_04 AC 139 ms
55,752 KB
testcase_05 AC 145 ms
55,712 KB
testcase_06 AC 157 ms
55,836 KB
testcase_07 AC 138 ms
55,848 KB
testcase_08 AC 148 ms
55,920 KB
testcase_09 AC 157 ms
56,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class ShuffleGame {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        try{
             int Initial = scanner.nextInt();   //●の初期位置
             int RepetitionNumber = scanner.nextInt();  //試行回数
             
             for(int i = 0 ; i < RepetitionNumber ; i++){
                 int P = scanner.nextInt(); //Pを代入
                 int Q = scanner.nextInt(); //Qを代入
                 
                 if(P == Initial){
                     Initial = Q;
                 }else if(Q == Initial){
                     Initial = P;
                 }
             }
             
             System.out.println(Initial);
             
        }catch(InputMismatchException e){
            System.out.println("数値を入れてください。");
        }catch(Exception EE){
            System.out.println("想定外のエラーです。");
        }
    }   
}
0