AOJ 0011 Drawing Lots

AOJ 0010なんてなかった
リンク AOJ 0011 Drawing Lots

方針

あみだくじって、上から順に交換していけば結果がわかりますよね・・・
なので馬鹿正直に交換していきました。

ソース

import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int w, n;
    static int[] Amida;

    public static void main(String[] args) {
        while(read()){
            slove();
        }
    }
    static boolean read(){
        w = sc.nextInt();
        n = sc.nextInt();
        return true;
    }
    static void slove(){
        int temp;
        String[] input;
        Amida = new int[w+1];
        for(int k = 1; k <= w; k++){
            Amida[k] = k;
        }
        for(int i = 0; i < n; i++){
            input = sc.next().split(",");
            temp = Amida[Integer.parseInt(input[1])];
            Amida[Integer.parseInt(input[1])] = Amida[Integer.parseInt(input[0])];
            Amida[Integer.parseInt(input[0])] = temp;
        }
        for(int j = 1; j < Amida.length; j++){
            System.out.println(Amida[j]);
        }
    }
}