답안 #377832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377832 2021-03-15T08:17:33 Z kshitij_sodani Knjige (COCI20_knjige) C++14
50 / 50
3 ms 492 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'
int it[101];
int n;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	vector<int> ss;
	for(int i=0;i<n;i++){
		cin>>it[i];
		ss.pb(it[i]);
	}
	
	sort(ss.begin(),ss.end());
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=2;
		ans+=4*(n-i-1);
	}
	//reverse(ss.begin(),ss.end());
	for(int i=0;i<n/2;i++){
		swap(it[i],it[n-i-1]);
	}
	cout<<ans<<endl;
	for(int i=0;i<n;i++){
		int x=ss[n-i-1];
		int st=0;
		for(int j=n-1;j>=i;j--){
			if(st==0){
				if(it[j]==x){
					st=j+1;
				}
			}
		}
		st--;
		vector<int> tt;
		for(int j=i;j<n;j++){
			if(j!=st){
				tt.pb(it[j]);
			//	cout<<it[j]<<",";
			}
		}
	//	cout<<endl;
		it[i]=ss[n-i-1];

		for(int k=0;k<tt.size();k++){
			it[i+k+1]=tt[k];
		}
		/*for(int j=0;j<n;j++){
			cout<<it[j]<<":";
		}
		cout<<endl;*/
		for(int j=n-1;j>=i;j--){
			if(j==st){
				cout<<"UZMI D L"<<endl;
			}
			else{
				cout<<"UZMI L L"<<endl;
				cout<<"STAVI L D"<<endl;
			}
		}
		cout<<"STAVI D L"<<endl;
		for(int j=n-1;j>=i;j--){
			if(j==st){
			}
			else{
				cout<<"UZMI L D"<<endl;
				cout<<"STAVI L L"<<endl;
			}
		}

	}









 
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int k=0;k<tt.size();k++){
      |               ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 3 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 3 ms 492 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 2 ms 492 KB Output is correct