제출 #1345626

#제출 시각아이디문제언어결과실행 시간메모리
1345626BlockOGWorm Worries (BOI18_worm)C++20
10 / 100
356 ms9944 KiB
#include <bits/stdc++.h>

// mrrrowwww meeowwwww :3
// go play vivid/stasis! !! !!! https://vividstasis.gay

#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;

int ____init = []{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    return 0;
}();

int n, m, k;

map<pair<int, pair<int, int>>, int> cache;
int humidity(int x, int y, int z) {
    if (!cache.count({ x, { y, z } }) && x >= 1 && y >= 1 && z >= 1 && x <= n && y <= m && z <= k) {
        cout << "? " << x << ' ' << y << ' ' << z << endl;
        cin >> cache[{ x, { y, z } }];
    }
    return cache[{ x, { y, z } }];
}

void answer(int x, int y, int z) {
    cout << "! " << x << ' ' << y << ' ' << z << endl;
}

int main() {
    int q; cin >> n >> m >> k >> q;

    int x = (n + 1) / 2, y = (m + 1) / 2, z = (k + 1) / 2;
    int amount_x = n / 2, amount_y = m / 2, amount_z = k / 2;
    bool changed;
    do {
        int ma = humidity(x, y, z), dir;
        if (humidity(x + 1, y, z) > ma) ma = humidity(x + 1, y, z), dir = 0;
        if (humidity(x - 1, y, z) > ma) ma = humidity(x - 1, y, z), dir = 1;
        if (humidity(x, y + 1, z) > ma) ma = humidity(x, y + 1, z), dir = 2;
        if (humidity(x, y - 1, z) > ma) ma = humidity(x, y - 1, z), dir = 3;
        if (humidity(x, y, z + 1) > ma) ma = humidity(x, y, z + 1), dir = 4;
        if (humidity(x, y, z - 1) > ma) ma = humidity(x, y, z - 1), dir = 5;
        if (changed = ma > humidity(x, y, z)) {
            switch (dir) {
                case 0: if (x + amount_x <= n) x += amount_x; break;
                case 1: if (x - amount_x >= 1) x -= amount_x; break;
                case 2: if (y + amount_y <= m) y += amount_y; break;
                case 3: if (y - amount_y >= 1) y -= amount_y; break;
                case 4: if (z + amount_z <= k) z += amount_z; break;
                case 5: if (z - amount_z >= 1) z -= amount_z; break;
            }
            amount_x = (amount_x + 1) / 2, amount_y = (amount_y + 1) / 2, amount_z = (amount_z + 1) / 2;
        }
    } while (changed);

    answer(x, y, z);
}
#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...