結果

問題 No.26 シャッフルゲーム
ユーザー jimanojimano
提出日時 2018-01-13 15:07:18
言語 Java19
(openjdk 21)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 3,489 ms
コンパイル使用メモリ 72,492 KB
実行使用メモリ 56,152 KB
最終ジャッジ日時 2023-08-25 15:37:03
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
53,808 KB
testcase_01 AC 122 ms
55,436 KB
testcase_02 AC 159 ms
55,924 KB
testcase_03 AC 134 ms
55,944 KB
testcase_04 AC 137 ms
55,624 KB
testcase_05 AC 147 ms
55,752 KB
testcase_06 AC 147 ms
56,152 KB
testcase_07 AC 136 ms
55,780 KB
testcase_08 AC 144 ms
55,996 KB
testcase_09 AC 155 ms
55,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;

import java.util.Scanner;

public class No0026 {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			boolean[] cup = new boolean[3];
			cup[N - 1] = true;// 最初に○印が付いているカップ

			for (int i = 0; i < M; i++) {
				int p = sc.nextInt();
				int q = sc.nextInt();
				exchange(cup, p, q);
			}

			System.out.println(cnt(cup));
		}
	}

	static void exchange(boolean[] cup, int p, int q) {
		boolean boo = cup[p - 1];
		cup[p - 1] = cup[q - 1];
		cup[q - 1] = boo;
	}

	static int cnt(boolean[] cup) {
		int cnt;
		for (cnt = 0; cnt < cup.length; cnt++) {
			if (cup[cnt])
				break;
		}
		return cnt + 1;
	}
}
0