結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2014-11-16 14:12:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,476 bytes |
| コンパイル時間 | 744 ms |
| コンパイル使用メモリ | 77,216 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 16:06:38 |
| 合計ジャッジ時間 | 1,946 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d%d%d",&N,&C,&V);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:30:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | scanf("%d",&info[j][i]);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
struct TOWN{
vector<int> T,Y,M;
int way;
TOWN(){
way=0;
}
} town[51];
int main(){
int N,C,V,info[1500][4],nextcost,nextm,nexttown;
priority_queue<pair<int,pair<int,int>>> pq;
pair<int,pair<int,int>> now;
scanf("%d%d%d",&N,&C,&V);
for(int i=0;i<4;i++)
for(int j=0;j<V;j++)
scanf("%d",&info[j][i]);
for(int i=0;i<V;i++){
town[info[i][0]].T.push_back(info[i][1]);
town[info[i][0]].Y.push_back(info[i][2]);
town[info[i][0]].M.push_back(-1*info[i][3]);
town[info[i][0]].way++;
}
pq.push(make_pair(0,make_pair(0,1)));
while(!pq.empty()){
now = pq.top();
pq.pop();
if(now.second.second==N){
printf("%d",-1*now.first);
return 0;
}
for(int i=0;i<town[now.second.second].way;i++){
nextm = town[now.second.second].M[i]+now.first;
nextcost = town[now.second.second].Y[i]+now.second.first;
nexttown = town[now.second.second].T[i];
if(nextcost<=C)
pq.push(make_pair(nextm,make_pair(nextcost,nexttown)));
}
}
puts("-1");
return 0;
}
goodbaton