Submission #679105

# Submission time Handle Problem Language Result Execution time Memory
679105 2023-01-07T13:18:29 Z Hacv16 Aliens (IOI07_aliens) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
int n, x, y, m, numblock;
map<pair<int, int>, bool> mt;
 
bool check(int x){ return x > 0 && x <= n ;}

bool query(int x, int y){
    if(mt.find({x, y}) != mt.end()) return mt[{x, y}];
    if(!check(x) || !check(y)) return false;
    cout << "examine " << x << ' ' << y << '\n'; cout.flush();
    string ans; cin >> ans; return mt[{x, y}] = (ans == "true");
}

pair<int, int> findCenter(int x, int y, int m){
    int l = 0, r = 2 * n / m, curx = x, cury = y, jump = 0;
 
    while(l <= r){
        int mid = (l + r) >> 1;
        int nx = curx + m * mid, ny = cury + m * mid;
        if(query(nx, ny)) l = mid + 1, jump = mid;
        else r = mid - 1;
    }   
 
    curx += jump * m;
    cury += jump * m;
 
    l = 0, r = ((n + m - 1) / m), jump = 0;
 
    while(l <= r){
        int mid = (l + r) >> 1;
        int ny = cury + m * (2 * mid);
        if(query(curx, ny)) l = mid + 1, jump = 2 * mid;
        else r = mid - 1;
    }
 
    cury += jump * m;
 
    l = 0, r = ((n + m - 1)/ m), jump = 0;
 
    while(l <= r){
        int mid = (l + r) >> 1;
        int nx = curx - m * (2 * mid);
        if(query(nx, cury)) l = mid + 1, jump = 2 * mid;
        else r = mid - 1;
    }
 
    curx -= jump * m;

    curx += (m - 1) / 2;
    cury -= (m - 1) / 2;

    l = 0, r = ((n + m - 1) / m), jump = 0;
 
    while(l <= r){
        int mid = (l + r) >> 1;
        int nx = curx + m * (2 * mid);
        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;
    
    return {curx, cury};
}

pair<int, int> getPos(int x, int y, int dx, int dy){
    int pw = 0;

    for(int i = 0; i < 31; i++)
        if(!query(x + dx * (1 << i), y + dy * (1 << i))){ pw = i; break; }

    if(dx == 0 && dy == 1){
        int l = y, r = min(n, y + (1 << pw));

        while(l <= r){
            int mid = (l + r) >> 1;
            if(query(x, mid)) l = mid + 1;
            else r = mid - 1;
        }

        return {x, max(y, l - 1)};

    }else if(dx == 0 && dy == -1){
        int l = max(1, y - pw), r = y;

        while(l <= r){
            int mid = (l + r) >> 1;
            if(query(x, mid)) r = mid - 1;
            else l = mid + 1;
        }

        return {x, min(y, r + 1)};

    }else{
        int l = max(1, x - pw), r = x;

        while(l <= r){
            int mid = (l + r) >> 1;
            if(query(mid, y)) r = mid - 1;
            else l = mid + 1;
        }
        return {min(x, r + 1), y};
    }

    return {x, y};
}
 
int main(){
    cin >> n >> x >> y;

    pair<int, int> top = getPos(x, y, 0, 1);
    pair<int, int> bot = getPos(x, y, 0, -1);
    pair<int, int> lef = getPos(x, y, -1, 0);

    int m = top.second - bot.second + 1, cury = top.second, curx = lef.frist;

    pair<int, int> resp = findCenter(curx, cury, m);

    cout << "solution " << resp.first << ' ' << resp.second << '\n';

    exit(0);
}

Compilation message

aliens.cpp: In function 'int main()':
aliens.cpp:120:72: error: 'struct std::pair<int, int>' has no member named 'frist'; did you mean 'first'?
  120 |     int m = top.second - bot.second + 1, cury = top.second, curx = lef.frist;
      |                                                                        ^~~~~
      |                                                                        first