結果

問題 No.26 シャッフルゲーム
ユーザー DaiKi117DaiKi117
提出日時 2019-09-30 14:50:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 182 ms / 5,000 ms
コード長 720 bytes
コンパイル時間 2,703 ms
コンパイル使用メモリ 78,536 KB
実行使用メモリ 54,376 KB
最終ジャッジ日時 2024-04-14 08:03:58
合計ジャッジ時間 5,159 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,196 KB
testcase_01 AC 134 ms
54,244 KB
testcase_02 AC 182 ms
54,348 KB
testcase_03 AC 150 ms
54,344 KB
testcase_04 AC 153 ms
54,288 KB
testcase_05 AC 161 ms
54,376 KB
testcase_06 AC 158 ms
54,124 KB
testcase_07 AC 151 ms
54,012 KB
testcase_08 AC 167 ms
54,276 KB
testcase_09 AC 176 ms
54,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    boolean[] cup = {false, false, false};
    int first = scanner.nextInt() - 1;
    int shuffle = scanner.nextInt();
    int l = 0;
    int r = 0;
    cup[first] = true;
    for(int i = 0; i < shuffle; i++){
      l = scanner.nextInt() - 1;
      r = scanner.nextInt() - 1;
      if(first == l){
        cup[first] = false;
        cup[r] = true;
        first = r;
      }else if(first == r){
        cup[first] = false;
        cup[l] = true;
        first = l;
      }
    }
    for(int i = 0; i < 3; i++){
      if(cup[i] == true){
        System.out.println(i + 1);
      }
    }
  }
}
0