답안 #1099289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099289 2024-10-11T06:06:16 Z YFHHFY Soccer (JOI17_soccer) C++17
35 / 100
298 ms 35052 KB
#include<bits/stdc++.h>
#define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define int long long
#define itn int
#define ss set <int>
#define prq priority_queue <int>
#define endl '\n'
const ll MOD = 1e9 + 7;
#define md(x) (((x%MOD)+MOD)%MOD)
#define vi vector <int>
#define vl vector<ll>
#define str string 
#define mp make_pair
#define mata int32_t
#define sz size
#define lc id *2
#define rc lc +1
#define SZ(x)           (int)x.size()
#define mid (l+r)/2
#define cn cin
#define ct cout
#define F first
#define S second
#define sep " "
using namespace std;
typedef pair <int , int> pii;
const ll maxn = 2e6 + 5 ;
const int Lg = 23;
const ll inf = 1e18 ;
ll h , w , a , b , c , n;
// vector <pii> vp(100010);
// ll dp[510][510];
void solve (){
    cn >> h >> w >> a >> b >> c >> n;
    int s[n] , t[n];
    for (int i = 0 ; i < n ; i ++) cn >> s[i] >> t[i];
    vector<pii> adj[n];
    for (int i = 0 ; i < n ; i++){
        for (int j = 0 ; j < n ; j++){
            int difs = abs(s[i]-s[j]);
            int dift = abs(t[i]-t[j]);
            int o1 = (a*difs) + b + (c*dift);
            if (difs == 0) o1 -= b;
            int o2 = (a*dift) + b + (c*difs);
            if (dift == 0) o2 -= b;
            itn o3 = (c*difs) + (c*dift);
            int dist = min({o1,o2,o3});
            adj[i].pb({j , dist});
            adj[j].pb({i , dist});
        }
    }
	int dist[n];
	memset(dist,-1,sizeof(dist));
	dist[0] = 0;
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
	pq.push({0,0});
	while(!pq.empty()){
		int v = pq.top().first, di = pq.top().second; pq.pop();
		if(dist[v] != di) continue;
		for(auto ii : adj[v]){
			int nv = ii.first, nd = ii.second+di;
			if(dist[nv] != -1 && dist[nv] <= nd) continue;
			dist[nv] = nd;
			pq.push({nv,nd});
		}
	}
    ct << dist[n-1] << endl;
}
mata main(){
    tizoboz;
    int tt = 1;
    // cn >> tt;
    while (tt--){
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 860 KB Output is correct
4 Correct 2 ms 856 KB Output is correct
5 Correct 3 ms 2140 KB Output is correct
6 Correct 298 ms 35048 KB Output is correct
7 Correct 48 ms 33360 KB Output is correct
8 Correct 56 ms 33272 KB Output is correct
9 Correct 44 ms 33108 KB Output is correct
10 Correct 46 ms 33040 KB Output is correct
11 Correct 50 ms 33104 KB Output is correct
12 Correct 2 ms 1628 KB Output is correct
13 Correct 231 ms 35052 KB Output is correct
14 Correct 44 ms 33104 KB Output is correct
15 Correct 44 ms 33104 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 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 2 ms 856 KB Output is correct
10 Correct 3 ms 2140 KB Output is correct
11 Correct 298 ms 35048 KB Output is correct
12 Correct 48 ms 33360 KB Output is correct
13 Correct 56 ms 33272 KB Output is correct
14 Correct 44 ms 33108 KB Output is correct
15 Correct 46 ms 33040 KB Output is correct
16 Correct 50 ms 33104 KB Output is correct
17 Correct 2 ms 1628 KB Output is correct
18 Correct 231 ms 35052 KB Output is correct
19 Correct 44 ms 33104 KB Output is correct
20 Correct 44 ms 33104 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 1 ms 860 KB Output isn't correct
23 Halted 0 ms 0 KB -