답안 #964618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964618 2024-04-17T08:17:30 Z steveonalex Aliens (IOI07_aliens) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
 
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}
 
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
 
ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}
 
template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b){a = b; return true;}
        return false;
    }
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b){a = b; return true;}
        return false;
    }
template <class T>
    void printArr(T& a, string separator = " ", string finish = "\n", ostream& out = cout){
        for(auto i: a) out << i << separator;
        out << finish;
    }
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

const int LOG_N = 31;

int examine(ll x, ll y){
    if (x < 1 || x > n || y < 1 || y > n) return 0;
    cout << "examine " << x << " " << y << endl;
    string verdict; cin >> verdict;
    return verdict == "true";
}

void solution(ll x, ll y){
    cout << "solution " << x << " " << y << endl;
    exit(0);
}

int binary_lift_descent(function<int(int)> f){
    if (f(1) == 0) return 0;
    int j = 0;
    for(; j < LOG_N; ++j) {
        if (f(MASK(j)) == false){
            j--;
            break;
        }
    }
    int ans = MASK(j);
    while(j--){
        if (f(ans + MASK(j))) ans += MASK(j);
    }
    return ans;
}

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n, x1, y1;
    cin >> n >> x1 >> y1;

    ll xL, xR, yL, yR, block_sz;
    xR = binary_lift_descent([](int x){return examine(x1 + x, y1);});
    xL = binary_lift_descent([](int x){return examine(x1 - x, y1);});
    block_sz = xR - xL + 1;
    yL = binary_lift_descent([](int x){return examine(x1, y1 - x);});
    yR = yL + block_sz - 1;

    ll x1 = (xL + xR) / 2, y1 = (yL + yR) / 2;
    for(int i = -4; i<=4; ++i) for(int j = -4; j<=4; ++j) if ((i + j) % 2 == 0){
        if (examine(x1 + i * block_sz, y1 + j * block_sz)) {
            minimize(xL, x1 + i * block_sz);
            minimize(yL, y1 + j * block_sz);
            maximize(xR, x1 + i * block_sz);
            maximize(yR, y1 + j * block_sz);
        }
    } 

    x1 = (xL + xR) / 2, y1 = (yL + yR) / 2;
    solution(x1, y1);

    return 0;
}

Compilation message

aliens.cpp: In function 'int examine(ll, ll)':
aliens.cpp:49:22: error: 'n' was not declared in this scope
   49 |     if (x < 1 || x > n || y < 1 || y > n) return 0;
      |                      ^
aliens.cpp: In lambda function:
aliens.cpp:83:55: error: 'x1' is not captured
   83 |     xR = binary_lift_descent([](int x){return examine(x1 + x, y1);});
      |                                                       ^~
aliens.cpp:83:31: note: the lambda has no capture-default
   83 |     xR = binary_lift_descent([](int x){return examine(x1 + x, y1);});
      |                               ^
aliens.cpp:79:11: note: 'll x1' declared here
   79 |     ll n, x1, y1;
      |           ^~
aliens.cpp:83:63: error: 'y1' is not captured
   83 |     xR = binary_lift_descent([](int x){return examine(x1 + x, y1);});
      |                                                               ^~
aliens.cpp:83:31: note: the lambda has no capture-default
   83 |     xR = binary_lift_descent([](int x){return examine(x1 + x, y1);});
      |                               ^
aliens.cpp:79:15: note: 'll y1' declared here
   79 |     ll n, x1, y1;
      |               ^~
aliens.cpp: In function 'int main()':
aliens.cpp:83:68: error: could not convert '<lambda closure object>main()::<lambda(int)>{}' from 'main()::<lambda(int)>' to 'std::function<int(int)>'
   83 |     xR = binary_lift_descent([](int x){return examine(x1 + x, y1);});
      |                                                                    ^
      |                                                                    |
      |                                                                    main()::<lambda(int)>
aliens.cpp: In lambda function:
aliens.cpp:84:55: error: 'x1' is not captured
   84 |     xL = binary_lift_descent([](int x){return examine(x1 - x, y1);});
      |                                                       ^~
aliens.cpp:84:31: note: the lambda has no capture-default
   84 |     xL = binary_lift_descent([](int x){return examine(x1 - x, y1);});
      |                               ^
aliens.cpp:79:11: note: 'll x1' declared here
   79 |     ll n, x1, y1;
      |           ^~
aliens.cpp:84:63: error: 'y1' is not captured
   84 |     xL = binary_lift_descent([](int x){return examine(x1 - x, y1);});
      |                                                               ^~
aliens.cpp:84:31: note: the lambda has no capture-default
   84 |     xL = binary_lift_descent([](int x){return examine(x1 - x, y1);});
      |                               ^
aliens.cpp:79:15: note: 'll y1' declared here
   79 |     ll n, x1, y1;
      |               ^~
aliens.cpp: In function 'int main()':
aliens.cpp:84:68: error: could not convert '<lambda closure object>main()::<lambda(int)>{}' from 'main()::<lambda(int)>' to 'std::function<int(int)>'
   84 |     xL = binary_lift_descent([](int x){return examine(x1 - x, y1);});
      |                                                                    ^
      |                                                                    |
      |                                                                    main()::<lambda(int)>
aliens.cpp: In lambda function:
aliens.cpp:86:55: error: 'x1' is not captured
   86 |     yL = binary_lift_descent([](int x){return examine(x1, y1 - x);});
      |                                                       ^~
aliens.cpp:86:31: note: the lambda has no capture-default
   86 |     yL = binary_lift_descent([](int x){return examine(x1, y1 - x);});
      |                               ^
aliens.cpp:79:11: note: 'll x1' declared here
   79 |     ll n, x1, y1;
      |           ^~
aliens.cpp:86:59: error: 'y1' is not captured
   86 |     yL = binary_lift_descent([](int x){return examine(x1, y1 - x);});
      |                                                           ^~
aliens.cpp:86:31: note: the lambda has no capture-default
   86 |     yL = binary_lift_descent([](int x){return examine(x1, y1 - x);});
      |                               ^
aliens.cpp:79:15: note: 'll y1' declared here
   79 |     ll n, x1, y1;
      |               ^~
aliens.cpp: In function 'int main()':
aliens.cpp:86:68: error: could not convert '<lambda closure object>main()::<lambda(int)>{}' from 'main()::<lambda(int)>' to 'std::function<int(int)>'
   86 |     yL = binary_lift_descent([](int x){return examine(x1, y1 - x);});
      |                                                                    ^
      |                                                                    |
      |                                                                    main()::<lambda(int)>
aliens.cpp:89:8: error: redeclaration of 'll x1'
   89 |     ll x1 = (xL + xR) / 2, y1 = (yL + yR) / 2;
      |        ^~
aliens.cpp:79:11: note: 'll x1' previously declared here
   79 |     ll n, x1, y1;
      |           ^~
aliens.cpp:89:28: error: redeclaration of 'll y1'
   89 |     ll x1 = (xL + xR) / 2, y1 = (yL + yR) / 2;
      |                            ^~
aliens.cpp:79:15: note: 'll y1' previously declared here
   79 |     ll n, x1, y1;
      |               ^~