#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<bitset>
#include<cassert>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(((long long)(n))-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
//#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define pb push_back
#define mk make_pair
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
typedef long long i64;
typedef long double f80;
typedef unsigned int u32;
typedef unsigned long long u64;
#include "grader.h"
i64 n;
i64 solve(i64 l,i64 r,i64 k)
{
if(l==r) return l;i64 md=(l+r)/2;
if(l<=3&&n-r>3) md=(l+l+r)/3;
if(n-r<=3&&l>3) md=(l+r+r)/3;
i64 p=md*2-k;p=max(1ll,p);p=min(n,p);
if(p==k){if(p<=(l+r)/2)p++; else p--;}
i64 ml=(p+k+1)/2-1,mr=(p+k)/2+1;
if(ml-l+1<(r-l+1)/4-2||r-mr+1<(r-l+1)/4-2) p=md,ml=(p+k+1)/2-1,mr=(p+k)/2+1;
int t=Guess(p);
if(t==0) return (k+p)/2;
if((t==1)==(p<k)) return solve(l,min(r,ml),p); else return solve(max(l,mr),r,p);
}
int HC(int nn)
{
n=nn;Guess(1);return solve(1,n,1);
}
Compilation message
hottercolder.cpp: In function 'i64 solve(i64, i64, i64)':
hottercolder.cpp:44:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
44 | if(l==r) return l;i64 md=(l+r)/2;
| ^~
hottercolder.cpp:44:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
44 | if(l==r) return l;i64 md=(l+r)/2;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
586 ms |
24376 KB |
Output is partially correct - alpha = 0.555555555556 |