답안 #302871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
302871 2020-09-19T11:03:45 Z Akashi Aliens (IOI07_aliens) C++14
0 / 100
1 ms 288 KB
#include <bits/stdc++.h>
using namespace std;

int n, x, y;
char s[15];

bool ask(int x, int y) {
    if (x <= 0 || y <= 0 || x > n || y > n) return false;
    bool ok = false;

    printf("examine %d %d\n", x, y);
    scanf("%s", s);
    if (s[0] == 't') ok = true;

    return ok;
}

void found(int x, int y) {
    printf("solution %d %d\n", x, y);
}

int find_dir(int x, int y, int sgn) {
    int wh = 0;
    for (int bit = 1; bit <= n ; bit = bit << 1) {
        bool ok = ask(x + bit * sgn, y);
        if (!ok) {wh = bit >> 1; break ;}
    }

    if (wh == 0) return 0;

    int ans = 0;
    for (int bit = wh; bit >= 1 ; bit = bit >> 1) {
        bool ok = ask(x + bit * sgn, y);
        if (ok) x += (bit * sgn), ans = ans + bit;
    }

    return ans;
}

void corect(int &x, int &y, int m) {
    while (x > 0) {
        bool ok = ask(x - m, y);
        if (ok) x -= m;
        else break ;
    }

    while (y > 0) {
        bool ok = ask(x, y - m);
        if (ok) y -= m;
        else break ;
    }

    for (int bit = (1 << 30); bit >= 1 ; bit = bit >> 1) {
        bool ok = ask(x - bit, y);
        if (ok) x -= bit;
    }

    for (int bit = (1 << 30); bit >= 1 ; bit = bit >> 1) {
        bool ok = ask(x, y - bit);
        if (ok) y -= bit;
    }
}

int main() {
    scanf("%d%d%d", &n, &x, &y);

    int up = find_dir(x, y, -1);
    int down = find_dir(x, y, 1);

    int m = up + down + 1;

    corect(x, y, m);

    found(x + 2 * m + m / 2, y + 2 * m + m / 2);

    return 0;
}











Compilation message

aliens.cpp: In function 'bool ask(int, int)':
aliens.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~
aliens.cpp: In function 'int main()':
aliens.cpp:65:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |     scanf("%d%d%d", &n, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 288 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -