Submission #00386
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #define INF 999999 #define ROOP(i,n) for(int i=1;i<=n;i++) using namespace std; int N,M,A,B,prev[3000][3000],G[3000][3000],ans=0,sp=0; vector< int > V; void warshall_froyd(){ ROOP(i,N){ ROOP(j,N){ prev[i][j]=i; } } ROOP(k,N){ ROOP(i,N){ ROOP(j,N){ if (G[i][j]>G[i][k]+G[k][j]){ G[i][j]=G[i][k]+G[k][j]; prev[i][j]=prev[k][j]; } } } } } int main(){ scanf ( "%d %d %d %d" ,&N,&M,&A,&B); ROOP(i,N) ROOP(j,N) G[i][j]=INF; ROOP(i,N) G[i][i]=0; ROOP(i,M){ int u,v,t; scanf ( " %d %d %d" ,&u,&v,&t); G[u][v]=t;G[v][u]=t; } warshall_froyd(); for ( int cur=B;cur!=A;cur=prev[A][cur]) V.push_back(cur); V.push_back(A); ROOP(i,N){ int MIN=INF; for (vector< int >::iterator it=V.begin();it<V.end();it++){ MIN=min(MIN,G[i][*it]); } ans+=MIN; } printf ( "%d\n" ,ans); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - railway |
ユーザー名 | nii |
投稿日時 | 2017-11-26 15:06:59 |
言語 | C++ |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1009 Byte |
最大実行時間 | 1000 ms |
最大メモリ使用量 | 65536 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 80 | * |
2 | partial_1 | 0 / 20 | !*, *S* |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |
---|---|---|---|---|---|
!test01.txt | AC | 20 ms | 2524 KB |
1
|
2
|
!test02.txt | AC | 15 ms | 2600 KB |
1
|
2
|
mesh_01.txt | WA | 713 ms | 24412 KB |
1
|
|
mesh_02.txt | WA | 690 ms | 24420 KB |
1
|
|
randomL_01.txt | MLE | 1000 ms | 65536 KB |
1
|
|
randomL_02.txt | MLE | 548 ms | 65536 KB |
1
|
|
randomL_03.txt | MLE | 713 ms | 65536 KB |
1
|
|
randomL_04.txt | MLE | 532 ms | 65536 KB |
1
|
|
randomL_05.txt | MLE | 581 ms | 65536 KB |
1
|
|
randomS_01.txt | WA | 628 ms | 27572 KB |
1
|
2
|
randomS_02.txt | WA | 611 ms | 27580 KB |
1
|
2
|
randomS_03.txt | WA | 725 ms | 27460 KB |
1
|
2
|
treeL_01.txt | MLE | 334 ms | 65536 KB |
1
|
|
treeL_02.txt | MLE | 367 ms | 65536 KB |
1
|
|
treeS_01.txt | AC | 707 ms | 24576 KB |
1
|
2
|
treeS_02.txt | WA | 623 ms | 24708 KB |
1
|
2
|