답안 #931258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931258 2024-02-21T13:07:41 Z De3b0o Soccer (JOI17_soccer) C++14
35 / 100
156 ms 26300 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define er erase
#define pb push_back
#define ppb pop_back()
#define ph push
#define pp pop()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "YES" << "\n";
#define no cout << "NO" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid (l+r)/2

using namespace std;

int main()
{
    d3
    ll h , w;
    cin >> h >> w;
    ll a , b , c;
    cin >> a >> b >> c;
    ll n;
    cin >> n;
    pll pos[n];
    for(int i = 0 ; n>i ; i++)
    {
        ll x,y;
        cin >> x >> y;
        pos[i]={x,y};
    }
    if(n==2)
    {
        ll x = abs(pos[0].F-pos[1].F);
        ll y = abs(pos[0].S-pos[1].S);
        ll ans = (x+y)*c;
        ans=min(ans,min(y*a+b+x*c,x*a+b+y*c));
        cans
        return 0;
    }
    vector<pll> adj[n];
    ll ans = (abs(pos[0].F-pos[n-1].F)+abs(pos[0].S-pos[n-1].S))*c;
    for(int i = 0 ; n>i ; i++)
    {
        for(int j = 0 ; n>j ; j++)
        {
            if(i==j)
                continue;
            ll x = abs(pos[i].F-pos[j].F);
            ll y = abs(pos[i].S-pos[j].S);
            adj[i].pb({j,min(b+y*c,x*c+b)});
        }
    }
    priority_queue<pll> q;
    bool vis[n] = {0};
    q.push({0,0});
    ll d[n];
    for(int i = 0 ; n>i ; i++)
        d[i]=LLONG_MAX;
    d[0]=0;
    while(!q.empty())
    {
        pll t = q.top();
        q.pop();
        if(vis[t.S])
            continue;
        vis[t.S] = 1;
        for(auto it : adj[t.S])
        {
            d[it.F]=min(d[it.F],d[t.S]+it.S);
            q.push({-d[it.F],it.F});
        }
    }
    ans=min(ans,d[n-1]);
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 1596 KB Output is correct
6 Correct 156 ms 25788 KB Output is correct
7 Correct 147 ms 26300 KB Output is correct
8 Correct 147 ms 25536 KB Output is correct
9 Correct 150 ms 25792 KB Output is correct
10 Correct 147 ms 22240 KB Output is correct
11 Correct 145 ms 25020 KB Output is correct
12 Correct 3 ms 1116 KB Output is correct
13 Correct 149 ms 25432 KB Output is correct
14 Correct 150 ms 26104 KB Output is correct
15 Correct 154 ms 26300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 5 ms 1596 KB Output is correct
11 Correct 156 ms 25788 KB Output is correct
12 Correct 147 ms 26300 KB Output is correct
13 Correct 147 ms 25536 KB Output is correct
14 Correct 150 ms 25792 KB Output is correct
15 Correct 147 ms 22240 KB Output is correct
16 Correct 145 ms 25020 KB Output is correct
17 Correct 3 ms 1116 KB Output is correct
18 Correct 149 ms 25432 KB Output is correct
19 Correct 150 ms 26104 KB Output is correct
20 Correct 154 ms 26300 KB Output is correct
21 Incorrect 1 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -