#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
void read(T &x)
{
x = 0;
register int c;
while ((c = getchar()) && (c > '9' || c < '0'))
;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
}
constexpr bool typetest = 0;
constexpr int N = 1e3 + 5;
constexpr ll Inf = 1e17;
int *l, *r;
int solve(int left, int right)
{
if (left == right)
return left;
int le = left, mid, hi = right;
while (le <= hi)
{
mid = (le + hi) / 2;
if (query(left, mid, left, right))
hi = mid - 1;
else
le = mid + 1;
}
int root = le;
if (root > left)
l[root] = solve(left, root - 1);
if (root < right)
r[root] = solve(root + 1, right);
return root;
}
int solve(int n, int *Left, int *Right)
{
l = Left;
r = Right;
for (int i = 0; i < n; ++i)
l[i] = r[i] = -1;
return solve(0, n - 1);
}
/*
void Read()
{
}
void Solve()
{
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("xor.INP", "r"))
{
freopen("xor.inp", "r", stdin);
freopen("xor.out", "w", stdout);
}
int t(1);
if (typetest)
cin >> t;
for (int _ = 1; _ <= t; ++_)
{
// cout << "Case #" << _ << ": ";
Read();
Solve();
}
// cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
/**/
Compilation message
popa.cpp:93:1: warning: "/*" within comment [-Wcomment]
93 | /**/
|
popa.cpp: In function 'void read(T&)':
popa.cpp:13:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
13 | register int c;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
200 KB |
Output is correct |
2 |
Correct |
20 ms |
200 KB |
Output is correct |
3 |
Correct |
6 ms |
200 KB |
Output is correct |
4 |
Correct |
20 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
184 ms |
536 KB |
Output is correct |
2 |
Correct |
270 ms |
444 KB |
Output is correct |
3 |
Correct |
107 ms |
332 KB |
Output is correct |
4 |
Correct |
168 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
71 ms |
280 KB |
too many queries |
2 |
Halted |
0 ms |
0 KB |
- |