Submission #487415

# Submission time Handle Problem Language Result Execution time Memory
487415 2021-11-15T12:06:15 Z Nimbostratus Knjige (COCI20_knjige) C++17
0 / 50
3 ms 592 KB
#include "bits/stdc++.h"
using namespace std;
#define endl '\n'
using lint = long long;
using pii = pair<int,int>;
constexpr int maxn = 2e5+5;
constexpr int inf = 2e9;
constexpr int mod = 1e9+7;

int n, a[maxn];
vector<string> v;

signed main() {
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	do {
		int mx = max_element(a, a + n) - a;
		for(int i = 0; i < mx; i++) {
			v.push_back("UZMI L L");
			v.push_back("STAVI L R");
		}
		v.push_back("UZMI R L");
		for(int i = mx + 1; i < n; i++) {
			v.push_back("UZMI L L");
			v.push_back("STAVI L R");
		}
		v.push_back("STAVI R L");
		for(int i = 0; i < n - 1; i++) {
			v.push_back("UZMI L R");
			v.push_back("STAVI L L");
		}
		for(int i = mx + 1; i < n; i++)
			swap(a[i - 1], a[i]);
	} while(--n);
	cout << v.size() << endl;
	for(auto& s : v)
		cout << s << endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  freopen("in.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen("out.txt","w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Runtime error 3 ms 592 KB Execution killed with signal 11
3 Runtime error 2 ms 592 KB Execution killed with signal 11
4 Runtime error 3 ms 592 KB Execution killed with signal 11
5 Runtime error 3 ms 592 KB Execution killed with signal 11
6 Runtime error 2 ms 592 KB Execution killed with signal 11
7 Runtime error 3 ms 592 KB Execution killed with signal 11
8 Runtime error 3 ms 592 KB Execution killed with signal 11
9 Runtime error 3 ms 592 KB Execution killed with signal 11
10 Runtime error 3 ms 592 KB Execution killed with signal 11