intexecuteCmd(int point, string cmd){ char commond = cmd[0]; auto iter = arr.find(point);
string str; int value; if (commond == 'U' || commond == 'D') { for (int i = 2; i < cmd.size(); i++) { str += cmd[i]; } value = stoi(str); }
if (commond == 'U') { for (int i = 0; i < value; i++) { iter--; } } if (commond == 'D') { for (int i = 0; i < value; i++) { iter++; } } if (commond == 'C') { deletedData.push(*iter); iter = arr.erase(iter);
if (iter == arr.end()) { iter--; } } if (commond == 'Z') { if (!deletedData.empty()) { int value = deletedData.top(); deletedData.pop();
arr.insert(value); } }
return *iter; }
voidinsertNumber(int n){ for (int i = 0; i < n; i++) { arr.insert(i); } }
voidscanSet(){ for (auto iter = arr.begin(); iter != arr.end(); iter++) { int index = *iter;
check[index] = true; } }
string solution(int n, int k, vector<string> cmd){ string answer = ""; insertNumber(n);
int point = k; for (int i = 0; i < cmd.size(); i++) { point = executeCmd(point, cmd[i]); } scanSet();
for (int i = 0; i < n; i++) { if (check[i]) { answer += 'O'; } else { answer += 'X'; } }