Created
December 4, 2011 15:08
-
-
Save mojaie/1430404 to your computer and use it in GitHub Desktop.
AOJ:0011
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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