#include<bits/stdc++.h>
using namespace std;
vector<string>ans;
vector<char>a,b;
void add(int i,int j,int l){
if (i==0){
ans.push_back("UZMI");
}
else{
ans.push_back("STAVI");
}
if(j==0){
a.push_back('L');
}
else{
a.push_back('D');
}
if (l==0){
b.push_back('L');
}
else{
b.push_back('D');
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
vector<int>arr(n);
vector<int>brr=arr;
sort(brr.rbegin(),brr.rend());
for (int i = 0;i<n;++i){
cin>>arr[i];
}
stack<int>first,second;
int j =0;
bool lefthand=false,righthand=false;
for (int i = 0;i<n;++i){
if (second.empty()||second.top()<arr[i]){
add(0,0,0);
add(1,0,1);
second.push(arr[i]);
}
else{
add(0,0,0);
while(!second.empty()&&second.top()>arr[i]){
add(0,1,1);
add(1,1,0);
first.push(second.top());
second.pop();
}
add(1,0,1);
second.push(arr[i]);
while(!first.empty()){
add(0,0,0);
add(1,0,1);
second.push(first.top());
first.pop();
}
}
}
while(!second.empty()){
add(0,0,1);
add(1,0,0);
second.pop();
}
cout<<ans.size()<<endl;
for (int i = 0;i<ans.size();++i){
cout<<ans[i]<<" "<<a[i]<<" "<<b[i]<<endl;
}
return 0;}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:68:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for (int i = 0;i<ans.size();++i){
| ~^~~~~~~~~~~
Main.cpp:36:5: warning: unused variable 'j' [-Wunused-variable]
36 | int j =0;
| ^
Main.cpp:37:6: warning: unused variable 'lefthand' [-Wunused-variable]
37 | bool lefthand=false,righthand=false;
| ^~~~~~~~
Main.cpp:37:21: warning: unused variable 'righthand' [-Wunused-variable]
37 | bool lefthand=false,righthand=false;
| ^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
988 KB |
Output is correct |
2 |
Correct |
18 ms |
860 KB |
Output is correct |
3 |
Correct |
18 ms |
860 KB |
Output is correct |
4 |
Correct |
17 ms |
860 KB |
Output is correct |
5 |
Correct |
17 ms |
860 KB |
Output is correct |
6 |
Correct |
18 ms |
988 KB |
Output is correct |
7 |
Correct |
12 ms |
712 KB |
Output is correct |
8 |
Correct |
17 ms |
988 KB |
Output is correct |
9 |
Correct |
21 ms |
940 KB |
Output is correct |
10 |
Correct |
19 ms |
860 KB |
Output is correct |