QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#218718 | #6391. Airplane | Bucketsmith | 0 | 43ms | 16884kb | C++20 | 1.1kb | 2023-10-18 17:31:09 | 2023-10-18 17:31:09 |
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 ++)
if(abs(dis[0][i] - dis[1][i]) <= 1)
ans = min(ans, dis[0][i] + dis[1][i] + abs(dis[0][i] - dis[1][i]));
cout << ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 22
Accepted
time: 37ms
memory: 16884kb
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:
200378
result:
ok single line: '200378'
Test #2:
score: -22
Wrong Answer
time: 43ms
memory: 16844kb
input:
200000 199999 0 7069 4413 15143 13876 8264 277 9620 7202 15692 14258 2614 13807 19768 18946 6508 4536 16015 11178 18780 13194 3126 15666 16341 13700 1400 17159 3289 11433 12997 4482 5897 10872 14089 17849 6479 3144 15034 9891 8465 13826 16423 12149 10812 5239 7420 17792 11494 11072 14771 3344 1911 1...
output:
239620
result:
wrong answer 1st lines differ - expected: '239619', found: '239620'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 8736kb
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:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%