#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){
//for(int i=1;i<=50;i++){for(int j=1;j<=i;j++) printf("%i %i\n",i,j);}
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 || r-l<=3){
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+1)/4;
mid=l+3*k;
//printf("%i\n",mid);
a.pb({Guess(mid),mid});
int sledeci=l+mid>>1;
if(a.back().fi==1) l=sledeci;
else r=sledeci;
}
else{
int k=(r-l+1)/4;
mid=l+k;
//printf("%i\n",mid);
a.pb({Guess(mid),mid});
int sledeci=mid+r+1>>1;
if(a.back().fi==1) r=sledeci;
else l=sledeci;
}
}
ct++;
}
return res;
}
Compilation message
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:16:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
16 | int mid=l+r>>1;
| ~^~
hottercolder.cpp:29:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
29 | int sledeci=l+mid>>1;
| ~^~~~
hottercolder.cpp:38:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
38 | int sledeci=mid+r+1>>1;
| ~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
1368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
1368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
1372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
733 ms |
24400 KB |
Output isn't correct - alpha = 0.000000000000 |
2 |
Halted |
0 ms |
0 KB |
- |