#include "grader.h"
#include <cstdio>
using namespace std;
int left,right;
bool last;
int HC(int N){
if(N==1)return 1;
Guess(1);
int res1 = Guess(2);
if(N==2)
{
if(res1==1)return 2;
else return 1;
}
int res2;
//printf("%d\n",N);
for(int i=3;i<=N;i++)
{
res2 = Guess(i);
//printf("%d*",res2);
if(res2 != res1)
{
if(res2==1)return i;
if(res2==-1)return i-1;
}
else res1=res2;
}
if(res2==1)return N;
else return 1;
/*
//printf("%d\n",N);
left=1,right=N;
last = 0;
Guess(left);
while(left+1 < right)
{
//printf("%d %d\n",left,right);
int res;
int mid=(left+right)/2;
if(last==0)
{
res = Guess(right);
if(res == -1)
{
right = mid;
Guess(left);
last = 0;
}
else if(res == 1)
{
left = mid;
last = 1; //next is left
}
else if(res == 0)
{
return mid;
}
}
else
{
res = Guess(left);
if(res == -1)
{
left = mid;
Guess(right);
last = 1;
}
else if(res == 1)
{
right = mid;
last = 0; //next is left
}
else if(res == 0)
{
return mid;
}
}
}
if(right == left+1)
{
//printf("%d\n",last);
int res;
if(last == 0)
{
res = Guess(right);
if(res == 1)return right;
else return left;
}
else if(last == 1)
{
res = Guess(left);
if(res == 1)return left;
else return right;
}
}*/
}
Compilation message
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:28:2: warning: 'res2' may be used uninitialized in this function [-Wmaybe-uninitialized]
if(res2==1)return N;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
97 ms |
1272 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
108 ms |
1272 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10010 ms |
8184 KB |
Time limit exceeded |