結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
tkzw_21
|
| 提出日時 | 2015-01-28 21:10:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,530 bytes |
| コンパイル時間 | 1,531 ms |
| コンパイル使用メモリ | 172,524 KB |
| 実行使用メモリ | 207,932 KB |
| 最終ジャッジ日時 | 2024-07-08 03:41:25 |
| 合計ジャッジ時間 | 8,143 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 TLE * 1 -- * 32 |
ソースコード
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;
typedef pair<int,pair<int,int>> PP;
typedef long long LL;
const double EPS = 1e-8;
const int INF = 1e9;
int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
struct edge{
int to,cost,tm;
};
int used[51];
int bfs(vector<vector<edge>>& es,int C,int G){
//時間、コスト、どこにいるか
priority_queue<PP,vector<PP>,greater<PP>> pq;
pq.push(make_pair(0,make_pair(C,0)));
used[0] = 1;
int ret = INF;
while(!pq.empty()){
PP pp = pq.top();pq.pop();
if(pp.second.second == G)ret = min(ret,pp.first);
for(int i=0;i<es[pp.second.second].size();i++){
int v = es[pp.second.second][i].to;
int c = pp.second.first - es[pp.second.second][i].cost;
int tm = pp.first + es[pp.second.second][i].tm;
if( c < 0)continue;
pq.push(make_pair(tm,make_pair(c,v)));
used[v] = 1;
}
}
return ret==INF ? -1 : ret;
}
int main(void) {
int N,C,V;
vector<vector<edge>>es;
cin >> N >> C >> V;
es.resize(N);
vector<int> S(V),T(V),Y(V),M(V);
for(int i=0;i<V;i++)cin >> S[i];
for(int i=0;i<V;i++)cin >> T[i];
for(int i=0;i<V;i++)cin >> Y[i];
for(int i=0;i<V;i++)cin >> M[i];
for(int i=0;i<V;i++)es[S[i]-1].push_back(edge{T[i]-1,Y[i],M[i]});
cout << bfs(es,C,N-1) << endl;
return 0;
}
// command shift d duplicate
// command ctrl up down
// command D
// command caps G → '' ""
// vector<vector<int>> a(N,vector<int>(M,-1));
//diff < (./a.out < input.txt) output.txt
// sort(v.begin(),v.end(),greater<int>());
tkzw_21