QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250570 | #6391. Airplane | Mine_King | 0 | 29ms | 13472kb | C++14 | 1.7kb | 2023-11-13 13:19:33 | 2023-11-13 13:19:34 |
Judging History
answer
// 願ったんなら叶えてしまえやって
// Think twice, code once.
#include <queue>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eputchar(c) putc(c, stderr)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define eputs(str) fputs(str, stderr), putc('\n', stderr)
using namespace std;
int n, m, dis[2][200005], a[200005];
struct graph {
int tot, hd[200005];
int nxt[800005], to[800005];
void add(int u, int v) {
nxt[++tot] = hd[u];
hd[u] = tot;
to[tot] = v;
return ;
}
} g;
struct node {
int id, val;
node() = default;
node(int _id, int _val): id(_id), val(_val) {}
bool operator<(const node &x) const {return val > x.val;}
};
void dijkstra(int s, int o) {
priority_queue<node> q;
memset(dis[o], 0x3f, sizeof(dis[o]));
q.emplace(s, dis[o][s] = 0);
while (!q.empty()) {
int now = q.top().id, tmp = q.top().val;
q.pop();
if (tmp != dis[o][now]) continue;
for (int i = g.hd[now]; i; i = g.nxt[i])
if (dis[o][g.to[i]] > max(dis[o][now] + 1, a[g.to[i]]))
q.emplace(g.to[i], dis[o][g.to[i]] = max(dis[o][now] + 1, a[g.to[i]]));
}
return ;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= m; i++) {
int u, v;
scanf("%d%d", &u, &v);
g.add(u, v);
g.add(v, u);
}
if (n == 2) {puts("1"); return 0;}
dijkstra(1, 0), dijkstra(n, 1);
int ans = 0x3f3f3f3f;
for (int i = 1; i <= n; i++) {
ans = min(ans, 2 * max(dis[0][i], dis[1][i]));
for (int j = g.hd[i]; j; j = g.nxt[j])
ans = max(ans, 2 * max(dis[0][i], dis[1][g.to[j]]) + 1);
}
printf("%d\n", ans);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 29ms
memory: 13472kb
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:
400395
result:
wrong answer 1st lines differ - expected: '200378', found: '400395'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 2ms
memory: 11040kb
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:
17
result:
wrong answer 1st lines differ - expected: '1', found: '17'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%