結果

問題 No.26 シャッフルゲーム
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-09 22:10:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 901 bytes
コンパイル時間 3,349 ms
コンパイル使用メモリ 73,800 KB
実行使用メモリ 37,024 KB
最終ジャッジ日時 2024-04-28 14:27:26
合計ジャッジ時間 3,993 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
36,452 KB
testcase_01 AC 43 ms
36,856 KB
testcase_02 AC 48 ms
36,840 KB
testcase_03 AC 44 ms
36,820 KB
testcase_04 AC 45 ms
36,844 KB
testcase_05 AC 47 ms
36,448 KB
testcase_06 AC 48 ms
36,632 KB
testcase_07 AC 46 ms
36,440 KB
testcase_08 AC 47 ms
36,812 KB
testcase_09 AC 50 ms
37,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No26{
	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int cupNumAns = Integer.parseInt(br.readLine());
			int changeTimes = Integer.parseInt(br.readLine());
			System.out.println(changeCup(br, cupNumAns, changeTimes));
		}
		catch(IOException e){
			e.getStackTrace();
		}
		catch(NumberFormatException e){
			e.getStackTrace();
		}
	}
	
	public static int changeCup(BufferedReader br, int n, int m) throws IOException, NumberFormatException{
		for(int i=0; i < m; i++){
			String[] str = br.readLine().split(" ");
			int[] cupNum = new int[2];
			for(int j=0; j < 2; j++)
				cupNum[j] = Integer.parseInt(str[j]);
			if(n == cupNum[0]) n =cupNum[1];
			else if(n == cupNum[1]) n = cupNum[0];
		}
		return n;
	}
}
0