#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n], d[n];
for (int i = 0; i < n; i ++)
cin >> d[i], a[i] = d[i];
sort(a, a + n);
int cur = n - 1;
int done = 0;
vector<pair<string, pair<char, char>>> vec;
while (cur >= 0){
int placed = 0;
vector<int> tmp;
bool taken = 0;
for (int i = 0; i <= cur; i ++){
if (d[i] == a[cur] and !taken){
taken = 1;
vec.push_back({"UZMI", {'L', 'L'}});
}
else{
vec.push_back({"UZMI", {'R', 'L'}});
vec.push_back({"STAVI", {'R', 'R'}});
tmp.push_back(d[i]);
placed++;
}
}
vec.push_back({"STAVI", {'L', 'L'}});
while (placed){
placed--;
vec.push_back({"UZMI", {'R', 'R'}});
vec.push_back({"STAVI", {'R', 'L'}});
}
d[cur] = a[cur];
for (int i = 0; i < cur; i ++)
d[i] = tmp[i];
cur--;
}
for (int i = 0; i < n; i ++)
cout << d[i] << " ";
cout << endl;
cout << vec.size() << endl;
for (auto [s, P] : vec){
auto [x, y] = P;
cout << s << " " << x << " " << y << endl;
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:14:9: warning: unused variable 'done' [-Wunused-variable]
14 | int done = 0;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
1620 KB |
Token "1" doesn't correspond to pattern "(UZMI|STAVI)" |
2 |
Incorrect |
19 ms |
1620 KB |
Token "2" doesn't correspond to pattern "(UZMI|STAVI)" |
3 |
Incorrect |
20 ms |
1624 KB |
Token "5" doesn't correspond to pattern "(UZMI|STAVI)" |
4 |
Incorrect |
21 ms |
1624 KB |
Token "6" doesn't correspond to pattern "(UZMI|STAVI)" |
5 |
Incorrect |
21 ms |
1620 KB |
Token "54" doesn't correspond to pattern "(UZMI|STAVI)" |
6 |
Incorrect |
22 ms |
1624 KB |
Token "4" doesn't correspond to pattern "(UZMI|STAVI)" |
7 |
Incorrect |
21 ms |
1624 KB |
Token "1" doesn't correspond to pattern "(UZMI|STAVI)" |
8 |
Incorrect |
26 ms |
1624 KB |
Token "7" doesn't correspond to pattern "(UZMI|STAVI)" |
9 |
Incorrect |
20 ms |
1624 KB |
Token "8" doesn't correspond to pattern "(UZMI|STAVI)" |
10 |
Incorrect |
20 ms |
1620 KB |
Token "2" doesn't correspond to pattern "(UZMI|STAVI)" |