QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#294271 | #4831. Eager Sorting | ucup_team_qiuly# | 0 | 0ms | 0kb | C++14 | 1.2kb | 2023-12-30 11:08:29 | 2023-12-30 11:08:30 |
answer
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) fprintf (stderr, __VA_ARGS__)
#define lep(i, l, r) for (int i = (l), i##_end = (r); i <= i##_end; ++ i)
#define rep(i, r, l) for (int i = (r), i##_end = (l); i >= i##_end; -- i)
char _c; bool _f; template <class T> inline void IN (T & x) {
_f = 0, x = 0; while (_c = getchar (), ! isdigit (_c)) if (_c == '-') _f = 1;
while (isdigit (_c)) x = x * 10 + _c - '0', _c = getchar (); if (_f == 1) x = -x;
}
template <class T> inline void chkmin (T & x, T y) { if (x > y) x = y; }
template <class T> inline void chkmax (T & x, T y) { if (x < y) x = y; }
signed main () {
srand (28315732);
int n; IN (n);
auto op = [&] (int x, int y) {
if (x < y) swap (x, y);
int u; IN (u); if (! ~ u) exit (0); return u;
};
function <void (int, int)> doit = [&] (int l, int r) -> void {
if (l >= r) return ;
int cur = l + rand () % (r - l + 1), x = l, y = r;
while (x <= y) {
if (x < cur) op (x, cur) ? cur = x ++ : ++ x;
else if (y > cur) op (y, cur) ? cur = y -- : -- y;
else break ;
}
doit (l, cur - 1), doit (cur + 1, r);
}; doit (1, n);
cout << -1 << " " << -1 << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Instance #0 Time Limit Exceeded
Interactor to First Run
5
First Run to Interactor
Interactor to Second Run
Second Run to Interactor
Manager to Checker
WA Invalid Operation 1216629976 22002