# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
378409 | Araragi | Knjige (COCI20_knjige) | C++17 | 10 ms | 1772 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("00")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
const int inf = 1e9;
const ll inf64 = 1e18;
#define ft first
#define fin(x) ifstream cin("x.in");
#define fout(x) ofstream cout("x.out");
#define sd second
#define pb push_back
#define sz(x) (int)x.size()
int hand[2];
vector<int> a[2];
vector<string> cmd;
vector<int> num;
bool cmp(int& x, int& y) {return (a[0][x] < a[0][y]);}
void get(int fst, int scd) {
cmd.pb((string)"UZMI " + (fst ? "D" : "L") + " " + (scd ? "D" : "L"));
hand[fst] = a[scd].back();
a[scd].pop_back();
}
void put(int fst, int scd) {
cmd.pb((string)"STAVI " + (fst ? "D" : "L") + " " + (scd ? "D" : "L"));
a[scd].pb(hand[fst]);
hand[fst] = 0;
}
void nande(int where) {cerr << "called debug procedure...\n"; for (auto it : a[where]) cerr << it << " "; cerr << '\n'; cerr << "ended'\n";}
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
system("color 2");
int n;
cin >> n;
a[0].resize(n);
num.resize(n);
for (int i = 0; i < n; i++)
cin >> a[0][i];
if (is_sorted(a[0].begin(), a[0].end()))
{
cout << "0";
return 0;
}
iota(num.begin(), num.end(), 0);
sort(num.begin(), num.end(), cmp);
for (int i = 0; i < n; i++)
a[0][num[i]] = i + 1;
reverse(a[0].begin(), a[0].end());
// 0 - LEFT, 1 - DANTE
// get(fst, scd), put(fst, scd) (fst - hand, scd - shelf)
//int cnt = 0;
for (int i = 0; i < n; i++)
{
//nande(0);
while (a[0].back() != i + 1)
{
get(0, 0);
put(0, 1);
// cnt++;
}
get(1, 0);
//nande(0);
//nande(1);
while ((i > 0 ? a[1].back() != i : !a[1].empty()))
{
get(0, 1);
put(0, 0);
}
//nande(0);
//nande(1);
put(1, 0);
//nande(0);
//nande(1);
while (!a[1].empty())
{
get(0, 1);
put(0, 0);
}
//nande(0);
//nande(1);
}
cout << sz(cmd) << '\n';
for (auto it : cmd)
cout << it << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |