#include <bits/stdc++.h>
using namespace std;
#ifndef _LOCAL
//#pragma GCC optimize("O3,Ofast")
#else
#pragma GCC optimize("O0")
#endif
template<typename t> inline void umin(t &a, const t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, const t b) {a = max(a, b);}
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef int8_t byte;
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
#define ft first
#define sd second
#define len(f) int((f).size())
#define bnd(f) (f).begin(), (f).end()
#define _ <<' '<<
const int inf = 1e9 + 5;
const ll inf64 = 4e18 + 5;
const int md = 998244353;
namespace MD {
void add(int &a, const int b) {if((a += b) >= md) a -= md;}
void sub(int &a, const int b) {if((a -= b) < 0) a += md;}
int prod(const int a, const int b) {return ll(a) * b % md;}
};
vector<int> a[2];
int b[2];
void take(int fi, int se) {
cout << "UZMI " << (fi ? 'D' : 'L') _ (se ? 'D' : 'L') << '\n';
b[fi] = a[se].back();
a[se].pop_back();
}
void put(int fi, int se) {
cout << "STAVI " << (fi ? 'D' : 'L') _ (se ? 'D' : 'L') << '\n';
a[se].push_back(b[fi]);
b[fi] = -1;
}
void solve() {
int n; cin >> n;
a[0].resize(n);
for(int &i : a[0]) cin >> i;
vector<int> f(n);
iota(bnd(f), 0);
sort(bnd(f), [&] (const int &l, const int &r) {return a[0][l] < a[0][r];});
for(int i = 0; i < n; ++i) a[0][f[i]] = i + 1;
reverse(bnd(a[0]));
for(int i = 0; i < n; ++i) {
while(a[0].back() != i + 1)
take(0, 0),
put(0, 1);
take(1, 0);
while(i ? a[1].back() != i : len(a[1]))
take(0, 1),
put(0, 0);
put(1, 0);
while(len(a[1]))
take(0, 1),
put(0, 0);
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef _LOCAL
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
#else
system("color a");
freopen("in.txt", "r", stdin);
int t; cin >> t;
while(t--)
#endif
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |
2 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |
3 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |
4 |
Incorrect |
6 ms |
748 KB |
Expected integer, but "UZMI" found |
5 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |
6 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |
7 |
Incorrect |
7 ms |
620 KB |
Expected integer, but "UZMI" found |
8 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |
9 |
Incorrect |
7 ms |
620 KB |
Expected integer, but "UZMI" found |
10 |
Incorrect |
6 ms |
620 KB |
Expected integer, but "UZMI" found |