大牛们帮看看,#9总是过不了

记录信息
评测状态    Wrong Answer
题目  P1794 文化之旅
递交时间    2016-07-25 17:36:52
代码语言    C++
评测机 ShadowShore
消耗时间    30 ms
消耗内存    632 KiB
评测时间    2016-07-25 17:36:54
评测结果
编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 632 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 632 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 628 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 632 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 632 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 632 KiB, score = 10
测试数据 #6: Accepted, time = 15 ms, mem = 632 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 632 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 632 KiB, score = 10
测试数据 #9: WrongAnswer, time = 0 ms, mem = 628 KiB, score = 0
WrongAnswer, time = 30 ms, mem = 632 KiB, score = 90
代码
#include <bits/stdc++.h>
using std :: min;
const int INF = 999999;
int n,k,m,s,t,dist[101][101],c[101],a[101][101];
int main() {
  scanf("%d%d%d%d%d",&n,&k,&m,&s,&t);
  for (int i = 1;i <= n;i++)
    for (int j = 1;j <= n;j++) dist[i][j] = INF;
  for (int i = 1;i <= n;i++) scanf("%d",&c[i]);
  for (int i = 1;i <= k;i++)
    for (int j = 1;j <= k;j++)
      scanf("%d",&a[i][j]);
  for (int i = 1;i <= m;i++) {
    int a1,b1,c1;
    scanf("%d%d%d",&a1,&b1,&c1);
    dist[a1][b1] = dist[b1][a1] = c1;
  }
  for (int i = 1;i <= n;i++)
    for (int j = 1;j <= n;j++)
      if (a[i][j]) dist[i][j] = INF;
  for (int k = 1;k <= n;k++)      //floyd
    for (int i = 1;i <= n;i++)
      for (int j = 1;j <= n;j++) dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
  if (dist[s][t] == INF) printf("%d",-1);
  else printf("%d",dist[s][t]);
}

1 条评论

  • 1

信息

ID
1794
难度
6
分类
搜索 | 图结构 | 最短路 点击显示
标签
递交数
2557
已通过
606
通过率
24%
被复制
17
上传者