Submission #844744

# Submission time Handle Problem Language Result Execution time Memory
844744 2023-09-05T19:29:30 Z vjudge1 Knjige (COCI20_knjige) C++17
0 / 50
3 ms 1496 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll MAXN = 5005;

vector<int> A, srt;
string put(string hand, string shelf) {
	return "STAVI " + hand + " " + shelf + "\n";
}

string take(string hand, string shelf) {
	return "UZMI " + hand + " " + shelf + "\n"; 
}

int main() {
	fast
	int N;
	cin >> N;

	A = vector<int>(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		srt.push_back(A[i]);
	}
	sort(srt.begin(), srt.end());

	stack<int> l, r;
	vector<string> ans;
	for (int i = N-1; i >= 0; i--)
		l.push(A[i]);

	while (l.size() || r.size()) {
		while (l.size() && srt.back() != l.top()) {
			ans.push_back(take("L", "L"));
			ans.push_back(put("L", "R"));
			r.push(l.top());
			l.pop();
		}
		ans.push_back(take("R", "L"));
		l.pop(); 
		while (l.size()) {
			ans.push_back(take("L", "L"));
			ans.push_back(put("L", "R"));
			r.push(l.top());
			l.pop();
		}
		ans.push_back(put("R", "L"));

		while (r.size()) {
			ans.push_back(take("L", "R"));
			ans.push_back(put("L", "L"));
			l.push(r.top());
			r.pop();
		}
		srt.pop_back(); 
	}

	cout << ans.size() << "\n";
	for (auto u : ans)
		cout << u;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
2 Incorrect 2 ms 1496 KB Token "R" doesn't correspond to pattern "(L|D)"
3 Incorrect 3 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
4 Incorrect 2 ms 1496 KB Token "R" doesn't correspond to pattern "(L|D)"
5 Incorrect 2 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
6 Incorrect 2 ms 1496 KB Token "R" doesn't correspond to pattern "(L|D)"
7 Incorrect 2 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
8 Incorrect 2 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
9 Incorrect 3 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
10 Incorrect 2 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"