#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
int rec(int l, int r, int last){
if(l == r) return l;
int m = (l + r) >> 1;
if(m == last && m > l) m --;
else if(m == last) m ++;
int x = Guess(m);
if(x == 0){
return (m + last) / 2;
}
if(x == 1){
if(m <= last) return rec(l, min((m + last - 1) / 2, r), m);
else return rec(max(l, (m + last) / 2 + 1), r, m);
}
if(x == -1){
if(m <= last) return rec(max(l, (m + last) / 2 + 1), r, m);
else return rec(l, min((last + m - 1) / 2, r), m);
}
}
int HC(int N){
if(N == 1) return 1;
Guess(N / 2);
return rec(1, N, N / 2);
}
Compilation message
hottercolder.cpp: In function 'int rec(int, int, int)':
hottercolder.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
24 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
750 ms |
8244 KB |
Output is partially correct - alpha = 0.500000000000 |