# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
704900 | 1075508020060209tc | Knjige (COCI20_knjige) | C++14 | 3 ms | 984 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;
int ar[500005];
int freq[500005];
vector<pair<int,pair<char,char>>>ans;
stack<int>stkl;stack<int>stkr;
void swplr(){
ans.push_back({1,{'L','L'}});
ans.push_back({0,{'L','R'}});
stkr.push(stkl.top());
stkl.pop();
}
void swprl(){
ans.push_back({1,{'L','R'}});
ans.push_back({0,{'L','L'}});
stkl.push(stkr.top());
stkr.pop();
}
signed main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
for(int i=n;i>=1;i--){
cin>>ar[i];
}
for(int i=1;i<=n;i++){
stkl.push(ar[i]);
freq[ar[i]]++;
}
for(int i=1;i<=n;i++){
swplr();
}
sort(ar+1,ar+n+1);
for(int i=n;i>=1;i--){
int rhand=0;
while(stkr.size()){
if(stkr.top()==ar[i]&&rhand==0){
ans.push_back({1,{'R','R'}});
rhand=1;
stkr.pop();
continue;
}
swprl();
}
while(stkl.size()){
swplr();
}
ans.push_back({0,{'R','L'}});
}
cout<<ans.size()<<endl;
for(int i=0;i<ans.size();i++){
if(ans[i].first==0){
cout<<"STAVI ";
}else{
cout<<"UZMI ";
}
if(ans[i].second.first=='R'){
cout<<"D ";
}else{
cout<<"L ";
}
if(ans[i].second.second=='R'){
cout<<"D\n";
}else{
cout<<"L\n";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |