답안 #969783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969783 2024-04-25T15:07:05 Z Pring Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 69592 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

const int MXN = 30005, INF = 1e9;
int n, m, pos[MXN], p[MXN];
int dis[MXN];
vector<int> v[MXN];
priority_queue<pii, vector<pii>, greater<pii>> pq;

void DIJKSTRA(int sr) {
    auto PUSH = [&](int to, int len, int t) -> bool {
        if (dis[to] == INF) pq.push(mp(len, to));
        auto it = lower_bound(v[to].begin(), v[to].end(), t);
        if (it != v[to].end() && *it == t) return false;
        return true;
    };
    fill(dis, dis + n, INF);
    pq.push(mp(0, sr));
    while (pq.size()) {
        auto [len, id] = pq.top();
        pq.pop();
        if (dis[id] != INF) continue;
        dis[id] = len;
        if (id == pos[1]) break;
        for (auto &t : v[id]) {
            for (int i = 1; id + t * i < n; i++) {
                int to = id + t * i;
                if (!PUSH(to, len + i, t)) break;
            }
            for (int i = 1; id - t * i >= 0; i++) {
                int to = id - t * i;
                if (!PUSH(to, len + i, t)) break;
            }
        }
    }
}

void miku() {
    cin >> n >> m;
    FOR(i, 0, m) {
        cin >> pos[i] >> p[i];
        v[pos[i]].push_back(p[i]);
    }
    FOR(i, 0, n) {
        sort(v[i].begin(), v[i].end());
        v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end());
    }
    DIJKSTRA(pos[0]);
    cout << (dis[pos[1]] == INF ? -1 : dis[pos[1]]) << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}
# 결과 실행 시간 메모리 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 1 ms 1112 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 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 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1268 KB Output is correct
3 Correct 1 ms 1112 KB Output is correct
4 Correct 1 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 1 ms 1112 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 1112 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
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1312 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1112 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 2 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 7 ms 1756 KB Output is correct
30 Correct 2 ms 1372 KB Output is correct
31 Correct 3 ms 1372 KB Output is correct
32 Correct 2 ms 1408 KB Output is correct
33 Correct 15 ms 2516 KB Output is correct
34 Correct 10 ms 2268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 920 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 1 ms 1116 KB Output is correct
9 Correct 1 ms 1112 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1112 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 1112 KB Output is correct
17 Correct 1 ms 1188 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 2 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1112 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 8 ms 1756 KB Output is correct
30 Correct 2 ms 1372 KB Output is correct
31 Correct 3 ms 1372 KB Output is correct
32 Correct 3 ms 1368 KB Output is correct
33 Correct 15 ms 2264 KB Output is correct
34 Correct 10 ms 2268 KB Output is correct
35 Correct 7 ms 2264 KB Output is correct
36 Correct 2 ms 1112 KB Output is correct
37 Correct 9 ms 2516 KB Output is correct
38 Correct 7 ms 2264 KB Output is correct
39 Correct 5 ms 1628 KB Output is correct
40 Correct 5 ms 1628 KB Output is correct
41 Correct 6 ms 1880 KB Output is correct
42 Correct 4 ms 1628 KB Output is correct
43 Correct 4 ms 1628 KB Output is correct
44 Correct 4 ms 1628 KB Output is correct
45 Correct 69 ms 7124 KB Output is correct
46 Correct 44 ms 6092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 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 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 928 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 2 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 1112 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1368 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 2 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 2 ms 1116 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 8 ms 1756 KB Output is correct
30 Correct 2 ms 1372 KB Output is correct
31 Correct 3 ms 1372 KB Output is correct
32 Correct 2 ms 1372 KB Output is correct
33 Correct 16 ms 2268 KB Output is correct
34 Correct 10 ms 2268 KB Output is correct
35 Correct 8 ms 2264 KB Output is correct
36 Correct 1 ms 1116 KB Output is correct
37 Correct 7 ms 2516 KB Output is correct
38 Correct 6 ms 2264 KB Output is correct
39 Correct 5 ms 1628 KB Output is correct
40 Correct 5 ms 1788 KB Output is correct
41 Correct 6 ms 1884 KB Output is correct
42 Correct 4 ms 1628 KB Output is correct
43 Correct 4 ms 1628 KB Output is correct
44 Correct 4 ms 1648 KB Output is correct
45 Correct 69 ms 6860 KB Output is correct
46 Correct 45 ms 7884 KB Output is correct
47 Correct 16 ms 3792 KB Output is correct
48 Correct 7 ms 1884 KB Output is correct
49 Correct 5 ms 1884 KB Output is correct
50 Correct 3 ms 1628 KB Output is correct
51 Correct 16 ms 3284 KB Output is correct
52 Correct 16 ms 4304 KB Output is correct
53 Correct 7 ms 2140 KB Output is correct
54 Correct 2 ms 1368 KB Output is correct
55 Correct 2 ms 1372 KB Output is correct
56 Correct 5 ms 2396 KB Output is correct
57 Correct 2 ms 1628 KB Output is correct
58 Correct 6 ms 1884 KB Output is correct
59 Correct 6 ms 1884 KB Output is correct
60 Correct 6 ms 1880 KB Output is correct
61 Correct 6 ms 1884 KB Output is correct
62 Correct 8 ms 2392 KB Output is correct
63 Correct 187 ms 10448 KB Output is correct
64 Correct 213 ms 11720 KB Output is correct
65 Correct 526 ms 19904 KB Output is correct
66 Execution timed out 1032 ms 69592 KB Time limit exceeded
67 Halted 0 ms 0 KB -