답안 #660800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660800 2022-11-23T08:53:00 Z velislavgarkov Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
300 ms 262144 KB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int MAXN=6e4+10;
vector <pair <int,int> > v[MAXN];
priority_queue <pair <int,int> > q;
int ans[MAXN];
void dejkstra(int start) {
    ans[start]=0;
    q.push({0,start});
    while (!q.empty()) {
        int x=q.top().second;
        if (-q.top().first!=ans[x]) {
            q.pop();
            continue;
        }
        q.pop();
        for (auto i:v[x]) {
            if (ans[i.first]==-1 || ans[i.first]>ans[x]+i.second) {
                ans[i.first]=ans[x]+i.second;
                q.push({-ans[i.first],i.first});
            }
        }
    }
}
int main () {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, beg, steps, start, ed;
    cin >> n >> m;
    for (int j=0;j<m;j++) {
        cin >> beg >> steps;
        if (j==0) start=beg;
        if (j==1) ed=beg;
        int br=1;
        for (int i=beg+steps;i<n;i+=steps) {
            v[beg].push_back({i,br});
            br++;
        }
        br=1;
        for (int i=beg-steps;i>=0;i-=steps) {
            v[beg].push_back({i,br});
            br++;
        }
    }
    for (int i=0;i<n+m;i++) ans[i]=-1;
    dejkstra(start);
    cout << ans[ed] << endl;
    return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:50:19: warning: 'ed' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |     cout << ans[ed] << endl;
      |                   ^
skyscraper.cpp:49:13: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |     dejkstra(start);
      |     ~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1620 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1748 KB Output is correct
12 Correct 5 ms 3920 KB Output is correct
13 Correct 4 ms 3924 KB Output is correct
14 Correct 1 ms 1748 KB Output is correct
15 Correct 1 ms 1748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 2 ms 1620 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1748 KB Output is correct
12 Correct 5 ms 3920 KB Output is correct
13 Correct 5 ms 3928 KB Output is correct
14 Correct 1 ms 1752 KB Output is correct
15 Correct 1 ms 1748 KB Output is correct
16 Correct 2 ms 1748 KB Output is correct
17 Correct 2 ms 2004 KB Output is correct
18 Correct 1 ms 1748 KB Output is correct
19 Correct 1 ms 1748 KB Output is correct
20 Correct 53 ms 33856 KB Output is correct
21 Correct 1 ms 1748 KB Output is correct
22 Correct 1 ms 1748 KB Output is correct
23 Correct 1 ms 1748 KB Output is correct
24 Correct 3 ms 1876 KB Output is correct
25 Correct 2 ms 1876 KB Output is correct
26 Correct 61 ms 34752 KB Output is correct
27 Correct 57 ms 34740 KB Output is correct
28 Correct 2 ms 1876 KB Output is correct
29 Correct 3 ms 2516 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 3 ms 2132 KB Output is correct
32 Correct 2 ms 2004 KB Output is correct
33 Correct 4 ms 3156 KB Output is correct
34 Correct 4 ms 3156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 2 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1620 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 1748 KB Output is correct
12 Correct 4 ms 3920 KB Output is correct
13 Correct 4 ms 3928 KB Output is correct
14 Correct 1 ms 1748 KB Output is correct
15 Correct 2 ms 1748 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 2 ms 2004 KB Output is correct
18 Correct 1 ms 1748 KB Output is correct
19 Correct 1 ms 1748 KB Output is correct
20 Correct 54 ms 33836 KB Output is correct
21 Correct 1 ms 1748 KB Output is correct
22 Correct 1 ms 1748 KB Output is correct
23 Correct 2 ms 1748 KB Output is correct
24 Correct 2 ms 1876 KB Output is correct
25 Correct 2 ms 1876 KB Output is correct
26 Correct 60 ms 34800 KB Output is correct
27 Correct 57 ms 34704 KB Output is correct
28 Correct 2 ms 1876 KB Output is correct
29 Correct 3 ms 2516 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 3 ms 2132 KB Output is correct
32 Correct 2 ms 2004 KB Output is correct
33 Correct 4 ms 3156 KB Output is correct
34 Correct 4 ms 3120 KB Output is correct
35 Correct 10 ms 3528 KB Output is correct
36 Correct 3 ms 2004 KB Output is correct
37 Correct 10 ms 5212 KB Output is correct
38 Correct 11 ms 4548 KB Output is correct
39 Correct 10 ms 4692 KB Output is correct
40 Correct 12 ms 4576 KB Output is correct
41 Correct 10 ms 4504 KB Output is correct
42 Runtime error 299 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 1 ms 1620 KB Output is correct
3 Correct 1 ms 1620 KB Output is correct
4 Correct 1 ms 1620 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1620 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1620 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 2 ms 1748 KB Output is correct
12 Correct 5 ms 3920 KB Output is correct
13 Correct 5 ms 3928 KB Output is correct
14 Correct 1 ms 1748 KB Output is correct
15 Correct 1 ms 1748 KB Output is correct
16 Correct 1 ms 1756 KB Output is correct
17 Correct 2 ms 2004 KB Output is correct
18 Correct 1 ms 1748 KB Output is correct
19 Correct 1 ms 1748 KB Output is correct
20 Correct 54 ms 33808 KB Output is correct
21 Correct 1 ms 1748 KB Output is correct
22 Correct 1 ms 1748 KB Output is correct
23 Correct 2 ms 1748 KB Output is correct
24 Correct 2 ms 1876 KB Output is correct
25 Correct 2 ms 1876 KB Output is correct
26 Correct 59 ms 34796 KB Output is correct
27 Correct 60 ms 34700 KB Output is correct
28 Correct 2 ms 1876 KB Output is correct
29 Correct 3 ms 2516 KB Output is correct
30 Correct 2 ms 2004 KB Output is correct
31 Correct 2 ms 2132 KB Output is correct
32 Correct 2 ms 2004 KB Output is correct
33 Correct 4 ms 3156 KB Output is correct
34 Correct 4 ms 3156 KB Output is correct
35 Correct 9 ms 3368 KB Output is correct
36 Correct 3 ms 1876 KB Output is correct
37 Correct 10 ms 5136 KB Output is correct
38 Correct 10 ms 4436 KB Output is correct
39 Correct 11 ms 4564 KB Output is correct
40 Correct 10 ms 4436 KB Output is correct
41 Correct 10 ms 4308 KB Output is correct
42 Runtime error 300 ms 262144 KB Execution killed with signal 9
43 Halted 0 ms 0 KB -