Submission #1028612

# Submission time Handle Problem Language Result Execution time Memory
1028612 2024-07-20T06:05:47 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 2392 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 30010, M = 30010;
int n, m, b[M], p[M], dist[N];
bool mark[N];
vector<int> vec[N];

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i ++){
        cin >> b[i] >> p[i];
        vec[b[i]].push_back(p[i]);
    }
    for (int i = 0; i < n; i ++){
        sort(vec[i].begin(), vec[i].end());
        vec[i].resize(unique(vec[i].begin(), vec[i].end()) - vec[i].begin());
    }

    memset(dist, 63, sizeof dist);
    dist[b[0]] = 0;

    for (int ii = 0; ii < n; ii ++){
        int v = -1;
        for (int j = 0; j < n; j ++)
            if (!mark[j] and (v == -1 or dist[v] > dist[j]))
                v = j;

        if (v == b[1]) break;

        mark[v] = 1;
        for (int d : vec[v]){
            for (int i = 1; v + d * i < n; i ++)
                dist[v + d * i] = min(dist[v + d * i], dist[v] + i);
            for (int i = 1; v - d * i >= 0; i ++)
                dist[v - d * i] = min(dist[v - d * i], dist[v] + i);
        }
    }

    if (dist[b[1]] > 1e9)
        dist[b[1]] = -1;
    cout << dist[b[1]] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 2 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1116 KB Output is correct
18 Correct 5 ms 1116 KB Output is correct
19 Correct 5 ms 1116 KB Output is correct
20 Correct 10 ms 1344 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 6 ms 1116 KB Output is correct
23 Correct 4 ms 1116 KB Output is correct
24 Correct 7 ms 1116 KB Output is correct
25 Correct 4 ms 1116 KB Output is correct
26 Correct 6 ms 1116 KB Output is correct
27 Correct 7 ms 1116 KB Output is correct
28 Correct 7 ms 1116 KB Output is correct
29 Correct 7 ms 1116 KB Output is correct
30 Correct 7 ms 1272 KB Output is correct
31 Correct 7 ms 1116 KB Output is correct
32 Correct 7 ms 1272 KB Output is correct
33 Correct 8 ms 1112 KB Output is correct
34 Correct 8 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 2 ms 1112 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1368 KB Output is correct
18 Correct 5 ms 1116 KB Output is correct
19 Correct 5 ms 1128 KB Output is correct
20 Correct 10 ms 1348 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 6 ms 1296 KB Output is correct
23 Correct 4 ms 1116 KB Output is correct
24 Correct 6 ms 1116 KB Output is correct
25 Correct 3 ms 1320 KB Output is correct
26 Correct 6 ms 1304 KB Output is correct
27 Correct 7 ms 1112 KB Output is correct
28 Correct 8 ms 1112 KB Output is correct
29 Correct 9 ms 1284 KB Output is correct
30 Correct 7 ms 1116 KB Output is correct
31 Correct 7 ms 1276 KB Output is correct
32 Correct 7 ms 1280 KB Output is correct
33 Correct 8 ms 1300 KB Output is correct
34 Correct 8 ms 1116 KB Output is correct
35 Correct 11 ms 1640 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 11 ms 1372 KB Output is correct
38 Correct 13 ms 1624 KB Output is correct
39 Correct 9 ms 1628 KB Output is correct
40 Correct 10 ms 1628 KB Output is correct
41 Correct 10 ms 1628 KB Output is correct
42 Correct 13 ms 1624 KB Output is correct
43 Correct 13 ms 1588 KB Output is correct
44 Correct 17 ms 1628 KB Output is correct
45 Correct 15 ms 1628 KB Output is correct
46 Correct 15 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1112 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1368 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1308 KB Output is correct
18 Correct 6 ms 1296 KB Output is correct
19 Correct 5 ms 1116 KB Output is correct
20 Correct 10 ms 1116 KB Output is correct
21 Correct 1 ms 1112 KB Output is correct
22 Correct 6 ms 1292 KB Output is correct
23 Correct 5 ms 1300 KB Output is correct
24 Correct 6 ms 1116 KB Output is correct
25 Correct 3 ms 1116 KB Output is correct
26 Correct 6 ms 1156 KB Output is correct
27 Correct 7 ms 1116 KB Output is correct
28 Correct 7 ms 1344 KB Output is correct
29 Correct 7 ms 1116 KB Output is correct
30 Correct 7 ms 1116 KB Output is correct
31 Correct 7 ms 1112 KB Output is correct
32 Correct 7 ms 1116 KB Output is correct
33 Correct 8 ms 1152 KB Output is correct
34 Correct 8 ms 1116 KB Output is correct
35 Correct 11 ms 1664 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 11 ms 1368 KB Output is correct
38 Correct 12 ms 1628 KB Output is correct
39 Correct 9 ms 1520 KB Output is correct
40 Correct 10 ms 1624 KB Output is correct
41 Correct 11 ms 1880 KB Output is correct
42 Correct 13 ms 1628 KB Output is correct
43 Correct 13 ms 1760 KB Output is correct
44 Correct 17 ms 1628 KB Output is correct
45 Correct 15 ms 1588 KB Output is correct
46 Correct 15 ms 1592 KB Output is correct
47 Correct 134 ms 1880 KB Output is correct
48 Correct 389 ms 2116 KB Output is correct
49 Correct 634 ms 1884 KB Output is correct
50 Correct 817 ms 1896 KB Output is correct
51 Execution timed out 1018 ms 2392 KB Time limit exceeded
52 Halted 0 ms 0 KB -