結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
ojisan_IT
|
| 提出日時 | 2017-08-11 07:02:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,670 bytes |
| コンパイル時間 | 1,456 ms |
| コンパイル使用メモリ | 176,536 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 04:57:10 |
| 合計ジャッジ時間 | 2,485 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 5 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
In function 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]',
inlined from 'int main()' at main.cpp:64:14:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:235:15: warning: iteration 301 invokes undefined behavior [-Waggressive-loop-optimizations]
235 | if (__b < __a)
| ~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:63:20: note: within this loop
63 | for(int i = 0; i <= 301; i++)
| ~~^~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
int dp[51][301] ={}; // dp[N][C] = time
struct edge{
int to,cost,time;
};
vector<edge> G[51];
int s[1500],t[1500],y[1500],m[1500];
int main(){
int n,c,v; 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)
G[s[i]].pb((edge){t[i],y[i],m[i]});
fill_n(dp[0],51*301,INF);
priority_queue<pii,vector<pii>,greater<pii > > q; //cost,position
dp[1][c] = 0;
q.push(mp(c,1));
while(!q.empty()){
int id = q.top().SEC;
int nowc = q.top().FST;
q.pop();
for(int i = 0; i < G[id].size();i++){
if(nowc-G[id][i].cost>=0 && dp[id][nowc]+G[id][i].time < dp[G[id][i].to][nowc-G[id][i].cost]){
dp[G[id][i].to][nowc-G[id][i].cost]=dp[id][nowc]+G[id][i].time;
q.push(mp(nowc-G[id][i].cost,G[id][i].to));
}
}
}
int ans = INF;
for(int i = 0; i <= 301; i++)
ans = min(ans,dp[n][i]);
cout << ((ans == INF)? -1 : ans) << endl;
}
ojisan_IT