結果
| 問題 |
No.17 2つの地点に泊まりたい
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-04 00:51:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 759 bytes |
| コンパイル時間 | 321 ms |
| コンパイル使用メモリ | 52,500 KB |
| 最終ジャッジ日時 | 2024-11-14 18:59:05 |
| 合計ジャッジ時間 | 921 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:9: error: ‘vector’ was not declared in this scope
10 | vector<int> s(n);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:10:16: error: expected primary-expression before ‘int’
10 | vector<int> s(n);
| ^~~
main.cpp:11:21: error: ‘s’ was not declared in this scope
11 | for(int& v: s) cin>>v;
| ^
main.cpp:13:23: error: expected primary-expression before ‘int’
13 | vector<vector<int>> cost(n, vector<int>(n, inf));
| ^~~
main.cpp:17:13: error: ‘cost’ was not declared in this scope
17 | cost[a][b]=cost[b][a]=c;
| ^~~~
main.cpp:21:19: error: ‘cost’ was not declared in this scope
21 | rep(i, n) cost[i][i]=0;
| ^~~~
main.cpp:23:13: error: ‘cost’ was not declared in this scope
23 | cost[i][j]=min(cost[i][j], cost[i][k]+cost[k][j]);
| ^~~~
main.cpp:27:26: error: ‘cost’ was not declared in this scope
27 | res=min(res, cost[0][i]+s[i]+cost[i][j]+s[j]+cost[j][n-1]);
| ^~~~
main.cpp:27:37: error: ‘s’ was not declared in this scope
27 | res=min(res, cost[0][i]+s[i]+cost[i][j]+s[j]+cost[j][n-1]);
| ^
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
const int inf=1<<23;
int n, m;
while (cin>>n) {
vector<int> s(n);
for(int& v: s) cin>>v;
cin>>m;
vector<vector<int>> cost(n, vector<int>(n, inf));
while (m--) {
int a, b, c;
cin>>a>>b>>c;
cost[a][b]=cost[b][a]=c;
}
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
rep(i, n) cost[i][i]=0;
rep(k, n) rep(i, n) rep(j, n)
cost[i][j]=min(cost[i][j], cost[i][k]+cost[k][j]);
int res=inf;
REP(i,1,n-1) REP(j,1,n-1) if (i!=j)
res=min(res, cost[0][i]+s[i]+cost[i][j]+s[j]+cost[j][n-1]);
cout<<res<<endl;
}
}
hogeover30