include iostream include vector include string include set include map

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define mp make_pair
#define pb push_back
int n;
char* a;
vector<int> stpos;
void move1(int i, int j) {
a[j] = a[i];
a[i] = 0;
cout <<"M " <<i+1 <<" " <<j+1 <<endl;
}
int main(){
cin >>n;
a = new char[n];
int p;
int lateIdx = -1;
int r21 = 0;
int l3 = n - 1;
int tail1 = 0;
while(cin >>p && p != 0) { //TODO: LATE
if(p > 0) {
if(p == 3) {
for(int i = 0; i < 3; i++) a[l3-i] = 3;
stpos.pb(l3-2);
l3 -= 3;
} else if(p == 1) {
stpos.pb(r21);
a[r21++] = 1;
tail1++;
} else if(p == 2) {
bool mover21 = false;
if(tail1 & 1 == 1) { move1(r21 - 1, r21 + 1); r21--; mover21 = true; }
stpos.pb(r21);
a[r21++] = 2;
a[r21++] = 2;
r21 += mover21;
}
} else {
if(p == 3) {
}
}
}
return 0;
}