Submission #1103430

# Submission time Handle Problem Language Result Execution time Memory
1103430 2024-10-21T01:34:43 Z irmuun Soccer (JOI17_soccer) C++17
35 / 100
70 ms 23828 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll h,w;
    cin>>h>>w;
    ll a,b,c;
    cin>>a>>b>>c;
    ll n;
    cin>>n;
    ll s[n+5],t[n+5];
    for(ll i=1;i<=n;i++){
        cin>>s[i]>>t[i];
    }
    vector<pair<ll,ll>>g[n+5];
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            if(i==j) continue;
            ll d=min(abs(s[i]-s[j]),abs(t[i]-t[j]));
            ll e=max(abs(s[i]-s[j]),abs(t[i]-t[j]));
            ll ans=min({c*(d+e),d*c+e*a+b});
            g[i].pb({j,ans});
        }
    }
    vector<ll>dist(n+5,1e18);
    set<pair<ll,ll>>st;
    dist[1]=0;
    st.insert({0,1});
    while(!st.empty()){
        ll D=st.begin()->ff,i=st.begin()->ss;
        st.erase(st.begin());
        if(dist[i]!=D) continue;
        for(auto [j,w]:g[i]){
            if(D+w<dist[j]){
                dist[j]=D+w;
                st.insert({dist[j],j});
            }
        }
    }
    cout<<dist[n];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 432 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 1108 KB Output is correct
6 Correct 70 ms 23828 KB Output is correct
7 Correct 22 ms 16716 KB Output is correct
8 Correct 24 ms 17236 KB Output is correct
9 Correct 25 ms 16724 KB Output is correct
10 Correct 24 ms 16724 KB Output is correct
11 Correct 23 ms 16724 KB Output is correct
12 Correct 2 ms 1280 KB Output is correct
13 Correct 56 ms 21836 KB Output is correct
14 Correct 24 ms 16928 KB Output is correct
15 Correct 24 ms 16724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 2 ms 1108 KB Output is correct
11 Correct 70 ms 23828 KB Output is correct
12 Correct 22 ms 16716 KB Output is correct
13 Correct 24 ms 17236 KB Output is correct
14 Correct 25 ms 16724 KB Output is correct
15 Correct 24 ms 16724 KB Output is correct
16 Correct 23 ms 16724 KB Output is correct
17 Correct 2 ms 1280 KB Output is correct
18 Correct 56 ms 21836 KB Output is correct
19 Correct 24 ms 16928 KB Output is correct
20 Correct 24 ms 16724 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Incorrect 1 ms 596 KB Output isn't correct
23 Halted 0 ms 0 KB -