Submission #386582

# Submission time Handle Problem Language Result Execution time Memory
386582 2021-04-07T02:02:23 Z timmyfeng Hamburg Steak (JOI20_hamburg) C++17
15 / 100
249 ms 13004 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 200000, X = 1000000000;

vector<array<int, 2>> skewers;
array<int, 4> rects[N];
bool tested[N];
int n;

array<int, 4> bounds() {
    int x1 = X, x2 = 1, y1 = X, y2 = 1;
    for (int i = 0; i < n; ++i) {
        if (!tested[i]) {
            auto [x3, x4, y3, y4] = rects[i];
            x1 = min(x1, x4);
            x2 = max(x2, x3);
            y1 = min(y1, y4);
            y2 = max(y2, y3);
        }
    }
    return {x1, x2, y1, y2};
}

void solve(int k) {
    if (k == 0) {
        if (count(tested, tested + n, true) == n) {
            for (auto [x, y] : skewers) {
                cout << x << " " << y << "\n";
            }
            exit(0);
        }
        return;
    }

    auto [x1, x2, y1, y2] = bounds();

    for (auto x : {x1, x2}) {
        for (auto y : {y1, y2}) {
            skewers.push_back({x, y});
            vector<int> undo;
            for (int i = 0; i < n; ++i) {
                if (!tested[i]) {
                    auto [x3, x4, y3, y4] = rects[i];
                    if (x3 <= x && x <= x4) {
                        if (y3 <= y && y <= y4) {
                            tested[i] = true;
                            undo.push_back(i);
                        }
                    }
                }
            }

            solve(k - 1);

            for (auto i : undo) {
                tested[i] = false;
            }
            skewers.pop_back();
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        cin >> rects[i][0] >> rects[i][2] >> rects[i][1] >> rects[i][3];
    }

    solve(k);

    cout << -1 << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 620 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 620 KB Output is correct
13 Correct 8 ms 496 KB Output is correct
14 Incorrect 8 ms 492 KB Integer parameter [name=x_1] equals to -1, violates the range [1, 10^9]
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 620 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 97 ms 12524 KB Output is correct
6 Correct 102 ms 12652 KB Output is correct
7 Correct 99 ms 12656 KB Output is correct
8 Correct 102 ms 12524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 106 ms 12752 KB Output is correct
6 Correct 136 ms 13004 KB Output is correct
7 Correct 102 ms 12652 KB Output is correct
8 Correct 112 ms 12748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 3 ms 492 KB Output is correct
13 Correct 106 ms 12620 KB Output is correct
14 Correct 100 ms 12524 KB Output is correct
15 Correct 104 ms 12524 KB Output is correct
16 Correct 102 ms 12600 KB Output is correct
17 Correct 104 ms 12652 KB Output is correct
18 Correct 126 ms 12524 KB Output is correct
19 Correct 121 ms 12780 KB Output is correct
20 Correct 113 ms 12544 KB Output is correct
21 Correct 249 ms 12760 KB Output is correct
22 Correct 188 ms 12572 KB Output is correct
23 Correct 176 ms 12620 KB Output is correct
24 Correct 163 ms 12704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 3 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 3 ms 492 KB Output is correct
10 Correct 3 ms 492 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
12 Correct 2 ms 620 KB Output is correct
13 Correct 8 ms 496 KB Output is correct
14 Incorrect 8 ms 492 KB Integer parameter [name=x_1] equals to -1, violates the range [1, 10^9]
15 Halted 0 ms 0 KB -