#include <stdio.h>
#include <algorithm>
#include "snakelib.h"
using namespace std;
int main(){
const int hd=12122;
int K=get_speed();
char A1,A2;
//int as=0,ae=hd-1,bs=1,be=hd,ls=1,le=hd;
int l=0,hl=0,r=12121,tr=12121,q=13,tm,hm;
while(q--){
tm=(l+tr)/2;hm=(hl+r)/2;
ask_snake(tm,hm,&A1,&A2);
if(A1=='s') l=tm,tr=tm+K;
else{
if(A1=='f')tr=tm+K-1;
else l=tm+1;
}
if(A2=='s') hl=hm,r=hm+K;
else{
if(A2=='f')r=hm+K-1;
else hl=hm+1;
}
if(A1=='s' && A2=='s'){
tell_length(hm-tm+1);
return 0;
}
}
tell_length(hl-l+1+(r-hl - tr+l) / 2);
return 0;
}
Compilation message
snake.cpp: In function 'int main()':
snake.cpp:6:12: warning: unused variable 'hd' [-Wunused-variable]
6 | const int hd=12122;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (12119 units) |
2 |
Incorrect |
0 ms |
336 KB |
your estimate differs too much (5831 units) |
3 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (983 units) |
4 |
Incorrect |
0 ms |
336 KB |
your estimate differs too much (1084 units) |
5 |
Incorrect |
0 ms |
504 KB |
your estimate differs too much (591 units) |
6 |
Incorrect |
0 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 (9 units) |
9 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (9 units) |
10 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (9 units) |
11 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (9 units) |
12 |
Correct |
1 ms |
336 KB |
Output is correct: estimate ok. 11 calls needed |
13 |
Incorrect |
0 ms |
336 KB |
your estimate differs too much (9 units) |
14 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (4040 units) |
15 |
Incorrect |
0 ms |
336 KB |
your estimate differs too much (4041 units) |
16 |
Incorrect |
1 ms |
504 KB |
your estimate differs too much (9296 units) |
17 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (1586 units) |
18 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (7395 units) |
19 |
Incorrect |
1 ms |
336 KB |
your estimate differs too much (3107 units) |
20 |
Incorrect |
0 ms |
336 KB |
your estimate differs too much (692 units) |