結果

問題 No.26 シャッフルゲーム
ユーザー めうめう🎒めうめう🎒
提出日時 2016-05-09 21:19:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 179 ms / 5,000 ms
コード長 707 bytes
コンパイル時間 2,479 ms
コンパイル使用メモリ 75,256 KB
実行使用メモリ 42,496 KB
最終ジャッジ日時 2024-04-15 14:57:50
合計ジャッジ時間 4,655 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,296 KB
testcase_01 AC 137 ms
41,396 KB
testcase_02 AC 179 ms
42,496 KB
testcase_03 AC 145 ms
41,632 KB
testcase_04 AC 150 ms
41,804 KB
testcase_05 AC 165 ms
41,748 KB
testcase_06 AC 168 ms
41,912 KB
testcase_07 AC 148 ms
41,752 KB
testcase_08 AC 167 ms
42,044 KB
testcase_09 AC 169 ms
42,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;


public class Main {
	private int now;
	private int n;
	
	public void setNow(int now){
		this.now = now;
	}
	
	public void setN(int n){
		this.n = n;
	}
	
	public int getNow(){
		return this.now;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main();
		int now = sc.nextInt();
		m.setNow(now);
		int n = sc.nextInt();
		m.setN(n);
		int a,b;
		for(int i = 0;i < n;i++){
			a = sc.nextInt();
			b = sc.nextInt();
			if(a == m.getNow()){
				m.setNow(b);
			}else if(b == m.getNow()){
				m.setNow(a);
			}
		}
		System.out.println(m.getNow());
	}
}
0