#include <bits/stdc++.h>
#define sz(x) (int)(x.size())
#define debug printf
#define lp(i,a,b) for(int i = a ; i < b; i++)
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pii pair<int,int>
#define ll long long
#define all(x) x.begin(),x.end()
const int MAXN = 1e5+10 ;
using namespace std ;
int N ;
vector<int> vec ;
vector<string> a ,b , c ;
vector<pair<int,int> > p ;
int main()
{
cin >> N ;
for(int i = 1 , x ; i <= N ; i++ )
{
cin >> x ;
p.pb( make_pair(x,i-1) ) ;
vec.push_back(x) ;
}
sort(all(p)) ;
for(int i = 0 ; i < N ; i++ ) vec[p[i].second] = i+1 ;
for(int i = 1 , j = N ; i < N ; i++ , j-- )
{
int k ;
for(int kk = 0 ; kk < sz(vec) ; kk++ )
{
if(vec[kk] == j)
{
k = kk ;
a.pb("UZMI") ;
b.pb("D") ;
c.pb("L") ;
continue ;
}
a.pb("UZMI") ;
a.pb( "STAVI" ) ;
b.pb("L") ;
b.pb("L") ;
c.pb( "L" ) ;
c.pb("D") ;
}
vector<int> lef( vec.begin() , vec.begin()+k ) ;
vector<int> rig( vec.begin()+k+1 , vec.end() ) ;
a.pb( "STAVI" ) ;
b.pb("D") ;
c.pb("L") ;
vec.clear() ;
vec.insert(vec.begin() , lef.begin() , lef.end() ) ;
vec.insert( vec.end() , rig.begin() , rig.end() ) ;
for(auto e : vec )
{
a.pb("UZMI") ;
a.pb( "STAVI" ) ;
b.pb("L") ;
b.pb("L") ;
c.pb( "D" ) ;
c.pb("L") ;
}
}
cout << sz(a) << endl ;
for(int i = 0 ; i < sz(a) ; i++ )
{
cout << a[i] << " " << b[i] << " " << c[i] << endl ;
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:68:12: warning: unused variable 'e' [-Wunused-variable]
68 | for(auto e : vec )
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
2512 KB |
Output is correct |
2 |
Correct |
36 ms |
2508 KB |
Output is correct |
3 |
Correct |
43 ms |
2508 KB |
Output is correct |
4 |
Correct |
37 ms |
2512 KB |
Output is correct |
5 |
Correct |
36 ms |
2508 KB |
Output is correct |
6 |
Correct |
37 ms |
2504 KB |
Output is correct |
7 |
Correct |
37 ms |
2508 KB |
Output is correct |
8 |
Correct |
38 ms |
2512 KB |
Output is correct |
9 |
Correct |
37 ms |
2508 KB |
Output is correct |
10 |
Correct |
36 ms |
2512 KB |
Output is correct |