結果

問題 No.26 シャッフルゲーム
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-07 21:06:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 551 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 71,888 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-09-17 15:58:14
合計ジャッジ時間 4,146 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,760 KB
testcase_01 AC 124 ms
56,328 KB
testcase_02 AC 148 ms
56,092 KB
testcase_03 AC 134 ms
56,140 KB
testcase_04 AC 139 ms
53,996 KB
testcase_05 AC 152 ms
55,916 KB
testcase_06 AC 149 ms
55,716 KB
testcase_07 AC 141 ms
55,876 KB
testcase_08 AC 148 ms
55,964 KB
testcase_09 AC 171 ms
56,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int m = koko.nextInt();
        int n = koko.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        for(int i=0; i<n; i++){
            p[i] = koko.nextInt();
            q[i] = koko.nextInt();
            if(m==p[i]){
                m=q[i];
            }else if(m==q[i]){
                m=p[i];
            }
        }
        System.out.println(m);
        
    }
}
0