結果
問題 | No.26 シャッフルゲーム |
ユーザー |
|
提出日時 | 2022-06-20 10:38:13 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 169 ms / 5,000 ms |
コード長 | 843 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 74,172 KB |
実行使用メモリ | 41,956 KB |
最終ジャッジ日時 | 2024-10-12 21:25:19 |
合計ジャッジ時間 | 4,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); //〇印がついているカップの位置番号 int N = sc.nextInt(); //カップを入れ替える回数 int M = sc.nextInt(); //カップ int[] cup = new int[3]; //カップに〇をつける cup[N-1] = 1; //M回カップを入れ替える for(int i = 0; i < M; i++) { //入れ替えるカップ int c1 = sc.nextInt(); int c2 = sc.nextInt(); //カップの入れ替え作業 int c = cup[c1-1]; cup[c1-1] = cup[c2-1]; cup[c2-1] = c; } //〇印がついているカップを探す int ans = -1; for(int i = 0; i < cup.length; i++) { if(cup[i] == 1) { ans = i + 1; } } System.out.println(ans); } }