#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
template<class T>
void readi(T &x)
{
T input = 0;
bool negative = false;
char c = ' ';
while (c < '-')
{
c = getchar();
}
if (c == '-')
{
negative = true;
c = getchar();
}
while (c >= '0')
{
input = input * 10 + (c - '0');
c = getchar();
}
if (negative)
{
input = -input;
}
x = input;
}
template<class T>
void printi(T output)
{
if (output == 0)
{
putchar('0');
return;
}
if (output < 0)
{
putchar('-');
output = -output;
}
int aout[20];
int ilen = 0;
while(output)
{
aout[ilen] = ((output % 10));
output /= 10;
ilen++;
}
for (int i = ilen - 1; i >= 0; i--)
{
putchar(aout[i] + '0');
}
return;
}
template<class T>
void ckmin(T &a, T b)
{
a = min(a, b);
}
template<class T>
void ckmax(T &a, T b)
{
a = max(a, b);
}
long long randomize(long long mod)
{
return ((1ll << 30) * rand() + (1ll << 15) * rand() + rand()) % mod;
}
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-10;
#define MAGIC 347
#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
long long normalize(long long x, long long mod = INF)
{
return (((x % mod) + mod) % mod);
}
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N;
int lst, lstres;
int go(int x)
{
if (x == lst)
{
return lstres;
}
lst = x;
lstres = Guess(x);
return lstres;
}
pii merge(pii a, pii b)
{
return MP(max(a.fi, b.fi), min(a.se, b.se));
}
int solve(int L, int R)
{
if (L == R) return L;
int was = lst, is = max(1, min(N, L + R - was));
int b = go(is);
if (b == 0)
{
return (is + was) / 2;
}
int mid = (is + was) / 2;
pii guy;
pii cur = MP(L, R);
pii msg;
if (b == 1)
{
if (is > was)
{
msg = MP(mid + 1, is);
}
else
{
if (mid + mid == L + R)
{
msg = MP(is, mid - 1);
}
msg = MP(is, mid);
}
}
else
{
if (is > was)
{
if (mid + mid == L + R)
{
msg = MP(was, mid - 1);
}
else
{
msg = MP(was, mid);
}
}
else
{
msg = MP(mid + 1, was);
}
}
guy = merge(cur, msg);
return solve(guy.fi, guy.se);
}
int HC(int n)
{
N = n;
lst = -1; lstres = -1;
go(1);
return solve(1, N);
//1 means ur getting better, 0 means equal, -1 means worse
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
842 ms |
8316 KB |
Output is partially correct - alpha = 0.222222222222 |