QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#178695 | #6333. Festivals in JOI Kingdom 2 | rgnerdplayer | 0 | 0ms | 0kb | C++20 | 1.1kb | 2023-09-14 11:14:40 | 2023-09-14 11:14:41 |
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%