QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#444342#8646. Card CollectionQwerty1232#0 1ms3836kbC++233.3kb2024-06-15 18:26:552024-06-15 18:26:55

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 18:26:55]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3836kb
  • [2024-06-15 18:26:55]
  • 提交

answer

#include <bits/stdc++.h>

void unique(auto& vec) {
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
}

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

    int n, m;
    std::cin >> n >> m;
    std::vector<std::pair<int, int>> input(n), quer(m);
    for (auto& [u, v] : input) {
        std::cin >> u >> v;
    }
    for (auto& [u, v] : quer) {
        std::cin >> u >> v;
    }

    std::vector<int> all_x, all_y;
    for (auto& [u, v] : quer) {
        all_x.push_back(u);
        all_x.push_back(u - 1);
        all_y.push_back(v);
        all_y.push_back(v - 1);
    }
    all_x.push_back(1.1e9);
    all_y.push_back(1.1e9);
    unique(all_x);
    unique(all_y);

    int w = all_x.size(), h = all_y.size();
    for (auto& [u, v] : input) {
        u = std::lower_bound(all_x.begin(), all_x.end(), u) - all_x.begin();
        v = std::lower_bound(all_y.begin(), all_y.end(), v) - all_y.begin();
        assert(u != w && v != h);
    }
    for (auto& [u, v] : quer) {
        u = std::lower_bound(all_x.begin(), all_x.end(), u) - all_x.begin();
        v = std::lower_bound(all_y.begin(), all_y.end(), v) - all_y.begin();
        assert(u != w && v != h);
    }

    std::vector<std::vector<std::vector<std::vector<char>>>> dp(n, std::vector<std::vector<std::vector<char>>>(n, std::vector<std::vector<char>>(w, std::vector<char>(h))));
    for (int i = 0; i < n; i++) {
        dp[i][i][input[i].first][input[i].second] = 0xF;
    }

    for (int i = 1; i < n; i++) {
        for (int j = i - 1; j >= 0; j--) {
            for (int t = j; t < i; t++) {
                for (int a = 0; a < w; a++) {
                    for (int b = 0; b < h; b++) {
                        if (!dp[j][t][a][b]) {
                            continue;
                        }

                        for (int c = 0; c < w; c++) {
                            for (int d = 0; d < h; d++) {
                                if (!dp[t + 1][i][c][d]) {
                                    continue;
                                }
                                for (char ch = 0; ch < 4; ch++) {
                                    if ((dp[j][t][a][b] & 1 << ch) && (dp[t + 1][i][c][d] & 1 << ch)) {
                                        if (ch == 0 || ch == 3) {
                                            dp[j][i][std::min(a, c)][std::min(b, d)] |= 1 << ch;
                                        } else {
                                            dp[j][i][std::max(a, c)][std::max(b, d)] |= 1 << ch;
                                        }
                                    }
                                }
                            }
                        }
                        if (dp[j][i][a][b] & 1) {
                            dp[j][i][a][b] |= 2;
                        }
                        if (dp[j][i][a][b] & 4) {
                            dp[j][i][a][b] |= 8;
                        }
                    }
                }
            }
        }
    }

    for (int i = 0; i < m; i++) {
        if (dp[0][n - 1][quer[i].first][quer[i].second]) {
            std::cout << i + 1 << " ";
        }
    }
    std::cout << std::endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 1ms
memory: 3612kb

input:

2 10
171631799 561094698
171631799 867698918
126573648 561094698
171631799 867698918
171631799 561094698
126573648 561094698
126573648 561094698
171631799 561094698
126573648 561094698
126573648 561094698
126573648 561094698
171631799 561094698

output:

2 3 6 10 

result:

ok 4 number(s): "2 3 6 10"

Test #2:

score: 11
Accepted
time: 1ms
memory: 3548kb

input:

3 10
713180371 43103927
713180371 136832929
853543805 251852293
892623928 251852293
713180371 136832929
713180371 43103927
853543805 43103927
892623928 136832929
713180371 43103927
853543805 43103927
892623928 136832929
713180371 43103927
892623928 251852293

output:

2 3 6 9 

result:

ok 4 number(s): "2 3 6 9"

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3836kb

input:

4 10
254412080 855555783
254412080 534954259
610506813 184822793
804271098 233942602
804271098 233942602
536633825 184822793
254412080 855555783
804271098 233942602
536633825 233942602
254412080 855555783
804271098 534954259
610506813 534954259
536633825 184822793
536633825 855555783

output:

3 6 

result:

wrong answer 1st numbers differ - expected: '1', found: '3'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%