Skip to content

Instantly share code, notes, and snippets.

@mojaie
Created December 4, 2011 15:08
Show Gist options
  • Save mojaie/1430404 to your computer and use it in GitHub Desktop.
Save mojaie/1430404 to your computer and use it in GitHub Desktop.
AOJ:0011
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int w = scn.nextInt();
int n = scn.nextInt();
int[] ls = new int[w + 1];
for (int i = 1; i <= w; i++) {
ls[i] = i;
}
for (int i = 0; i < n; i++) {
String str = scn.next();
String[] arr = str.split(",");
int a = Integer.parseInt(arr[0]);
int b = Integer.parseInt(arr[1]);
int buf = ls[a];
ls[a] = ls[b];
ls[b] = buf;
}
for (int i = 1; i <= w; i++) {
System.out.println(ls[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment