結果

問題 No.26 シャッフルゲーム
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-12 08:37:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 1,965 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 57,984 KB
最終ジャッジ日時 2023-10-24 21:30:22
合計ジャッジ時間 4,232 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,664 KB
testcase_01 AC 123 ms
57,648 KB
testcase_02 AC 166 ms
57,580 KB
testcase_03 AC 134 ms
57,584 KB
testcase_04 AC 140 ms
57,760 KB
testcase_05 AC 150 ms
57,680 KB
testcase_06 AC 151 ms
57,816 KB
testcase_07 AC 141 ms
57,680 KB
testcase_08 AC 151 ms
57,984 KB
testcase_09 AC 169 ms
57,724 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();
    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