Submission #837244

# Submission time Handle Problem Language Result Execution time Memory
837244 2023-08-25T08:35:50 Z _martynas Soccer (JOI17_soccer) C++11
35 / 100
6 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int mxn = 1e5+5;
const ll inf = 1e17;

int h, w, n;
ll A, B, C;
ll s[mxn], t[mxn];

int main(int argc, char const *argv[]) {
    cin >> h >> w >> A >> B >> C;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> s[i] >> t[i];
    if(C <= A) {
        cout << C*(labs(s[0]-s[n-1])+labs(t[0]-t[n-1])) << "\n";
        return 0;
    }
    if(n == 2) {
        cout << min(C*(labs(s[0]-s[n-1])+labs(t[0]-t[n-1])), C*min(labs(s[0]-s[n-1]), labs(t[0]-t[n-1]))+A*max(labs(s[0]-s[n-1]), labs(t[0]-t[n-1]))+B) << "\n";
    }
    else if(A == 0) {
        vector<ll> dist(n, inf);
        vector<bool> visited(n);
        dist[0] = 0;
        for(int k = 0; k < n-1; k++) {
            int mni = -1;
            for(int i = 0; i < n; i++) if(!visited[i]) {
                if(mni == -1 || dist[i] < dist[mni]) mni = i;
            }
            visited[mni] = true;
            for(int i = 0; i < n; i++) {
                dist[i] = min(dist[i], dist[mni]+min(C*(labs(s[mni]-s[i])+labs(t[mni]-t[i])), C*min(labs(s[mni]-s[i]), labs(t[mni]-t[i]))+B));
            }
        }
        cout << dist[n-1] << "\n";
    }
    else {
        cout << "0\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 5 ms 340 KB Output is correct
7 Correct 5 ms 312 KB Output is correct
8 Correct 5 ms 340 KB Output is correct
9 Correct 5 ms 340 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 6 ms 312 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 6 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 5 ms 340 KB Output is correct
12 Correct 5 ms 312 KB Output is correct
13 Correct 5 ms 340 KB Output is correct
14 Correct 5 ms 340 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
16 Correct 6 ms 312 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 6 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 5 ms 340 KB Output is correct
21 Correct 0 ms 308 KB Output is correct
22 Incorrect 0 ms 212 KB Output isn't correct
23 Halted 0 ms 0 KB -