Submission #542614

#TimeUsernameProblemLanguageResultExecution timeMemory
542614OttoTheDinoWorm Worries (BOI18_worm)C++17
0 / 100
528 ms300 KiB
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define rrep(i,s,e)                 for (int i = s; i >= e; --i)
#define pb                          push_back
#define pf                          push_front
#define fi                          first
#define se                          second
#define all(a)                      a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;

vi d6[6] = {{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}};

int qry (int x, int y, int z) {
    cout << "? " << x << " " << y << " " << z << endl;
    int res; cin >> res;
    return res;
}

int rand (int a, int b) {
    return a + rand() % (b-a+1);
}

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

    srand(128);

    int n, m, k, q; cin >> n >> m >> k >> q;

    if (n>1 && m>1) {
        int best = 0, a = 0, b = 0, c = 0;
        rep (i,1,q/2) {
            int x = rand(1,n), y = rand(1,m), z = rand(1,k);
            int res = qry (x, y, z);
            if (res>best) {
                best = res;
                a = x, b = y, c = z;
            }
        }
        int cnt = 0;
        while (true) {
            bool hap = 0;
            rep (i,0,5) {
                int na = a + d6[i][0];
                int nb = b + d6[i][1];
                int nc = c + d6[i][2];
                int res = qry (na, nb, nc);
                if (++cnt>q/2) {
                    cout << "! " << a << " " << b << " " << c << endl;
                    return 0;
                }
                if (res > best) {
                    best = res;
                    hap = 1;
                    a = na;
                    b = nb;
                    c = nc;
                    break;
                }
            }
            if (!hap) {
                cout << "! " << a << " "<< b << " " << c << endl;
                break;
            }
        }
    }

    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...