- [SCOI2012]Blinker的仰慕者
RE三个点求调
- 2022-10-18 15:13:43 @
rt,朴素dij,实在不知道错在哪里, 的范围已经调到尽可能大了仍然re。 求调
#include <iostream>
#include <cstdio>
using namespace std;
#define inf 2147483647
const int N = 3009, M = 5000009;
int h[N][N], n, m, s;
int dis[N], vis[N];
inline void dijkstra() {
for (int i = 1; i <= n; i++) dis[i] = inf;
dis[s] = 0;
for (int i = 1; i <= n; i++) {
int id, mind = inf;
for (int j = 1; j <= n; j++) {
if (dis[j] < mind && !vis[j]) {
id = j;
mind = dis[j];
}
}
vis[id] = 1;
for (int j = 1; j <= n; j++) {
if (h[id][j] != inf) dis[j] = min(dis[j], dis[id] + h[id][j]);
}
}
}
signed main () {
int c, u, v;
scanf ("%d%d%d", &n, &m, &s);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
h[i][j] = inf;
for (int i = 1; i <= m; i++) {
scanf ("%d%d%d", &u, &v, &c);
h[u][v] = min(c, h[u][v]);
}
dijkstra();
for (int i = 1; i <= n; i++) printf ("%d ", dis[i]);
return 0;
}
3 条评论
-
PatrickChen LV 6 @ 2022-12-6 8:34:57
re了那几个点?
-
2022-10-18 15:16:19@
所以re除了数组越界还有别的原因吗
-
2022-10-18 15:15:50@
qwq
- 1
信息
- ID
- 2307
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 37
- 已通过
- 7
- 上传者