#include "snakelib.h"
#include<bits/stdc++.h>
using namespace std;
int k,l,r,minLen,maxLen,mid1,mid2;
char a1, a2;
int main(){
k=get_speed();
minLen=1;maxLen=12122;
l=0;r=12122;
for(int i=1;i<=13;++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'){
return minLen=r-l+1;
}
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,r=mid2+k;
if(a2=='b')minLen=r-mid1+1,r+=k;
}
}
int guess=(maxLen+minLen)/2;
tell_length(guess);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
2 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
3 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
4 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
5 |
Runtime error |
0 ms |
436 KB |
Execution killed with signal 13 |
6 |
Runtime error |
1 ms |
432 KB |
Execution killed with signal 13 |
7 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
8 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
9 |
Runtime error |
0 ms |
428 KB |
Execution killed with signal 13 |
10 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 13 |
11 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
12 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
13 |
Runtime error |
0 ms |
428 KB |
Execution killed with signal 13 |
14 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
15 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
16 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
17 |
Runtime error |
1 ms |
440 KB |
Execution killed with signal 13 |
18 |
Runtime error |
0 ms |
344 KB |
Execution failed because the return code was nonzero |
19 |
Runtime error |
0 ms |
432 KB |
Execution killed with signal 13 |
20 |
Runtime error |
0 ms |
436 KB |
Execution killed with signal 13 |