제출 #440886

#제출 시각아이디문제언어결과실행 시간메모리
440886Haruto810198Worm Worries (BOI18_worm)C++17
10 / 100
1630 ms992432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d)) #define szof(x) ((int)(x).size()) #define vi vector<int> #define pii pair<int,int> #define pb push_back #define eb emplace_back #define mkp make_pair const int INF = 2147483647; const int LNF = INF*INF; const int MOD = 1000000007; const int mod = 998244353; //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") int X, Y, Z; int Q; vector<vector<vi>> arr; int query(int x, int y, int z){ int ret; if(x<=0 or x>=X+1 or y<=0 or y>=Y+1 or z<=0 or z>=Z+1){ return 0; } if(arr[x][y][z] == 0){ cout<<"? "<<x<<" "<<y<<" "<<z<<endl; cin>>ret; arr[x][y][z] = ret; } else{ ret = arr[x][y][z]; } return ret; } int solve_1D(int y, int z){ int xl = 0, xr = X+1, xm1, xm2; while(xl + 3 <= xr){ xm1 = (xl + xl + xr) / 3; xm2 = (xl + xr + xr) / 3; int vl = query(xl, y, z); int vm1 = query(xm1, y, z); int vm2 = query(xm2, y, z); int vr = query(xr, y, z); if(max(vl, vm1) >= max(vm2, vr)){ xr = xm2; if(query(xm1, y, z) <= query(xm1 + 1, y, z)){ xl = xm1 + 1; } else{ xr = xm1; } } else{ xl = xm1; if(query(xm2, y, z) <= query(xm2 + 1, y, z)){ xl = xm2 + 1; } else{ xr = xm2; } } } FOR(i, xl, xr, 1){ if( query(i-1, y, z) <= query(i, y, z) and query(i, y, z) >= query(i+1, y, z) ){ return i; } } return -1; } signed main(){ //ios_base::sync_with_stdio(false); //cin.tie(0); //cout.tie(0); cin>>X>>Y>>Z>>Q; arr.resize(X + 1); for(auto& i : arr){ i.resize(Y + 1); for(auto& j : i){ j.resize(Z + 1); } } int res = solve_1D(1, 1); cout<<"! "<<res<<" 1 1"<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...