QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#218637 | #6391. Airplane | Bucketsmith | 0 | 37ms | 16768kb | C++20 | 1.1kb | 2023-10-18 16:08:18 | 2023-10-18 16:08:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
using pii = pair<int, int>;
vector<int> g[N];
int n, m;
int a[N], dis[2][N];
void dijkstra(int st, int *dis) {
memset(dis + 1, 0x3f, sizeof(int) * n);
dis[st] = 0;
priority_queue<pii, vector<pii>, greater<pii> > q;
q.push({0, st});
while(q.size()) {
auto [d, u] = q.top();
q.pop();
if(d > dis[u]) continue;
for(auto v : g[u]) {
if(max(d + 1, a[v]) < dis[v]) {
dis[v] = max(d + 1, a[v]);
q.push({dis[v], v});
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i ++)
cin >> a[i];
for(int i = 1, u, v; i <= m; i ++) {
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
dijkstra(1, dis[0]);
dijkstra(n, dis[1]);
int ans = 1e9;
for(int i = 1; i <= n; i ++)
ans = min(ans, dis[0][i] + dis[1][i]);
cout << ans;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 37ms
memory: 16768kb
input:
200000 199999 0 199 58 60 83 5 10 182 87 65 104 153 197 137 80 143 34 181 62 48 10 57 86 58 117 10 171 188 95 52 95 140 126 0 196 85 87 14 10 139 177 92 31 18 102 146 68 9 91 124 156 38 41 121 183 10 32 174 171 29 49 26 118 1 69 185 57 168 54 159 195 95 9 32 195 70 85 174 158 82 33 197 66 189 198 11...
output:
200180
result:
wrong answer 1st lines differ - expected: '200378', found: '200180'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 10
Accepted
time: 2ms
memory: 9780kb
input:
6 10 0 0 6 1 8 0 5 6 2 3 5 4 6 4 3 5 6 2 3 6 3 4 3 1 6 1
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 1ms
memory: 9552kb
input:
4 5 0 1 2 0 2 4 1 2 3 2 4 1 4 3
output:
1
result:
ok single line: '1'
Test #10:
score: -10
Wrong Answer
time: 0ms
memory: 9632kb
input:
20 40 0 2 1 5 3 4 1 5 3 2 5 5 5 3 3 4 4 3 4 0 4 3 15 18 11 18 10 13 1 3 9 14 16 14 16 1 5 3 13 15 20 7 20 16 9 11 16 11 1 2 6 2 19 10 7 13 15 10 7 15 8 11 5 9 8 12 6 7 7 14 2 18 17 16 8 3 1 10 5 2 4 2 11 13 17 3 11 5 4 8 13 6 17 1 10 7 5 6 13 9
output:
3
result:
wrong answer 1st lines differ - expected: '4', found: '3'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%