結果

問題 No.26 シャッフルゲーム
ユーザー kuramukuramu
提出日時 2016-01-20 11:54:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 786 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 74,620 KB
実行使用メモリ 53,588 KB
最終ジャッジ日時 2023-10-21 13:29:18
合計ジャッジ時間 3,382 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,572 KB
testcase_01 AC 53 ms
52,456 KB
testcase_02 AC 54 ms
53,572 KB
testcase_03 AC 54 ms
53,588 KB
testcase_04 AC 55 ms
53,572 KB
testcase_05 AC 56 ms
53,572 KB
testcase_06 AC 54 ms
53,572 KB
testcase_07 AC 54 ms
53,584 KB
testcase_08 AC 55 ms
53,572 KB
testcase_09 AC 56 ms
52,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {

	public static void main(String[] args) {
	      BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
	      try {
		      int ans = Integer.parseInt(stdReader.readLine());
		      int M = Integer.parseInt(stdReader.readLine());
		      
		      for(int i=0;i<M;i++){
		    	  String temps[] = stdReader.readLine().split(" ");
		    	  if(ans == Integer.parseInt(temps[0])){
		    		  ans = Integer.parseInt(temps[1]);
		    	  }else if(ans == Integer.parseInt(temps[1])){
		    		  ans = Integer.parseInt(temps[0]);
		    	  }
		      }
		      System.out.println(ans);
	    	  } catch (IOException e) {
			e.printStackTrace();
	      }
	}	
}
0