Submission #1093707

#TimeUsernameProblemLanguageResultExecution timeMemory
1093707MateiKing80Worm Worries (BOI18_worm)C++17
0 / 100
1132 ms17036 KiB
#include <bits/stdc++.h>

using namespace std;


struct cell
{
    int x, y, z;
};

bool operator <(cell a, cell b)
{
    if(a.x != b.x)
        return a.x < b.x;
    if(a.y != b.y)
        return a.y < b.y;
    return a.z < b.z;
}

cell operator +(cell a, cell b)
{
    return {a.x + b.x, a.y + b.y, a.z + b.z};
}

cell nv[6] = {{0, 0, 1}, {0, 0, -1}, {0, 1, 0}, {0, -1, 0}, {1, 0, 0}, {-1, 0, 0}};

map<cell, int> mp;

int n, m, k, q;

int ask(cell x)
{
    if(x.x <= 0 || x.x > n || x.y <= 0 || x.y > m || x.z <= 0 || x.z > k)
        return 0;
    if(mp[x] != 0)
        return mp[x];
    cout << "? " << x.x << " " << x.y << " " << x.z << endl;
    int ans = 0;
    cin >> ans;
    mp[x] = ans;
    return ans;
}

void respond(cell x)
{
    cout << "! " << x.x << " " << x.y << " " << x.z << endl;
    exit(0);
}

void dfs(cell x)
{
    random_shuffle(nv, nv + 6);
    for(int i = 0; i < 6; i ++)
        if(ask(x) < ask(nv[i] + x))
            dfs(nv[i] + x);
    respond(x);
}

int main()
{
    cin >> n >> m >> k >> q;
    cell x = {(n + 1) / 2, (m + 1) / 2, (k + 1) / 2};
    dfs(x);
}
#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...