dalao救我啊啊啊啊!!为什么全RE啊

P3371 【模板】单源最短路径(弱化版)

拜托打成代码格式行吗?
by little_sun @ 2018-07-19 18:51:19


咦,为什么全都挤在一起啦
by 江户脱柯北 @ 2018-07-19 18:51:21


```cpp #include <bits/stdc++.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int n,m,s,head,tail,x,y,t,u; int w[10005][10005],num[10005],team[500005],dis[10005],exist[10005],a[10001][10001]; int main(int argc, char** argv) { scanf("%d%d%d",&n,&m,&s); int inf=2147483647; for (int i=1;i<=n;i++) { num[i]=0; dis[i]=inf; for (int j=1;j<=n;j++) w[i][j]=inf; } for (int i=1;i<=m;i++) { scanf("%d%d%d",&x,&y,&t); w[x][y]=t; a[x][++num[x]]=y; } team[0]=s; dis[s]=0; exist[s]=1; do { //printf("!!\n"); head=((head-1)%1601)+1; u=team[head]; head++; exist[u]=0; for (int j=1;j<=num[u];j++) { if (dis[a[u][j]]>dis[u]+w[u][a[u][j]]) { dis[a[u][j]]=dis[u]+w[u][a[u][j]]; if (!exist[a[u][j]]) { tail++; tail=((tail-1)%1601)+1; team[tail]=a[u][j]; exist[a[u][j]]=true; } } } }while (head!=tail); for (int i=1;i<=n;i++) printf("%d ",dis[i]); return 0; } ```
by 江户脱柯北 @ 2018-07-19 18:52:42


@[little_sun](/space/show?uid=61966) 救我!!
by 江户脱柯北 @ 2018-07-19 18:54:20


你把`INF`设为`2147483647`即`0x7fffffff`是不对的。 你想想,`dis[a[u][j]]>dis[u]+w[u][a[u][j]]`,若$dis_u=2147483647$,再加上某数就爆`int`了。 应设为`0x3f3f3f3f`或者是`99999999`($10^9 - 1$)即8个9
by Aleph1022 @ 2018-07-19 19:00:08


等等还有错误,待我查一下
by Aleph1022 @ 2018-07-19 19:00:54


@[I_love_him52](/space/show?uid=75840) 那我试试改一下能不能过
by 江户脱柯北 @ 2018-07-19 19:01:03


@[I_love_him52](/space/show?uid=75840) 好
by 江户脱柯北 @ 2018-07-19 19:01:14


@[I_love_him52](/space/show?uid=75840) 我想问问RE就是数组越界吗?
by 江户脱柯北 @ 2018-07-19 19:05:40


这个`RE`真的很玄学…… 另外建议你的代码习惯尽量迎合大众所喜,变量名建议使用那些比较常见的,比如`queue(替换team)`,`vis/book(替换exist)` 我帮你重写份试试
by Aleph1022 @ 2018-07-19 19:11:44


| 下一页