#include <iostream>
#include <stack>
#include <vector>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> target(n);
for (int i = 0; i < n; ++i) {
cin >> target[i];
}
stack<int> s;
string operations;
int current = 1;
for (int i = 0; i < n; ) {
if (!s.empty() && s.top() == target[i]) {
s.pop();
operations += 'B';
++i;
} else {
if (current > n) {
break;
}
s.push(current);
operations += 'A';
++current;
}
}
cout << operations << endl;
return 0;
}
全部回复 共 0 条
还没有人回复。往下写第一条。
发表回复
登录后即可回复本帖,与出题人和同学一起讨论。
登录