結果

問題 No.26 シャッフルゲーム
ユーザー ちよちゃん
提出日時 2016-06-04 13:29:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 1,334 bytes
コンパイル時間 4,343 ms
コンパイル使用メモリ 74,772 KB
実行使用メモリ 54,412 KB
最終ジャッジ日時 2024-10-08 07:48:46
合計ジャッジ時間 6,410 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class Yuki26 {
    
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	// cup
    	int[] a = new int[3];
    	
    	a[sc.nextInt()-1] = 1;
    	//入れ替える回数
    	int m = sc.nextInt();
    	
    	for (int i=0; i<m; i++) {
    		int b = sc.nextInt()-1;
    		int c = sc.nextInt()-1;
    		int d = a[b];
            
    		a[b] = a[c];
    		a[c] = d;	
    	}
    	
    	sc.close();
    	
    	for (int i =0; i<3; i++) {
    		if(a[i] == 1){
    			System.out.println(i+1);
    		}
    	}
    	
        	/*
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int changeCount = scan.nextInt();

        int changeCupArray[][] = new int [changeCount][2];
        
        for (int i = 0; i < changeCount;i++) {
            for(int j = 0; j < 2; j++) {
                changeCupArray[i][j] = scan.nextInt();
            }
        }
        scan.close();		
        
        int pastValue = num;
        for (int i = 0; i < changeCount;i++) {
            for(int j = 0; j < 2; j++) {
                if(changeCupArray[i][j] == pastValue ){
                    pastValue = changeCupArray[i][j];
                }
            }
        }
        System.out.println(pastValue);
        */
    }
}
0