結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
![]() |
提出日時 | 2017-03-24 22:44:47 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,063 bytes |
コンパイル時間 | 1,104 ms |
コンパイル使用メモリ | 101,924 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-07-05 22:10:39 |
合計ジャッジ時間 | 2,279 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 WA * 6 |
ソースコード
#include <iostream> #include <fstream> #include <typeinfo> #include <vector> #include <stack> #include <cmath> #include <set> #include <map> #include <string> #include <algorithm> #include <cstdio> #include <queue> #include <iomanip> #include <cctype> #include <random> #define syosu(x) fixed<<setprecision(x) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; typedef pair<double,double> pdd; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<char> vc; typedef vector<vc> vvc; typedef vector<string> vs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<pll> vpll; typedef pair<int,P> pip; typedef vector<pip> vip; const int inf=1<<29; const ll INF=1ll<<52; const double pi=acos(-1); const double eps=1e-8; const ll mod=1e9+7; const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0}; const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1}; const int e=101; class Graph{ private: int V; vvp List; public: Graph(int v){ V=v; List=vvp(v); } void add_edge(int s,int t,int c){ List[s].push_back(P(t,c)); } int DIJ(int s,int t){ priority_queue<P> que; vi d(V,inf); d[s]=0; que.push(P(0,s)); while(!que.empty()){ P p=que.top(); que.pop(); int v=p.second; if(d[v]<-p.first) continue; for(int i=0;i<List[v].size();i++){ int F=List[v][i].first,S=List[v][i].second; if(d[F]>d[v]+S){ d[F]=d[v]+S; que.push(P(-d[F],F)); } } } return d[t]; } }; int gx,gy,n,f; int main(){ cin>>gx>>gy>>n>>f; Graph g(e*e); for(int i=0;i<n;i++){ int x,y,c; cin>>x>>y>>c; for(int j=0;j<e;j++) for(int k=0;k<e;k++){ int cx=j+x,cy=k+y; if(cx>=0&&cx<e&&cy>=0&&cy<e) g.add_edge(j*e+k,cx*e+cy,c); } } for(int i=0;i<e;i++) for(int j=0;j<e;j++){ if(i!=e-1) g.add_edge(i*e+j,(i+1)*e+j,f); if(j!=e-1) g.add_edge(i*e+j,i*e+j+1,f); } cout<<g.DIJ(0,gx*e+gy)<<endl; }