# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
54303 |
2018-07-03T06:30:51 Z |
김세빈(#1473) |
Aliens (IOI07_aliens) |
C++11 |
|
2 ms |
508 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
ll ans_x, ans_y, ans_sz;
bool yeah(ll x, ll y)
{
if(x < ans_x - ans_sz/2 - ans_sz*2 || x > ans_x + ans_sz/2 + ans_sz*2) return 0;
if(y < ans_y - ans_sz/2 - ans_sz*2 || y > ans_y + ans_sz/2 + ans_sz*2) return 0;
x = (x - ans_x + ans_sz/2 + ans_sz*2) / ans_sz;
y = (y - ans_y + ans_sz/2 + ans_sz*2) / ans_sz;
return (x + y + 1) % 2;
}
bool check(ll x, ll y)
{
ll ret;
if(x > n || x < 1 || y > n || y < 1) return 0;
printf("examine %lld %lld\n", x, y);
fflush(stdout);
scanf("%lld",&ret);
// return yeah(x, y);
return ret;
}
int f(ll x, ll y)
{
ll s, e, mid;
ll x1, x2, y1, y2;
// scanf("%lld%lld%lld", &n, &x, &y);
for(s=x,e=n;s<=e;){
mid = s+e >> 1;
if(check(mid, y) && check((x + mid*2) / 3, y) && check((x*2 + mid) / 3, y)) s = mid + 1;
else e = mid-1;
}
x2 = s - 1;
for(s=1,e=x;s<=e;){
mid = s+e >> 1;
if(check(mid, y) && check((x + mid*2) / 3, y) && check((x*2 + mid) / 3, y)) e = mid - 1;
else s = mid + 1;
}
x1 = e + 1;
if(y <= n-y){
for(s=1,e=y;s<=e;){
mid = s+e >> 1;
if(check(x, mid) && check(x, (y + mid*2) / 3) && check(x, (y*2 + mid) / 3)) e = mid - 1;
else s = mid + 1;
}
y1 = e + 1;
y2 = x2 - x1 + y1;
}
else{
for(s=1,e=y;s<=e;){
mid = s+e >> 1;
if(check(x, mid) && check(x, (y + mid*2) / 3) && check(x, (y*2 + mid) / 3)) s = mid + 1;
else e = mid - 1;
}
y2 = s - 1;
y1 = y2 - x2 + x1;
}
m = x2 - x1 + 1;
x = (x2 + x1) / 2, y = (y2 + y1) / 2;
if(check(x - m*2, y)){
if(check(x - m*3, y - m)){
if(check(x - m*3, y - m*3)){
if(check(x - m*4, y - m*4)) x -= m*2, y -= m*2;
else x -= m, y -= m;
}
else{
if(check(x - m*4, y - m*2)) x -= m*2;
else x -= m, y += m;
}
}
else{
if(check(x - m*2, y - m*2)){
if(check(x - m*2, y - m*4)) y -= m*2;
}
else{
if(check(x, y - m*4)) x -= m*2, y += m*2;
else y += m*2;
}
}
}
else{
if(check(x, y - m*2)){
if(check(x - m, y - m*3)) x += m, y -= m;
else if(check(x, y - m*4)) x += m*2, y -= m*2;
else x += m*2;
}
else{
if(check(x - m, y - m)) x += m, y += m;
else x += m*2, y += m*2;
}
}
printf("solution %lld %lld\n", x, y);
return 0;
}
int main()
{
ll x, y;
scanf("%lld", &n);
// scanf("%lld%lld%lld", &ans_x, &ans_y, &ans_sz);
scanf("%lld%lld", &x, &y);
f(x, y);
return 0;
}
Compilation message
aliens.cpp: In function 'int f(ll, ll)':
aliens.cpp:46:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
mid = s+e >> 1;
~^~
aliens.cpp:54:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
mid = s+e >> 1;
~^~
aliens.cpp:63:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
mid = s+e >> 1;
~^~
aliens.cpp:73:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
mid = s+e >> 1;
~^~
aliens.cpp: In function 'bool check(ll, ll)':
aliens.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&ret);
~~~~~^~~~~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:127:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &n);
~~~~~^~~~~~~~~~~~
aliens.cpp:129:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &x, &y);
~~~~~^~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
308 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
308 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
308 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
432 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
Expected int32, but "4999999988" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
508 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |