結果
| 問題 | No.17 2つの地点に泊まりたい | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2014-11-16 18:06:31 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 757 bytes | 
| コンパイル時間 | 437 ms | 
| コンパイル使用メモリ | 40,576 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-31 20:50:14 | 
| 合計ジャッジ時間 | 1,580 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 21 WA * 6 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d",&cost[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d",&m);
      |         ~~~~~^~~~~~~~~
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 scanf("%d%d%d",&a,&b,&c);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int n,m;
	scanf("%d",&n);
	vector<int>cost(n);
	vector<vector<int> >dist(n);
	for(int i=0;i<n;i++){
		scanf("%d",&cost[i]);
		dist[i].resize(n);
		for(int j=0;j<n;j++)dist[i][j]=999999999;
		dist[i][i]=0;
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		dist[a][b]=dist[b][a]=c;
	}
	for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		if(dist[i][j]>dist[i][k]+dist[k][j])dist[i][j]=dist[i][k]+dist[k][j];
	int ma=999999999;
	for(int i=1;i<n-1;i++)for(int j=1;j<n-1;j++)
		if(i!=j&&ma>dist[0][i]+cost[i]+dist[i][j]+cost[j]+dist[j][n-1])ma=dist[0][i]+cost[i]+dist[i][j]+cost[j]+dist[j][n-1];
	printf("%d\n",ma);
}
            
            
            
        