답안 #946250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946250 2024-03-14T13:02:43 Z jakebrain88 Snake (CEOI08_snake) C++17
0 / 100
1 ms 600 KB
#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 Runtime error 0 ms 416 KB Execution killed with signal 13
2 Runtime error 0 ms 416 KB Execution killed with signal 13
3 Runtime error 0 ms 600 KB Execution killed with signal 13
4 Runtime error 0 ms 424 KB Execution killed with signal 13
5 Runtime error 0 ms 424 KB Execution killed with signal 13
6 Runtime error 0 ms 600 KB Execution killed with signal 13
7 Runtime error 0 ms 424 KB Execution killed with signal 13
8 Runtime error 0 ms 600 KB Execution killed with signal 13
9 Runtime error 0 ms 420 KB Execution killed with signal 13
10 Runtime error 0 ms 424 KB Execution killed with signal 13
11 Runtime error 0 ms 420 KB Execution killed with signal 13
12 Runtime error 0 ms 420 KB Execution killed with signal 13
13 Runtime error 0 ms 420 KB Execution killed with signal 13
14 Runtime error 0 ms 420 KB Execution killed with signal 13
15 Runtime error 0 ms 420 KB Execution killed with signal 13
16 Runtime error 0 ms 416 KB Execution killed with signal 13
17 Runtime error 0 ms 416 KB Execution killed with signal 13
18 Runtime error 0 ms 424 KB Execution killed with signal 13
19 Runtime error 0 ms 424 KB Execution killed with signal 13
20 Runtime error 1 ms 412 KB Execution killed with signal 13