# include <bits/stdc++.h>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define deb(x) cerr << #x << " = " << x << endl;
# define pll pair <ll, ll>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = 2e5 + 25;
const ll inf = 2e9 + 0;
const ll mod = 1e9 + 123;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
using namespace std;
int n;
void ma1n (/* SABR */)
{
cin >> n;
multiset <int> qw;
queue <int> q1, q2;
for (int i = 1, x; i <= n; ++i)
{
cin >> x;
q1.push(x);
qw.insert(x);
}
queue <int> cur;
vector <string> ans;
while (!q1.empty())
{
int need = *qw.rbegin();
while (!q1.empty() && q1.front() != need)
{
string s = "UZMI L L";
ans.pb(s);
s = "STAVI L D";
ans.pb(s);
cur.push(q1.front());
q1.pop();
}
string s = "UZMI D L";
ans.pb(s);
q1.pop();
while (!cur.empty())
{
s = "UZMI L D";
ans.pb(s);
s = "STAVI L L";
ans.pb(s);
q1.push(cur.front());
cur.pop();
}
s = "STAVI D D";
ans.pb(s);
qw.erase(qw.find(need));
}
cout << sz(ans) << nl;
for (string x : ans) cout << x << nl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
int ttt = 1;
// cin >> ttt;
for (int test = 1; test <= ttt; ++test)
{
// cout << "Case " << test << ":" << ' ';
ma1n();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Wrong configuration |
2 |
Incorrect |
1 ms |
696 KB |
Wrong configuration |
3 |
Incorrect |
1 ms |
724 KB |
Wrong configuration |
4 |
Incorrect |
3 ms |
956 KB |
Wrong configuration |
5 |
Incorrect |
2 ms |
980 KB |
Wrong configuration |
6 |
Incorrect |
1 ms |
724 KB |
Wrong configuration |
7 |
Incorrect |
1 ms |
340 KB |
Wrong configuration |
8 |
Incorrect |
2 ms |
980 KB |
Wrong configuration |
9 |
Incorrect |
2 ms |
956 KB |
Wrong configuration |
10 |
Incorrect |
1 ms |
772 KB |
Wrong configuration |