結果

問題 No.26 シャッフルゲーム
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-11 04:45:31
言語 Java19
(openjdk 21)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 445 bytes
コンパイル時間 2,789 ms
コンパイル使用メモリ 71,608 KB
実行使用メモリ 56,000 KB
最終ジャッジ日時 2023-08-16 18:14:39
合計ジャッジ時間 4,879 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,616 KB
testcase_01 AC 123 ms
55,660 KB
testcase_02 AC 148 ms
55,768 KB
testcase_03 AC 134 ms
55,648 KB
testcase_04 AC 141 ms
55,520 KB
testcase_05 AC 148 ms
55,648 KB
testcase_06 AC 147 ms
55,476 KB
testcase_07 AC 139 ms
55,572 KB
testcase_08 AC 151 ms
56,000 KB
testcase_09 AC 156 ms
55,816 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