답안 #288216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288216 2020-09-01T10:16:21 Z Kastanda Aliens (IOI07_aliens) C++11
60 / 100
2 ms 368 KB
// M
#include<bits/stdc++.h>
using namespace std;
int n, m, nwx, nwy;
int main()
{
        scanf("%d%d%d", &n, &nwx, &nwy);

        auto Query = [&](int a, int b){
                if (a < 1 || a > n || b < 1 || b > n)
                        return false;
                printf("examine %d %d\n", a, b);
                fflush(stdout);
                char ss[7];
                scanf("%s", ss);
                return (bool)(ss[0] == 't');
        };

        {
                int lg = 0;
                while (Query(nwx - (1 << lg), nwy))
                        lg ++;
                int left_gap = 0;
                for (int i = lg - 1; i >= 0; i --)
                        if (Query(nwx - left_gap - (1 << i), nwy))
                                left_gap |= 1 << i;

                lg = 0;
                while (Query(nwx + (1 << lg), nwy))
                        lg ++;
                int right_gap = 0;
                for (int i = lg - 1; i >= 0; i --)
                        if (Query(nwx + right_gap + (1 << i), nwy))
                                right_gap |= 1 << i;

                m = right_gap + left_gap + 1;
                nwx -= left_gap;

                lg = 0;
                while (Query(nwx, nwy - (1 << lg)))
                        lg ++;
                int up_gap = 0;
                for (int i = lg - 1; i >= 0; i --)
                        if (Query(nwx, nwy - up_gap - (1 << i)))
                                up_gap |= 1 << i;

                nwy -= up_gap;

                int cx = 0, cy = 0;
                while (Query(nwx - m * (cx + 2), nwy))
                        cx += 2;
                if (Query(nwx - m * cx - m, nwy - m))
                        cx ++, cy ++;

                while (Query(nwx, nwy - m * (cy + 2)))
                        cy += 2;

                nwx -= m * cx;
                nwy -= m * cy;

                nwx += m * 2 + m / 2;
                nwy += m * 2 + m / 2;
                printf("solution %d %d\n", nwx, nwy);
          		fflush(stdout);
        }
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |         scanf("%d%d%d", &n, &nwx, &nwy);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
aliens.cpp: In lambda function:
aliens.cpp:15:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |                 scanf("%s", ss);
      |                 ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Incorrect
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 368 KB Incorrect