답안 #867626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867626 2023-10-29T02:36:23 Z josanneo22 Aliens (IOI07_aliens) C++17
0 / 100
1 ms 344 KB
#pragma warning(disable : 4996)
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
#define L(i,j,k) for(int i=(j);i<=(k);i++)
#define R(i,j,k) for(int i=(j);i>=(k);i--)

int n, x, y;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
bool ask(ll x, ll y) {
    if (x <= 0 || x >= n + 1 || y <= 0 || y >= n + 1) return false;
    printf("examine %lld %lld", x, y);
    fflush(stdout);
    char s[10]; scanf("%s", &s);
    return (*s == 't');
}
void find_centre(int N, int X, int Y) {
    n = N; x = X; y = Y;
    int lim[4];
    L(i, 0, 3) L(j, 0, 30) {
        if (!ask(x + dx[i] * (1ll << j), y + dy[i] * (1ll << j))) {
            ll l = (j ? (1ll << (j - 1)) : 0);
            ll r = (1ll << j);
            while (l < r) {
                ll mid = (l + r + 1) >> 1;
                if (ask(x + mid * dx[i], y + mid * dy[i])) l = mid;
                else r = mid - 1;
            }
            lim[i] = l;
            break;
        }
    }
    x = x + (lim[0] - lim[2]) / 2;
    y = y + (lim[1] - lim[3]) / 2;
    ll sz = (lim[0] + lim[2] + 1);
    int lu = 0, ld = 0, ru = 0, rd = 0;
    while (ask(x - sz * (lu + 1), y - sz * (lu + 1))) lu++;
    while (ask(x - sz * (ld + 1), y + sz * (ld + 1))) ld++;
    while (ask(x + sz * (ru + 1), y - sz * (ru + 1))) ru++;
    while (ask(x + sz * (rd + 1), y + sz * (rd + 1))) rd++;
    L(i, -2, 2) L(j, -2, 2) {
        if ((i + j) % 2 == 1) continue;
        int tlu = min(i + 2, j + 2);
        int tld = min(i + 2, 2 - j);
        int tru = min(2 - i, j + 2);
        int trd = min(2 - i, 2 - j);
        if (tie(tlu, tld, tru, trd) == make_tuple(lu, ld, ru, rd)) {
            printf("solution %lld %lld\n", x - sz * i, y - sz * j);
            return;
        }
    }
}
int main() {
    int N, X, Y; scanf("%d %d %d", &N, &X, &Y);
    find_centre(N, X, Y);
}

Compilation message

aliens.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    1 | #pragma warning(disable : 4996)
      | 
aliens.cpp: In function 'bool ask(ll, ll)':
aliens.cpp:15:25: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[10]' [-Wformat=]
   15 |     char s[10]; scanf("%s", &s);
      |                        ~^   ~~
      |                         |   |
      |                         |   char (*)[10]
      |                         char*
aliens.cpp:15:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     char s[10]; scanf("%s", &s);
      |                 ~~~~~^~~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:55:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     int N, X, Y; scanf("%d %d %d", &N, &X, &Y);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -