Submission #867633

# Submission time Handle Problem Language Result Execution time Memory
867633 2023-10-29T02:43:54 Z josanneo22 Aliens (IOI07_aliens) C++17
100 / 100
1 ms 600 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--)

ll 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\n", x, y);
    fflush(stdout);
    char s[10]; scanf("%s", s);
    return (*s == 't');
}
int main() {
    scanf("%lld %lld %lld", &n, &x, &y);
    vector<ll> 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) & 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);
            fflush(stdout);
            return 0;
        }
    }
}

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: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:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%lld %lld %lld", &n, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct