# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1089778 | SalihSahin | Knjige (COCI20_knjige) | C++14 | 20 ms | 2256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2048;
vector<array<string, 3> > ans;
void operation(int type, int hand, int shelf){ // take = 0, left = 0
array<string, 3> op;
if(!type) op[0] = "UZMI";
else op[0] = "STAVI";
if(!hand) op[1] = "L";
else op[1] = "D";
if(!shelf) op[2] = "L";
else op[2] = "D";
ans.pb(op);
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin>>n;
vector<int> a(n);
vector<int> ls, rs;
for(int i = 0; i < n; i++){
int x;
cin>>x;
ls.pb(x);
a[i] = x;
}
//reverse(ls.begin(), ls.end());
sort(a.begin(), a.end());
for(int i = n-1; i >= 0; i--){
if(ls[i] == a[i]) continue;
bool vis = 0;
while(ls.size() > n-i-1){
if(ls.back() == a[i] && !vis){
operation(0, 1, 0);
vis = true;
}
else{
operation(0, 0, 0);
rs.pb(ls.back());
operation(1, 0, 1);
}
ls.pop_back();
}
operation(1, 1, 0);
while(!rs.empty()){
operation(0, 0, 1);
ls.pb(rs.back());
rs.pop_back();
operation(1, 0, 0);
}
}
cout<<ans.size()<<endl;
for(auto itr: ans){
cout<<itr[0]<<" "<<itr[1]<<" "<<itr[2]<<endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |