Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created February 9, 2015 13:32
Show Gist options
  • Save theoremoon/faebb319ea0ddd932a0d to your computer and use it in GitHub Desktop.
Save theoremoon/faebb319ea0ddd932a0d to your computer and use it in GitHub Desktop.
/*
* AOJ 10033
* AC
*/
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main() {
stack<char> xs[128];
string s;
cin.ignore(10, '\n');
while (true) {
cin >> s;
if (s == "quit") break;
if (s == "push") {
int to; char v; cin >> to >> v;
xs[to].push(v);
} else if (s == "pop") {
int from; cin >> from;
cout << xs[from].top() << endl;
xs[from].pop();
} else if (s == "move") {
int from, to; cin >> from >> to;
xs[to].push(xs[from].top());
xs[from].pop();
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment