#include "grader.h"
#include <iostream>
using namespace std;
int ans = 0;
int n = 0;
//void init()
//{
// const int M = 50000000;
// ve.push_back(1), ve.push_back(1), ve.push_back(3);
// while(ve.back() < M)
// {
// ve.push_back(ve[ve.size() - 2] + ve[ve.size() - 1] + 1);
// }
//}
void f(int p, int q, int r)
{
if(p == q)
{
ans = p;
return;
}
if(r == 0)
{
Guess(p);
int t = Guess(q);
if(t == 1)
{
f((p + q + 2) / 2, q, q);
}
else if(t == -1)
{
f(p, (p + q - 1) / 2, q);
}
else
{
ans = (p + q) / 2;
}
return;
}
int t = p + q - r;
if(t < 1 || t > n)
{
Guess(p);
int x = Guess(q);
if(x == 1)
{
f((p + q + 2) / 2, q, q);
}
else if(x == -1)
{
f(p, (p + q - 1) / 2, q);
}
else
{
ans = (p + q) / 2;
}
return;
}
int y = t + r;
int x = Guess(t);
if(x == 0)
{
ans = y / 2;
return;
}
if((x == 1) ^ (t < r))
{
f((y + 2) / 2, q, t);
}
else
{
f(p, (y - 1) / 2, t);
}
}
int HC(int N)
{
n = N;
ans = 0;
f(1, n, 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
753 ms |
8144 KB |
Output is partially correct - alpha = 0.222222222222 |