#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e5;
int h[2]={-1,-1};
vector<int> st[2];
vector<string> ans;
void take(bool hand,bool shelf)
{
h[hand]=st[shelf].back();
st[shelf].pop_back();
ans.push_back((string)"UZMI "+(hand ? "R":"L")+" "+(shelf ? "R":"L"));
return;
}
void put(bool hand,bool shelf)
{
st[shelf].push_back(h[hand]);
h[hand]=-1;
ans.push_back((string)"STAVI "+(hand ? "R":"L")+" "+(shelf ? "R":"L"));
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
st[0].resize(n);
for(int i=1;i<=n;i++)
cin>>st[0][n-i];
while(!st[0].empty())
{
take(0,0);
put(0,1);
}
for(int i=0;i<n;i++)
{
take(0,1);
while(!st[1].empty())
{
if(st[1].back()>h[0])
{
put(0,0);
take(0,1);
}
else
{
take(1,1);
put(1,0);
}
}
while(st[0].size()>i)
{
take(1,0);
put(1,1);
}
put(0,0);
}
cout<<ans.size()<<"\n";
for(auto v:ans)
cout<<v<<"\n";
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:54:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
54 | while(st[0].size()>i)
| ~~~~~~~~~~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
2 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
3 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
4 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
5 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
6 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
7 |
Incorrect |
4 ms |
1356 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
8 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
9 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |
10 |
Incorrect |
4 ms |
1484 KB |
Token "R" doesn't correspond to pattern "(L|D)" |