Submission #1236199

#TimeUsernameProblemLanguageResultExecution timeMemory
1236199GeforgsSoccer (JOI17_soccer)C++20
35 / 100
31 ms524 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <unordered_map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> #define ll long long #define ld long double #define inf (ll)(2*1e18) //#define sort(a) sort(a.begin(), a.end()) #define reverse(a) reverse(a.begin(), a.end()) #define pb push_back #define endl "\n" using namespace std; ll n, m, k, A, B, C; ll dis(pair<ll, ll> a, pair<ll, ll> b){ return min({(abs(a.first - b.first) + abs(a.second - b.second))*C, abs(a.first - b.first)*C + B + A*abs(a.second - b.second), abs(a.second - b.second)*C + B + A*abs(a.first - b.first)}); } void solve(){ ll i, x; cin>>n>>m; cin>>A>>B>>C; cin>>k; vector<pair<ll, ll>> a(k); vector<ll> dp(k, inf); set<pair<ll, ll>> s; for(i=0;i<k;++i){ cin>>a[i].first>>a[i].second; } dp[0] = 0; s.insert({0, 0}); while(!s.empty()){ x = s.begin()->second; s.erase(s.begin()); for(i=0;i<k;++i){ if(dp[i] > dp[x] + dis(a[i], a[x])){ s.erase({dp[i], i}); dp[i] = dp[x] + dis(a[i], a[x]); s.insert({dp[i], i}); } } } cout<<dp.back()<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); srand(time(nullptr)); ll t=1; // cin>>t; for(;t>0;--t){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...