結果

問題 No.26 シャッフルゲーム
ユーザー kohaku_kohaku
提出日時 2016-11-11 04:45:31
言語 Java
(openjdk 23)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 445 bytes
コンパイル時間 1,764 ms
コンパイル使用メモリ 74,064 KB
実行使用メモリ 43,608 KB
最終ジャッジ日時 2024-11-25 07:42:10
合計ジャッジ時間 3,805 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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