#include "grader.h"
#include <iostream>
#include <random>
std::mt19937 rng(69420);
int HC(int N)
{
int lastAsked = -1;
int l = 0, r = N + 1;
while (l < r - 2)
{
int mid = (l + r) / 2;
if (lastAsked != l + 1 && lastAsked != r - 1)
{
int mid = (l + r) / 2;
if (rng() % 2)
{
Guess(l + 1);
int res = Guess(r - 1);
lastAsked = r - 1;
if (res == 0)
{
return mid;
}
if (res == -1)
{
r = mid + ((l + r) % 2 == 1);
} else
{
l = mid;
}
} else
{
Guess(r - 1);
int res = Guess(l + 1);
lastAsked = l + 1;
if (res == 0)
{
return mid;
}
if (res == 1)
{
r = mid + ((l + r) % 2 == 1);
} else
{
l = mid;
}
}
continue;
}
if (lastAsked == l + 1)
{
int res = Guess(r - 1);
lastAsked = r - 1;
if (res == 0)
{
return mid;
}
if (res == -1)
{
r = mid + ((l + r) % 2 == 1);
} else
{
l = mid;
}
} else
{
int res = Guess(l + 1);
lastAsked = l + 1;
if (res == 0)
{
return mid;
}
if (res == 1)
{
r = mid + ((l + r) % 2 == 1);
} else
{
l = mid;
}
}
}
return l + 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
7000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
6744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
635 ms |
16464 KB |
Output is partially correct - alpha = 0.137931034483 |