//#include "hottercolder.h"
#include <cstdio>
#include "grader.h"
#include <algorithm>
using namespace std;
int HC(int N){
//int g = Guess(1);
int lo=1;
int hi=N;
int lastguess=1;
Guess(lastguess);
int lmid;
int rmid;
int res;
while (lo<hi) {
lmid=lastguess;
rmid=hi-lastguess+lo;
if (rmid<lo||rmid>hi) {
lmid=lo;
Guess(lmid);
rmid=hi;
}
//printf("newguess %d\n",rmid);
res=Guess(rmid);
lastguess=rmid;
if (rmid<lmid) {
swap(rmid,lmid);
res=-res;
}
//printf("%d %d %d %d\n",lo,hi,lmid,rmid);
if (res==0) return (lmid+rmid)>>1;
if (res<0) {
//printf("lmid\n");
//lmid side
hi=((lmid+rmid)>>1)-((rmid-lmid+1)%2);
//printf("hi %d\n",hi);
} else {
//printf("rmid\n");
//rmid side
lo=((lmid+rmid)>>1)+1;
}
}
return lo;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
806 ms |
8248 KB |
Output is partially correct - alpha = 0.115384615385 |