답안 #844741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844741 2023-09-05T19:28:26 Z vjudge1 Knjige (COCI20_knjige) C++17
0 / 50
3 ms 1752 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 = 0; i < N; 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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
2 Incorrect 3 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
3 Incorrect 3 ms 1496 KB Token "R" doesn't correspond to pattern "(L|D)"
4 Incorrect 3 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
5 Incorrect 3 ms 1496 KB Token "R" doesn't correspond to pattern "(L|D)"
6 Incorrect 3 ms 1752 KB Token "R" doesn't correspond to pattern "(L|D)"
7 Incorrect 3 ms 1492 KB Token "R" doesn't correspond to pattern "(L|D)"
8 Incorrect 3 ms 1496 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)"