# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
130896 |
2019-07-16T08:20:52 Z |
이온조(#3169) |
Snake (CEOI08_snake) |
C++14 |
|
2 ms |
380 KB |
#include "snakelib.h"
#include <bits/stdc++.h>
using namespace std;
const bool DBG = 0;
int K;
char a1, a2;
void norm(int &x) {
x = min(x, 12121);
x = max(x, 0);
}
void ask(int a, int b, char *A1, char *A2) {
norm(a); norm(b);
if(DBG) {
printf("a: %d, b: %d\n", a, b);
char c, d;
scanf(" %c %c", &c, &d);
*A1 = c; *A2 = d;
}
else ask_snake(a, b, A1, A2);
}
void tell(int l) {
if(DBG) printf("my answer: %d\n", l);
else tell_length(l);
}
int main() {
srand(14345);
if(DBG) scanf("%d",&K);
else K = get_speed();
ask(4040, 8080, &a1, &a2);
if(DBG) printf("recieved %c %c\n", a1, a2);
int l1, r1, l2, r2;
if(a1 == 'f' || a1 == 's') l1 = 0, r1 = 4040;
else if(a2 == 'f' || a2 == 's') l1 = 4041, r1 = 8080;
else l1 = 8081, r1 = 12121;
if(a2 == 'b' || a2 == 's') l2 = 8080, r2 = 12121;
else if(a1 == 'b' || a1 == 's') l2 = 4040, r2 = 8079;
else l2 = 0, r2 = 4039;
double p1 = ((double)K / 13.0) * 0.12 + 0.5;
double p2 = ((double)K / 13.0) * 0.01;
int cnt = 13;
while(--cnt) {
int m1 = l1+r1 >> 1, m2 = l2+r2+1 >> 1;
if(r1-l1 > 10) m1 = l1 + (int)(p1*(r1-l1) + p2*(r1-l1));
if(r2-l2 > 10) m2 = l2 + (int)(p1*(r2-l2) + p2*(r2-l2));
if(DBG) printf("[%d, %d], [%d, %d]\n", l1, r1, l2, r2);
ask(m1, m2, &a1, &a2);
if(a1 == 's' || a1 == 'f') r1 = m1;
else l1 = m1 + 1, r1 += K;
if(a2 == 's' || a2 == 'b') l2 = m2, r2 += K;
else r2 = m2 - 1;
norm(l1); norm(r1);
norm(l2); norm(r2);
}
tell(r2-r1 + l2-l1 + 2 >> 1);
return 0;
}
Compilation message
snake.cpp: In function 'int main()':
snake.cpp:51:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m1 = l1+r1 >> 1, m2 = l2+r2+1 >> 1;
~~^~~
snake.cpp:51:34: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m1 = l1+r1 >> 1, m2 = l2+r2+1 >> 1;
~~~~~^~
snake.cpp:63:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
tell(r2-r1 + l2-l1 + 2 >> 1);
~~~~~~~~~~~~~~^~~
snake.cpp: In function 'void ask(int, int, char*, char*)':
snake.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c %c", &c, &d);
~~~~~^~~~~~~~~~~~~~~~~~
snake.cpp: In function 'int main()':
snake.cpp:33:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
if(DBG) scanf("%d",&K);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct: estimate ok. 13 calls needed |
2 |
Incorrect |
2 ms |
248 KB |
your estimate differs too much (7 units) |
3 |
Correct |
2 ms |
252 KB |
Output is correct: estimate ok. 13 calls needed |
4 |
Correct |
2 ms |
376 KB |
Output is correct: estimate ok. 13 calls needed |
5 |
Incorrect |
2 ms |
376 KB |
your estimate differs too much (9 units) |
6 |
Correct |
2 ms |
376 KB |
Output is correct: estimate ok. 13 calls needed |
7 |
Incorrect |
2 ms |
248 KB |
your estimate differs too much (2 units) |
8 |
Incorrect |
2 ms |
248 KB |
your estimate differs too much (3 units) |
9 |
Incorrect |
2 ms |
376 KB |
your estimate differs too much (4 units) |
10 |
Incorrect |
2 ms |
296 KB |
your estimate differs too much (5 units) |
11 |
Incorrect |
2 ms |
380 KB |
your estimate differs too much (6 units) |
12 |
Correct |
2 ms |
376 KB |
Output is correct: estimate ok. 13 calls needed |
13 |
Incorrect |
2 ms |
248 KB |
your estimate differs too much (8 units) |
14 |
Correct |
2 ms |
248 KB |
Output is correct: estimate ok. 13 calls needed |
15 |
Correct |
2 ms |
248 KB |
Output is correct: estimate ok. 13 calls needed |
16 |
Correct |
2 ms |
248 KB |
Output is correct: estimate ok. 13 calls needed |
17 |
Correct |
2 ms |
248 KB |
Output is correct: estimate ok. 13 calls needed |
18 |
Correct |
2 ms |
248 KB |
Output is correct: estimate ok. 13 calls needed |
19 |
Correct |
2 ms |
376 KB |
Output is correct: estimate ok. 13 calls needed |
20 |
Correct |
2 ms |
376 KB |
Output is correct: estimate ok. 13 calls needed |