Submission #1127308

#TimeUsernameProblemLanguageResultExecution timeMemory
1127308LudisseyWorm Worries (BOI18_worm)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
using namespace std;
vector<int> a;
map<pair<int,pair<int,int>>,int> req;
int n,m,k,q; 

int ask(int x, int y, int z){
    if(req.find({x,{y,z}})!=req.end()) return req[{x,{y,z}}];
    if(x<0||x>=n||y<0||y>=m||z<0||z>=k) return -1e9;
    q--;
    while(q<0) {
        
    }
    cout << "? " << x+1 << " " << y+1 << " " << z+1 << endl;
    int ans; cin>>ans;
    req[{x,{y,z}}]=ans;
    return ans;
}

void give_ans(int x, int y, int z){
    cout << "! " << x+1 << " " << y+1 << " " << z+1 << endl;
    return;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> m >> k >> q;
    int l=0; int r=n-1;
    int ans=0;
    int midc=ask((l+r+1)/2,0,0);
    int midl=ask((l+r+1)/2-1,0,0);
    if(midc<midl){
        last=midl;
        ans=(l+r+1)/2-1;
        r=(l+r+1)/2-1;
    }else{
        last=midc;
        ans=(l+r+1)/2-1;
        l=(l+r+1)/2;
    }
    while(l<r){
        int mid=(l+r+1)/2;
        int midANS=ask(mid,0,0);
        int midANS2=ask(mid-1,0,0);
        if(midANS>=midANS2){
            ans=mid;
            l=mid;
        }else{
            r=mid-1;
            ans=mid-1;
        }
        last=midANS;
    }
    give_ans(ans,0,0);
    return 0;
}

Compilation message (stderr)

worm.cpp: In function 'int main()':
worm.cpp:35:9: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   35 |         last=midl;
      |         ^~~~
      |         std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:101,
                 from worm.cpp:1:
/usr/include/c++/11/chrono:1276:32: note: 'std::chrono::last' declared here
 1276 |     inline constexpr last_spec last{};
      |                                ^~~~
worm.cpp:39:9: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   39 |         last=midc;
      |         ^~~~
      |         std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:101,
                 from worm.cpp:1:
/usr/include/c++/11/chrono:1276:32: note: 'std::chrono::last' declared here
 1276 |     inline constexpr last_spec last{};
      |                                ^~~~
worm.cpp:54:9: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   54 |         last=midANS;
      |         ^~~~
      |         std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:101,
                 from worm.cpp:1:
/usr/include/c++/11/chrono:1276:32: note: 'std::chrono::last' declared here
 1276 |     inline constexpr last_spec last{};
      |                                ^~~~