結果

問題 No.26 シャッフルゲーム
ユーザー lrf141
提出日時 2016-12-01 14:06:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 644 bytes
コンパイル時間 2,959 ms
コンパイル使用メモリ 74,072 KB
実行使用メモリ 41,792 KB
最終ジャッジ日時 2024-11-27 15:43:51
合計ジャッジ時間 4,910 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class no26{
    public static void main(String... args){
        
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(),m = scan.nextInt(),p,q,tmp;
        int res[] = new int[3];
        res[n-1]++;

        for(int i = 0; i < m; i++){
            p = scan.nextInt();
            q = scan.nextInt();
            p--;
            q--;
            tmp = res[p];
            res[p] = res[q];
            res[q] = tmp;
        }

        for(int i = 0; i < 3; i++){
            if(res[i] == 1){
                System.out.println(i+1);
                break;
            }
        }
    }
}
0