# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
130756 |
2019-07-16T04:37:03 Z |
임유진(#3171) |
Snake (CEOI08_snake) |
C++14 |
|
2 ms |
376 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) / 3, bm = (as + 2 * be) / 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);
be = min(be + K, hd);
ae = min(ae + K, be - 1);
}
}
tell_length((ls + le) / 2);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
too many calls of ask_snake |
2 |
Incorrect |
2 ms |
252 KB |
too many calls of ask_snake |
3 |
Incorrect |
2 ms |
376 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 |
256 KB |
too many calls of ask_snake |
8 |
Incorrect |
2 ms |
248 KB |
too many calls of ask_snake |
9 |
Partially correct |
2 ms |
376 KB |
Output is partially correct: estimate ok. 33 calls needed |
10 |
Incorrect |
2 ms |
376 KB |
too many calls of ask_snake |
11 |
Correct |
2 ms |
248 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 |
248 KB |
Output is correct: estimate ok. 9 calls needed |
14 |
Incorrect |
2 ms |
248 KB |
too many calls of ask_snake |
15 |
Incorrect |
2 ms |
252 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 |
252 KB |
too many calls of ask_snake |
19 |
Incorrect |
2 ms |
248 KB |
too many calls of ask_snake |
20 |
Incorrect |
2 ms |
376 KB |
too many calls of ask_snake |