# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
844754 | dosts | Knjige (COCI20_knjige) | C++14 | 2 ms | 988 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma optimize "DostSeferoğlu"
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx2,tune=native")
using namespace std;
#define int long long
#define pii pair<int,int>
#define bg begin
#define vi vector<int>
#define endl '\n'
#define vvi vector<vi>
#define vp vector<pii>
#define sp << " " <<
#define all(x) x.bg()+1,x.end()
#define ff first
#define ss second
#define brake {cout << "OK\n";return;}
#define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;}
#define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx)
#define F(xx,yy) for (int xx=1;xx<=yy;++xx)
#define pb push_back
const int inf = 1e18;
const int MOD = 998244353;
const int N = 2e5+1;
vector<string> ops;
void solu_bosalt(vi& a,vi& b,int ptr) {
while (!a.empty()) {
ops.push_back("AL L L");// sol elle solu al
ops.push_back("KOY L R");// sol elle sağa koy
b.push_back(a.back());
a.pop_back();
}
}
void hallet(vi& a,vi& b,int ptr) {
solu_bosalt(a,b,ptr);
ops.push_back("KOY R L");
}
void sag_ele_al(vi& a,vi& b,int ptr) {
while (!a.empty()) {
if (a.back() == ptr) {
ops.pb("AL R L");
a.pop_back();
return;
}
else {
ops.pb("AL R L");
ops.pb("KOY R R");
b.push_back(a.back());
a.pop_back();
}
}
while (!b.empty()) {
if (b.back() == ptr) {
b.pop_back();
ops.pb("AL R R");
return;
}
else {
a.pb(b.back());
b.pop_back();
ops.pb("AL R R");
ops.pb("KOY R L");
}
}
}
void solve() {
int n;
cin >> n;
vi thicks;
vi a(n);
for (int i=0;i<n;i++) cin >> a[i];
for (auto it : a) thicks .pb(it);
sort(thicks.bg(),thicks.end(),greater<int>());
vi b{};
int left_hand = 0,right_hand = 0;
for (auto it : thicks) {
sag_ele_al(a,b,it);
debug(a);
debug(b);
hallet(a,b,it);
}
cout << ops.size() << endl;
for (auto it : ops) {
cout << it << endl;
}
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef Local
freopen("input.in", "r", stdin);
freopen("input.out", "w", stdout);
#endif
int t = 1;
//cin >> t;
while (t --> 0) solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |