#include "grader.h"
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
int HC(int n){
int l=1,r=n,ct=0,res=0;
vector<pair<int,int> >a;
while(l<=r){
//printf("%i %i\n",l,r);
if(l==r){res=l;break;}
int mid=l+r>>1;
if(ct%2==0){
a.pb({Guess(mid),mid});
a.pb({Guess(mid+1),mid+1});
if(a.back().fi==-1) r=mid;
else l=mid+1;
}
else{
if(a.back().se<mid){
int k=(r-l)/4;
mid=l+3*k;
a.pb({Guess(mid),mid});
if(a.back().fi==1) l=mid-k;
else r=mid-k;
}
else{
int k=(r-l)/4;
mid=l+k;
a.pb({Guess(mid),mid});
if(a.back().fi==1) r=mid+k;
else l=mid+k;
}
}
ct++;
}
return res;
}
Compilation message
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:15:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
15 | int mid=l+r>>1;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
9552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
9556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
9628 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
831 ms |
135252 KB |
Output isn't correct - alpha = 0.000000000000 |
2 |
Halted |
0 ms |
0 KB |
- |