Submission #114142

# Submission time Handle Problem Language Result Execution time Memory
114142 2019-05-30T14:36:48 Z fedoseevtimofey Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 33400 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 3e4 + 7;

vector <pair <int, int>> g[N];
int d[N];
const int Inf = 1e9;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector <int> b(m), p(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i] >> p[i];
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i == j) continue;
            if ((b[i] - b[j]) % p[i] == 0) {
                g[i].emplace_back(j, abs(b[i] - b[j]) / p[i]);
            }
        }
    }
    for (int i = 0; i < m; ++i) d[i] = Inf;
    d[0] = 0;
    set <pair <int, int>> q;
    q.insert({0, 0});
    while (!q.empty()) {
        auto p = *q.begin();
        q.erase(q.begin());
        int u = p.second;
        for (auto &[v, w] : g[u]) {
            if (d[v] > d[u] + w) {
                q.erase({d[v], v});
                d[v] = d[u] + w;
                q.insert({d[v], v});
            }
        }
    }
    cout << (d[1] == Inf ? -1 : d[1]) << '\n';
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:42:20: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
         for (auto &[v, w] : g[u]) {
                    ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 2 ms 1024 KB Output is correct
9 Correct 2 ms 1024 KB Output is correct
10 Correct 3 ms 1152 KB Output is correct
11 Correct 28 ms 3192 KB Output is correct
12 Correct 74 ms 33044 KB Output is correct
13 Correct 73 ms 33272 KB Output is correct
14 Correct 25 ms 2552 KB Output is correct
15 Correct 26 ms 2560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 2 ms 1152 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 2 ms 1024 KB Output is correct
9 Correct 3 ms 1024 KB Output is correct
10 Correct 4 ms 1152 KB Output is correct
11 Correct 27 ms 3200 KB Output is correct
12 Correct 75 ms 33132 KB Output is correct
13 Correct 74 ms 33272 KB Output is correct
14 Correct 26 ms 2552 KB Output is correct
15 Correct 26 ms 2552 KB Output is correct
16 Correct 6 ms 1280 KB Output is correct
17 Correct 19 ms 1792 KB Output is correct
18 Correct 7 ms 1152 KB Output is correct
19 Correct 4 ms 1152 KB Output is correct
20 Correct 89 ms 33272 KB Output is correct
21 Correct 9 ms 1280 KB Output is correct
22 Correct 5 ms 1024 KB Output is correct
23 Correct 7 ms 1152 KB Output is correct
24 Correct 19 ms 1280 KB Output is correct
25 Correct 20 ms 1280 KB Output is correct
26 Correct 70 ms 30300 KB Output is correct
27 Correct 74 ms 31096 KB Output is correct
28 Correct 21 ms 1280 KB Output is correct
29 Correct 6 ms 1280 KB Output is correct
30 Correct 3 ms 1024 KB Output is correct
31 Correct 5 ms 1152 KB Output is correct
32 Correct 4 ms 1152 KB Output is correct
33 Correct 27 ms 2552 KB Output is correct
34 Correct 26 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 3 ms 1024 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 3 ms 1024 KB Output is correct
5 Correct 3 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Correct 3 ms 1024 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 3 ms 1024 KB Output is correct
10 Correct 4 ms 1152 KB Output is correct
11 Correct 29 ms 3320 KB Output is correct
12 Correct 75 ms 33272 KB Output is correct
13 Correct 73 ms 33400 KB Output is correct
14 Correct 25 ms 2552 KB Output is correct
15 Correct 26 ms 2680 KB Output is correct
16 Correct 6 ms 1408 KB Output is correct
17 Correct 19 ms 1764 KB Output is correct
18 Correct 7 ms 1152 KB Output is correct
19 Correct 5 ms 1152 KB Output is correct
20 Correct 77 ms 33272 KB Output is correct
21 Correct 8 ms 1152 KB Output is correct
22 Correct 4 ms 1024 KB Output is correct
23 Correct 11 ms 1152 KB Output is correct
24 Correct 19 ms 1252 KB Output is correct
25 Correct 20 ms 1280 KB Output is correct
26 Correct 67 ms 30200 KB Output is correct
27 Correct 69 ms 31096 KB Output is correct
28 Correct 20 ms 1252 KB Output is correct
29 Correct 6 ms 1280 KB Output is correct
30 Correct 3 ms 1152 KB Output is correct
31 Correct 5 ms 1152 KB Output is correct
32 Correct 4 ms 1152 KB Output is correct
33 Correct 26 ms 2548 KB Output is correct
34 Correct 26 ms 2560 KB Output is correct
35 Execution timed out 1069 ms 13172 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 3 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 2 ms 1024 KB Output is correct
10 Correct 4 ms 1152 KB Output is correct
11 Correct 27 ms 3328 KB Output is correct
12 Correct 75 ms 33016 KB Output is correct
13 Correct 72 ms 33272 KB Output is correct
14 Correct 25 ms 2560 KB Output is correct
15 Correct 26 ms 2560 KB Output is correct
16 Correct 7 ms 1280 KB Output is correct
17 Correct 22 ms 1792 KB Output is correct
18 Correct 7 ms 1152 KB Output is correct
19 Correct 4 ms 1152 KB Output is correct
20 Correct 74 ms 33272 KB Output is correct
21 Correct 9 ms 1152 KB Output is correct
22 Correct 5 ms 1152 KB Output is correct
23 Correct 8 ms 1148 KB Output is correct
24 Correct 19 ms 1280 KB Output is correct
25 Correct 21 ms 1280 KB Output is correct
26 Correct 69 ms 30200 KB Output is correct
27 Correct 70 ms 31068 KB Output is correct
28 Correct 20 ms 1280 KB Output is correct
29 Correct 6 ms 1408 KB Output is correct
30 Correct 3 ms 1024 KB Output is correct
31 Correct 4 ms 1280 KB Output is correct
32 Correct 4 ms 1152 KB Output is correct
33 Correct 26 ms 2552 KB Output is correct
34 Correct 26 ms 2576 KB Output is correct
35 Execution timed out 1062 ms 12860 KB Time limit exceeded
36 Halted 0 ms 0 KB -