Skip to content

Instantly share code, notes, and snippets.

@hhc0null
Created August 10, 2013 05:48
Show Gist options
  • Save hhc0null/6199232 to your computer and use it in GitHub Desktop.
Save hhc0null/6199232 to your computer and use it in GitHub Desktop.
AOJ0011
// 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