답안 #130747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130747 2019-07-16T04:32:57 Z 임유진(#3171) Snake (CEOI08_snake) C++14
17.5 / 100
2 ms 504 KB
#include <stdio.h>
#include <algorithm>

using namespace std;

#include "snakelib.h"

int main() {
	const int hd = 12122;
	int K = get_speed();
	char A1, A2;
	int as = 0, ae = hd - K, bs = K, be = hd, ls = 1, le = hd;

	while(le - ls > 2 * K) {
		if(ae < bs) {
			int am = (as + ae) / 2, bm = (bs + be) / 2;
			ask_snake(am, bm, &A1, &A2);
			if(A1 == 's') ae = am;
			else as = am + 1;
			if(A2 == 's') bs = bm + 1;
			else be = bm;
		}
		else {
			int am = (2 * as + be - 1) / 3, bm = (as + 2 * be - 1) / 3;
			ask_snake(am, bm, &A1, &A2);
			if(A1 == 'f') {
				be = min(be, am);
				ae = min(ae, be - 1);
			}
			else if(A1 == 'b' && A2 == 'f') {
				as = max(as, am + 1);
				be = min(be, bm);
				ae = min(ae, be - 1);
				bs = max(bs, as + 1);
			}
			else if(A2 == 'b') {
				as = max(as, bm + 1);
				bs = max(bs, as + 1);
			}
			else {
				if(A1 == 's') {
					ae = min(ae, am);
					bs = max(bs, am + 1);
				}
				if(A2 == 's') {
					ae = min(ae, bm);
					bs = max(bs, bm + 1);
				}
			}
			ls = max(ls, bs - ae);
			le = min(le, be - as);
			ae += K;
			be += K;
		}
	}
	
	tell_length((ls + le) / 2);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 504 KB too many calls of ask_snake
2 Incorrect 2 ms 248 KB too many calls of ask_snake
3 Incorrect 2 ms 248 KB too many calls of ask_snake
4 Incorrect 2 ms 376 KB too many calls of ask_snake
5 Incorrect 2 ms 248 KB too many calls of ask_snake
6 Incorrect 2 ms 248 KB too many calls of ask_snake
7 Incorrect 2 ms 248 KB too many calls of ask_snake
8 Incorrect 2 ms 384 KB too many calls of ask_snake
9 Partially correct 2 ms 248 KB Output is partially correct: estimate ok. 20 calls needed
10 Correct 2 ms 248 KB Output is correct: estimate ok. 11 calls needed
11 Correct 2 ms 256 KB Output is correct: estimate ok. 9 calls needed
12 Incorrect 2 ms 376 KB too many calls of ask_snake
13 Correct 2 ms 376 KB Output is correct: estimate ok. 9 calls needed
14 Incorrect 2 ms 376 KB too many calls of ask_snake
15 Incorrect 2 ms 376 KB too many calls of ask_snake
16 Incorrect 2 ms 248 KB too many calls of ask_snake
17 Incorrect 2 ms 248 KB too many calls of ask_snake
18 Incorrect 2 ms 248 KB too many calls of ask_snake
19 Incorrect 2 ms 248 KB too many calls of ask_snake
20 Incorrect 2 ms 248 KB too many calls of ask_snake