답안 #452014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
452014 2021-08-03T16:02:17 Z Apiram Knjige (COCI20_knjige) C++14
0 / 50
3 ms 1876 KB
#include<bits/stdc++.h>
using namespace std;
vector<string>ans;
vector<char>a,b;
void add(int i,int j,int l){
	if (i==0){
		ans.push_back("UZMI");
	}
	else{
		ans.push_back("STAVI");
	}
	if(j==0){
		a.push_back('L');
	}
	else{
		a.push_back('D');
	}
	if (l==0){
		b.push_back('L');
	}
	else{
		b.push_back('D');
	}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
vector<int>arr(n);
stack<int>first,second;
for (int i = 0;i<n;++i){
	cin>>arr[i];
	first.push(arr[i]);
}
vector<int>brr=arr;

sort(brr.rbegin(),brr.rend());
int j =0;
bool lefthand=false,righthand=false;
for (int i = 0;i<n;++i){
	while(first.top()>brr[i]){
		add(0,0,0);
		add(1,0,1);
		second.push(first.top());
		first.pop();
	}
	add(0,1,0);
	first.pop();
	while(!first.empty()){
		add(0,0,0);
		add(1,0,1);
		second.push(first.top());
		first.pop();
	}
	add(1,1,0);
	while(!second.empty()){
		add(0,0,1);
		add(1,0,0);
		first.push(second.top());
		second.pop();
	}
	
}

cout<<ans.size()<<endl;
for (int i = 0;i<ans.size();++i){
	cout<<ans[i]<<" "<<a[i]<<" "<<b[i]<<endl;
}
return 0;}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:66:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 | for (int i = 0;i<ans.size();++i){
      |                ~^~~~~~~~~~~
Main.cpp:38:5: warning: unused variable 'j' [-Wunused-variable]
   38 | int j =0;
      |     ^
Main.cpp:39:6: warning: unused variable 'lefthand' [-Wunused-variable]
   39 | bool lefthand=false,righthand=false;
      |      ^~~~~~~~
Main.cpp:39:21: warning: unused variable 'righthand' [-Wunused-variable]
   39 | bool lefthand=false,righthand=false;
      |                     ^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1876 KB Execution killed with signal 11
2 Runtime error 3 ms 1876 KB Execution killed with signal 11
3 Runtime error 3 ms 1748 KB Execution killed with signal 11
4 Runtime error 3 ms 1804 KB Execution killed with signal 11
5 Runtime error 3 ms 1844 KB Execution killed with signal 11
6 Runtime error 3 ms 1748 KB Execution killed with signal 11
7 Runtime error 3 ms 1876 KB Execution killed with signal 11
8 Runtime error 3 ms 1876 KB Execution killed with signal 11
9 Runtime error 3 ms 1748 KB Execution killed with signal 11
10 Runtime error 3 ms 1876 KB Execution killed with signal 11