#include "snakelib.h"
#include<bits/stdc++.h>
using namespace std;
int k;
char a1, a2;
int main(){
int l,r,minLen,maxLen,mid1,mid2;
k= get_speed();
minLen=1;maxLen=12122;
l=0;r=12122;
for(int i=1;i<=30;++i){
mid1 = l + (r-l)/3;
mid2=r - (r-l)/3;
ask_snake(mid1,mid2,&a1,&a2);
if(a1=='f'){
if(a2=='f') maxLen=mid2-l,r=mid2+k-1;
if(a2=='s')minLen=mid2-mid1+2,maxLen=mid2-l,r=mid2+k;
if(a2=='b')minLen=mid2-mid1+3,r+=k;
}
if(a1=='s'){
if(a2=='s'){
tell_length(minLen=r-l+1);
return 0;
}
l=mid1;
if(a2=='f')maxLen=mid2-l,r=mid2+k-1;
if(a2=='b')maxLen=r-mid1+1,r=mid2+k;
}
if(a1=='b'){
l=mid1+1;
if(a2=='f')maxLen=mid2-mid1-1,r=mid2+k-1;
if(a2=='s')maxLen=mid2-mid1,r=mid2+k;
if(a2=='b')minLen=r-mid1+1,r+=k;
}
}
int guess=(maxLen+minLen)/2;
tell_length(guess);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (3 units) |
2 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (1785 units) |
3 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (960 units) |
4 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (625 units) |
5 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (579 units) |
6 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (9 units) |
7 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (9 units) |
8 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (8 units) |
9 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (8 units) |
10 |
Partially correct |
1 ms |
500 KB |
Output is partially correct: estimate ok. 17 calls needed |
11 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (6 units) |
12 |
Partially correct |
1 ms |
336 KB |
Output is partially correct: estimate ok. 21 calls needed |
13 |
Partially correct |
1 ms |
336 KB |
Output is partially correct: estimate ok. 17 calls needed |
14 |
Correct |
1 ms |
336 KB |
Output is correct: estimate ok. 2 calls needed |
15 |
Correct |
1 ms |
336 KB |
Output is correct: estimate ok. 2 calls needed |
16 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (2826 units) |
17 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (1582 units) |
18 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (4727 units) |
19 |
Incorrect |
1 ms |
420 KB |
your estimate differs too much (3101 units) |
20 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (685 units) |