結果

問題 No.26 シャッフルゲーム
ユーザー kano_town
提出日時 2014-11-21 17:26:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 533 bytes
コンパイル時間 4,196 ms
コンパイル使用メモリ 77,440 KB
実行使用メモリ 43,004 KB
最終ジャッジ日時 2025-01-02 20:01:16
合計ジャッジ時間 5,478 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder26 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int P, Q;
		boolean[] cup = {false, false, false};
		cup[N - 1] = true;

		for (int i = 0; i < M; i++) {
			P = sc.nextInt();
			Q = sc.nextInt();
			cup[P - 1] ^= cup[Q - 1];
			cup[Q - 1] ^= cup[P - 1];
			cup[P - 1] ^= cup[Q - 1];
		}
		
		for (int i = 0; i < 3; i++)
			if (cup[i])
				System.out.println(i + 1);

	}
}
0