Created
August 10, 2013 05:48
-
-
Save hhc0null/6199232 to your computer and use it in GitHub Desktop.
AOJ0011
This file contains hidden or 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
// AOJ0011 ACed | |
#include <algorithm> | |
#include <cstdio> | |
#include <cmath> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main(void) { | |
int w, n; | |
string str; | |
cin >> w; | |
cin >> n; | |
int v[w], a[n], b[n]; | |
for(int i = 0; i < w; i++) { | |
v[i] = i + 1; | |
} | |
for(int i = 0; i < n; i++) { | |
cin >> str; | |
unsigned int idx = str.find(",",0); | |
a[i] = atoi(str.substr(0,idx).c_str()); | |
b[i] = atoi(str.substr(idx+1).c_str()); | |
swap(v[a[i]-1],v[b[i]-1]); | |
} | |
for(int i = 0; i < w; i++) { | |
cout << v[i] << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment