| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 373247 | sam571128 | Knjige (COCI20_knjige) | C++14 | 4 ms | 1124 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
signed main(){
fastio
int n;
cin >> n;
multiset<int> s;
int arr[n];
stack<int> st, st2;
for(int i = 0;i < n;i++){
cin >> arr[i];
s.insert(arr[i]);
}
for(int i = n-1;~i;i--) st.push(arr[i]);
vector<pair<string,pair<char,char>>> v;
while(!st.empty()){
if(st.top()!=*s.begin()){
v.push_back({"UZMI",{'L','L'}});
v.push_back({"STAVI",{'L','D'}});
st2.push(st.top());
st.pop();
}else{
v.push_back({"UZMI",{'D','L'}});
s.erase(s.find(st.top()));
st.pop();
while(!st2.empty()){
v.push_back({"UZMI",{'L','D'}});
v.push_back({"STAVI",{'L','L'}});
st.push(st2.top());
st2.pop();
}
v.push_back({"STAVI",{'D','D'}});
}
}
for(int i = 0;i < n;i++){
v.push_back({"UZMI",{'L','D'}});
v.push_back({"STAVI",{'L','L'}});
}
cout << v.size() << "\n";
for(auto p : v){
cout << p.first << " " << p.second.first << " " << p.second.second << "\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
