답안 #559655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559655 2022-05-10T11:04:18 Z hoanghq2004 Worm Worries (BOI18_worm) C++14
0 / 100
1256 ms 47768 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 gen(std :: chrono :: system_clock :: now().time_since_epoch().count());

int n, m, k, q;

namespace subtask2 {
    const int N = 1010;
    int H[N][N];
    void run() {
        auto ask = [&](int x, int y) {
            if (x >= 1 && x <= n && y >= 1 && y <= n && H[x][y] == 0) {
                cout << "? " << x << ' ' << y << ' ' << 1 << endl;
                cin >> H[x][y];
            }
            return H[x][y];
        };
        int x = gen() % n + 1, y = gen() % m + 1;
        while (1) {
            tuple <int, int, int> best = {-1, 0, 0};
            for (int a = x - 1; a <= x + 1; ++a)
                for (int b = y - 1; b <= y + 1; ++b) {
                    if (a == x && b == y) continue;
                    best = max(best, {ask(a, b), a, b});
                }
            if (get<0>(best) <= ask(x, y)) {
                cout << "! " << x << ' ' << y << ' ' << 1;
                exit(0);
            }
            x = get<1>(best), y = get<2>(best);
        }
    }
}

namespace subtask3 {
    const int N = 510;
    int H[N][N][N];
    void run() {
        auto ask = [&](int x, int y, int z) {
            if (x >= 1 && x <= n && y >= 1 && y <= n && z >= 1 && z <= n && H[x][y][z] == 0) {
                cout << "? " << x << ' ' << y << ' ' << z << endl;
                cin >> H[x][y][z];
            }
            return H[x][y][z];
        };
        int x = gen() % n + 1, y = gen() % m + 1, z = gen() % k + 1;
        while (1) {
            tuple <int, int, int, int> best = {-1, 0, 0, 0};
            for (int a = x - 1; a <= x + 1; ++a)
                for (int b = y - 1; b <= y + 1; ++b)
                    for (int c = z - 1; c <= z + 1; ++c) {
                        if (a == x && b == y && z == c) continue;
                        best = max(best, {ask(a, b, c), a, b, c});
                    }
            if (get<0>(best) <= ask(x, y, z)) {
                cout << "! " << x << ' ' << y << ' ' << z;
                exit(0);
            }
            x = get<1>(best), y = get<2>(best), z = get<3>(best);
        }
    }
}

int main() {
    ios :: sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> k >> q;
    if (k == 1) subtask2 :: run();
    else subtask3 :: run();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 5 ms 968 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Runtime error 37 ms 764 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Runtime error 35 ms 3052 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 10 ms 848 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Runtime error 650 ms 2580 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 10 ms 2088 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Runtime error 1256 ms 47768 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -