제출 #623649

#제출 시각아이디문제언어결과실행 시간메모리
623649KoDWorm Worries (BOI18_worm)C++17
32 / 100
1 ms292 KiB
#include <bits/stdc++.h>

using std::vector;
using std::pair;
using std::tuple;
using std::array;

int N, M, K, Q;

bool inside(const int x, const int y, const int z) {
    return 1 <= x and x <= N and 1 <= y and y <= M and 1 <= z and z <= K;
}

int query(const int x, const int y, const int z) {
    static std::map<array<int, 3>, int> memo = {};
    if (inside(x, y, z)) {
        auto& ret = memo[{x, y, z}];
        if (ret == 0) {
            std::cout << "? " << x << " " << y << " " << z << std::endl;
            std::cin >> ret;
        }
        return ret;
    } else {
        return 0;
    }
}

void answer(const int x, const int y, const int z) {
    assert(inside(x, y, z));
    std::cout << "! " << x << " " << y << " " << z << std::endl;
    std::exit(EXIT_SUCCESS);
}

void solve_1D() {
    int l = 0, r = N + 1;
    int x = 1, y = 1;
    while (l + y < r) {
        x += y;
        std::swap(x, y);
    }
    r = l + y;
    while (x > 1) {
        y -= x;
        if (query(l + y, 1, 1) < query(r - y, 1, 1)) {
            l += y;
        } else {
            r -= y;
        }
        std::swap(x, y);
    }
    answer(l + x, 1, 1);
}

void solve_2D() {

}

void solve_3D() {

}

int main() {
    std::cin >> N >> M >> K >> Q;
    if (M == 1 and K == 1) {
        solve_1D();
    } else if (K == 1) {
        solve_2D();
    } else {
        solve_3D();
    }
}
#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...