Submission #487402

#TimeUsernameProblemLanguageResultExecution timeMemory
487402FatihSolakWorm Worries (BOI18_worm)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
map<vector<int>,int> mp;
,int n,m,k,q;
int ask(int x,int y,int z){
    if(x < 1 || x > n)return 0;
    if(mp[{x,y,z}])return mp[{x,y,z}]; 
    cout << "? " << x << " " << y << " " << z << endl;
    int ret;
    cin >> ret;
    return mp[{x,y,z}] = ret;
}
void ans(int x,int y,int z){
    cout << "! " << x << " " << y << " " << z << endl;
    exit(0);
}
const double golden_ratio = (sqrt(5) - 1)/2;
void solve(){
    cin >> n >> m >> k >> q;
    if(m == 1 && k == 1){
        int l = 1,r = n;
        int x = golden_ratio * l + (1-golden_ratio)*r;
        int y = golden_ratio * r + (1-golden_ratio)*l;
        while(l + 5< r){
            if(ask(x,1,1) >= ask(y,1,1)){
                r = y - 1;
                y = x;
                x = golden_ratio * l + (1-golden_ratio)*r;
            }
            else{
                l = x + 1;
                x = y;
                y = golden_ratio * r + (1-golden_ratio)*l;
            }
        }
        for(int i=l;i<=r;i++){
            if(ask(i,1,1) >= ask(i-1,1,1) && ask(i,1,1) >= ask(i+1,1,1)){
                ans(i,1,1);
            }
        }
    }
}

int32_t main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message (stderr)

worm.cpp:5:1: error: expected unqualified-id before ',' token
    5 | ,int n,m,k,q;
      | ^
worm.cpp:5:2: error: expected unqualified-id before 'int'
    5 | ,int n,m,k,q;
      |  ^~~
worm.cpp: In function 'int ask(int, int, int)':
worm.cpp:7:21: error: 'n' was not declared in this scope
    7 |     if(x < 1 || x > n)return 0;
      |                     ^
worm.cpp: In function 'void solve()':
worm.cpp:20:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   20 |     cin >> n >> m >> k >> q;
      |            ^
      |            yn
worm.cpp:20:17: error: 'm' was not declared in this scope; did you mean 'mp'?
   20 |     cin >> n >> m >> k >> q;
      |                 ^
      |                 mp
worm.cpp:20:22: error: 'k' was not declared in this scope
   20 |     cin >> n >> m >> k >> q;
      |                      ^
worm.cpp:20:27: error: 'q' was not declared in this scope
   20 |     cin >> n >> m >> k >> q;
      |                           ^