#include "grader.h"
#include <algorithm>
using namespace std;
int solve( int l, int r, int prevRequest){
if( l == r ) return l;
int m = (l+r)>>1;
if( m == prevRequest && m != l ) m=m-1;
else if( m == prevRequest ) m=m+1;
int res1 = Guess(m);
if( res1 == 0 ){
return (m+prevRequest)/2;
}
if( res1 == 1 ){
if( prevRequest < m )
return solve(max(l,(m+prevRequest)/2+1), r, m);
else
return solve(l, min(r, (m+prevRequest-1)/2), m);
}
if( prevRequest < m ){
return solve(l, min(r, (prevRequest+m-1)/2), m);
}else{
return solve(max(l, (prevRequest+m)/2+1), r, m);
}
}
int HC(int N){
if( N == 1 ) return 1;
Guess(N/2);
return solve(1, N, N/2);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
701 ms |
8180 KB |
Output is partially correct - alpha = 0.500000000000 |