結果

問題 No.26 シャッフルゲーム
ユーザー takeya_okino
提出日時 2017-06-12 08:37:42
言語 Java
(openjdk 23)
結果
AC  
実行時間 174 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 74,020 KB
実行使用メモリ 54,444 KB
最終ジャッジ日時 2024-09-24 16:42:27
合計ジャッジ時間 4,244 ms
ジャッジサーバーID
(参考情報)
judge3 / 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();
    int[] arr = new int[3];
    arr[N - 1] = 1;
    for(int i = 0; i < M; i++) {
      int p = sc.nextInt() - 1;
      int q = sc.nextInt() - 1;
      int temp = arr[p];
      arr[p] = arr[q];
      arr[q] = temp;
    }
    int ans = 0;
    for(int i = 0; i < 3; i++) {
      if(arr[i] == 1) ans = i + 1;
    }
    System.out.println(ans);
  }
}
0