結果

問題 No.26 シャッフルゲーム
ユーザー AoiroFukurou
提出日時 2016-05-24 11:27:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 583 bytes
コンパイル時間 3,263 ms
コンパイル使用メモリ 74,904 KB
実行使用メモリ 54,312 KB
最終ジャッジ日時 2024-10-07 03:46:59
合計ジャッジ時間 5,539 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class No_026 {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int[] cup = new int[4];

	cup[N] = 1;
	for(int i = 0; i < M; i++){
		int[] shuf = new int[2];
		shuf[0] = sc.nextInt();
		shuf[1] = sc.nextInt();
		if(cup[shuf[0]] == 1){
			cup[shuf[0]] = 0;
			cup[shuf[1]] =1;
		}else if(cup[shuf[1]] == 1){
			cup[shuf[1]] = 0;
			cup[shuf[0]] = 1;
		}
	}
	for(int i = 1; i < 4; i ++){
		if(cup[i] == 1){
			System.out.println(i);
			break;
		}
	}
}
}
0