結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
ynq1242
|
| 提出日時 | 2014-10-26 13:53:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,983 bytes |
| コンパイル時間 | 985 ms |
| コンパイル使用メモリ | 93,844 KB |
| 実行使用メモリ | 10,268 KB |
| 最終ジャッジ日時 | 2024-07-08 03:34:11 |
| 合計ジャッジ時間 | 7,581 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 35 |
ソースコード
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
#include<ctime>
#include<set>
using namespace std;
#define li long long int
#define rep(i,to) for(li i=0;i<((li)(to));i++)
#define repp(i,start,to) for(li i=(li)(start);i<((li)(to));i++)
#define pb push_back
#define sz(v) ((li)(v).size())
#define bgn(v) ((v).begin())
#define eend(v) ((v).end())
#define allof(v) (v).begin(), (v).end()
#define dodp(v,n) memset(v,(li)n,sizeof(v))
#define bit(n) (1ll<<(li)(n))
#define mp(a,b) make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b) cout<<a<<"\t"<<b<<endl
#define p3(a,b,c) cout<<a<<"\t"<<b<<"\t"<<c<<endl
vector<string> split(const string &str, char delim){
istringstream iss(str); string tmp; vector<string> res;
while(getline(iss, tmp, delim)) res.push_back(tmp);
return res;
}
li sstoi(string s){
return atoi(s.c_str());
}
li n,c,v;
vector<pair<li, pair<li,li> > > edge[60];
li s[1515], t[1515], y[1515], m[1515];
li dfs(li from, li to, li total_cost, li total_time){
li res=1000000000000;
rep(i,sz(edge[from])){
li next=edge[from][i].F;
li cost=edge[from][i].S.F;
li minutes=edge[from][i].S.S;
if(next==to){
if(total_cost+cost<=c)res=min(res, total_time+minutes);
}
else{
li result=dfs(next, to, total_cost+cost, total_time+minutes);
if(result>=0)res=min(res, result);
}
}
return (res>100000000000 ? -1 : res);
}
int main(){
cin>>n>>c>>v;
rep(i,v)cin>>s[i];
rep(i,v)cin>>t[i];
rep(i,v)cin>>y[i];
rep(i,v)cin>>m[i];
rep(i,v){
edge[s[i]-1].pb(mp(t[i]-1, mp(y[i], m[i])));
}
cout<<dfs(0, n-1, 0, 0)<<endl;
return 0;
}
ynq1242