답안 #678879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
678879 2023-01-06T20:21:33 Z Hacv16 Aliens (IOI07_aliens) C++17
0 / 100
4 ms 308 KB
#include<bits/stdc++.h>
using namespace std;

const int MAX = 1e6 + 15;

int n, x, y, m, numblock;
map<pair<int, int>, bool> memo;

bool query(int x, int y){
    if(memo.find({x, y}) != memo.end()) return memo[{x, y}];
    cout << "examine " << x << ' ' << y << '\n'; cout.flush();

    string ans; cin >> ans;
    return memo[{x, y}] = (ans == "true");
}

bool check(int x){ return x > 0 && x < n ;}

int main(){
    cin >> n >> x >> y;

    int up = y, down = y;

    while(check(up + 1) && query(x, up + 1)) up++;
    while(check(down - 1) && query(x, down - 1)) down--;

    m = up - down + 1;
    while(x - 1 > 0 && query(x - 1, up)) x--;

    int l = 0, r = 3 * n / m, curx = x, cury = up, jump = 0;

    //Pula diagonal
    while(l <= r){
        int mid = (l + r) >> 1;
        int nx = curx + m * mid, ny = cury + m * mid;
        if(!check(nx) || !check(ny)){ r = mid - 1; continue; }
        if(query(nx, ny)) l = mid + 1, jump = mid;
        else r = mid - 1;
    }   

    curx += jump * m;
    cury += jump * m;

    //cerr << curx << ' ' << cury << '\n';

    l = 0, r = ((n + m - 1)/ m), jump = 0;

    //Pula cima
    while(l <= r){
        int mid = (l + r) >> 1;
        int ny = cury + m * (2 * mid);
        if(!check(ny)) { r = mid - 1; continue; }
        if(query(curx, ny)) l = mid + 1, jump = 2 * mid;
        else r = mid - 1;
    }

    cury += jump * m;

    //Pula esquerda
    l = 0, r = ((n + m - 1)/ m), jump = 0;

    while(l <= r){
        int mid = (l + r) >> 1;
        int nx = curx - m * (2 * mid);
        if(!check(nx)){ r = mid - 1; continue; }
        if(query(nx, cury)) l = mid + 1, jump = 2 * mid;
        else r = mid - 1;
    }

    curx -= jump * m;
    
    //move to center of current block
    curx += (m - 1) / 2;
    cury -= (m - 1) / 2;
    
    //move to center block
    int auxX = curx, auxY = cury;
    l = 0, r = ((n + m - 1) / m), jump = 0;

    while(l <= r){
        int mid = (l + r) >> 1;
        int nx = curx + m * (2 * mid);
        if(!check(nx)){ r = mid - 1; continue; }
        if(query(nx, cury)) l = mid + 1, jump = 2 * mid;
        else r = mid - 1;
    }

    numblock = jump + 1;

    curx += ((numblock - 1) / 2) * m;
    cury -= ((numblock - 1) / 2) * m;
    
    cout << curx << ' ' << cury << '\n';
    
    return 0;
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:77:9: warning: unused variable 'auxX' [-Wunused-variable]
   77 |     int auxX = curx, auxY = cury;
      |         ^~~~
aliens.cpp:77:22: warning: unused variable 'auxY' [-Wunused-variable]
   77 |     int auxX = curx, auxY = cury;
      |                      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 292 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 308 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -