結果

問題 No.26 シャッフルゲーム
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-11 04:45:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 445 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 74,672 KB
実行使用メモリ 41,904 KB
最終ジャッジ日時 2024-05-04 01:52:50
合計ジャッジ時間 3,673 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
41,060 KB
testcase_01 AC 111 ms
40,956 KB
testcase_02 AC 139 ms
41,904 KB
testcase_03 AC 130 ms
41,296 KB
testcase_04 AC 131 ms
41,196 KB
testcase_05 AC 143 ms
41,336 KB
testcase_06 AC 126 ms
41,408 KB
testcase_07 AC 128 ms
41,200 KB
testcase_08 AC 132 ms
41,676 KB
testcase_09 AC 143 ms
41,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        for(int i=0; i<M; i++){
            int P = sc.nextInt();
            int Q = sc.nextInt();
            if(N==P){
                N=Q;
            }else if(N==Q){
                N=P;
            }
        }
        System.out.println(N);
    }
}
0