QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178695#6333. Festivals in JOI Kingdom 2rgnerdplayer0 0ms0kbC++201.1kb2023-09-14 11:14:402023-09-14 11:14:41

Judging History

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

  • [2023-09-14 11:14:41]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-09-14 11:14:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    
    auto solve = [&]() {
        int n;
        cin >> n;

        vector<int> l(n), r(n);
        for (int i = 0; i < n; i++) {
            cin >> l[i] >> r[i];
            l[i]--, r[i]--;
        }

        int q;
        cin >> q;

        vector<int> x(q);
        for (int i = 0; i < q; i++) {
            cin >> x[i];
            x[i]--;
        }

        vector dis(n, vector<int>(n, -1));
        vector<pair<int, int>> que{pair(x[0], x[0])};
        dis[x[0]][x[0]] = 0;

        for (int b = 0; b < int(que.size()); b++) {
            auto [x, y] = que[b];
            for (int i = x; i <= y; i++) {
                int nx = min(x, l[i]);
                int ny = max(y, r[i]);
                if (dis[nx][ny] == -1) {
                    dis[nx][ny] = dis[x][y] + 1;
                    que.emplace_back(nx, ny);
                }
            }
        }

        cout << dis[0][n - 1] << '\n';
    };

    solve();

    return 0;
}


详细

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

1 194903119

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%