# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
99920 | 2019-03-08T18:15:03 Z | MohamedAhmed0 | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 298 ms | 67876 KB |
#include <bits/stdc++.h> using namespace std; int main() { int n , m ; scanf("%d %d" , &n , &m) ; vector< set<int> >v(n+1) ; vector< vector< pair<int , int> > >adj(n+1) ; int s , e ; for(int i = 0 ; i < m ; ++i) { int a , b ; scanf("%d %d" , &a , &b) ; if(i == 0) s = a ; else if(i == 1) e = a ; v[a].insert(b) ; } for(int i = 0 ; i < n ; ++i) { for(auto &power : v[i]) { for(int j = 1 ; ; ++j) { int here = i+power*j ; if(here >= n) break; adj[i].push_back({here , j}) ; if(v[here].count(power)) break; } for(int j = 1; ; ++j) { int here = i-power * j ; if(here < 0) break; adj[i].push_back({here , j}) ; if(v[here].count(power)) break; } } } priority_queue< pair<int , int> , vector< pair<int , int> > , greater< pair<int , int> > >q ; q.push({0 , s}) ; int dist[n+2] ; for(int i = 0 ; i <= n ; ++i) dist[i] = 1e9 ; dist[s] = 0 ; while(!q.empty()) { pair<int , int> p = q.top(); q.pop(); int now = p.second , d = p.first ; if(now == e) return cout<<d<<"\n" , 0 ; if(d > dist[now]) continue; for(auto &i : adj[now]) { int to = i.first ; int dist2 = d + i.second ; if(dist2 < dist[to]) { dist[to] = dist2 ; q.push({dist2 , to}) ; } } } return cout<<-1<<"\n" , 0 ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 412 KB | Output is correct |
15 | Correct | 3 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 428 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 356 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 336 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
15 | Correct | 4 ms | 512 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 640 KB | Output is correct |
18 | Correct | 3 ms | 512 KB | Output is correct |
19 | Correct | 2 ms | 512 KB | Output is correct |
20 | Correct | 3 ms | 640 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 3 ms | 512 KB | Output is correct |
24 | Correct | 5 ms | 640 KB | Output is correct |
25 | Correct | 3 ms | 640 KB | Output is correct |
26 | Correct | 2 ms | 512 KB | Output is correct |
27 | Correct | 3 ms | 640 KB | Output is correct |
28 | Correct | 3 ms | 740 KB | Output is correct |
29 | Correct | 6 ms | 1280 KB | Output is correct |
30 | Correct | 3 ms | 768 KB | Output is correct |
31 | Correct | 3 ms | 896 KB | Output is correct |
32 | Correct | 3 ms | 892 KB | Output is correct |
33 | Correct | 9 ms | 2020 KB | Output is correct |
34 | Correct | 7 ms | 2048 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 284 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 4 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
15 | Correct | 3 ms | 512 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 640 KB | Output is correct |
18 | Correct | 4 ms | 640 KB | Output is correct |
19 | Correct | 2 ms | 512 KB | Output is correct |
20 | Correct | 4 ms | 640 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 512 KB | Output is correct |
23 | Correct | 4 ms | 640 KB | Output is correct |
24 | Correct | 4 ms | 768 KB | Output is correct |
25 | Correct | 3 ms | 640 KB | Output is correct |
26 | Correct | 3 ms | 640 KB | Output is correct |
27 | Correct | 3 ms | 640 KB | Output is correct |
28 | Correct | 4 ms | 768 KB | Output is correct |
29 | Correct | 6 ms | 1408 KB | Output is correct |
30 | Correct | 4 ms | 768 KB | Output is correct |
31 | Correct | 4 ms | 1024 KB | Output is correct |
32 | Correct | 4 ms | 896 KB | Output is correct |
33 | Correct | 8 ms | 2048 KB | Output is correct |
34 | Correct | 8 ms | 2048 KB | Output is correct |
35 | Correct | 36 ms | 2808 KB | Output is correct |
36 | Correct | 5 ms | 768 KB | Output is correct |
37 | Correct | 26 ms | 3584 KB | Output is correct |
38 | Correct | 33 ms | 3960 KB | Output is correct |
39 | Correct | 35 ms | 3840 KB | Output is correct |
40 | Correct | 41 ms | 3832 KB | Output is correct |
41 | Correct | 31 ms | 3960 KB | Output is correct |
42 | Correct | 12 ms | 768 KB | Output is correct |
43 | Correct | 7 ms | 768 KB | Output is correct |
44 | Correct | 9 ms | 768 KB | Output is correct |
45 | Correct | 34 ms | 6648 KB | Output is correct |
46 | Correct | 37 ms | 6648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 256 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 3 ms | 512 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
15 | Correct | 3 ms | 512 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 640 KB | Output is correct |
18 | Correct | 2 ms | 640 KB | Output is correct |
19 | Correct | 2 ms | 512 KB | Output is correct |
20 | Correct | 3 ms | 640 KB | Output is correct |
21 | Correct | 2 ms | 420 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 3 ms | 640 KB | Output is correct |
24 | Correct | 4 ms | 640 KB | Output is correct |
25 | Correct | 4 ms | 640 KB | Output is correct |
26 | Correct | 3 ms | 640 KB | Output is correct |
27 | Correct | 4 ms | 640 KB | Output is correct |
28 | Correct | 4 ms | 768 KB | Output is correct |
29 | Correct | 5 ms | 1280 KB | Output is correct |
30 | Correct | 4 ms | 768 KB | Output is correct |
31 | Correct | 4 ms | 1024 KB | Output is correct |
32 | Correct | 4 ms | 768 KB | Output is correct |
33 | Correct | 9 ms | 2048 KB | Output is correct |
34 | Correct | 8 ms | 2048 KB | Output is correct |
35 | Correct | 27 ms | 2936 KB | Output is correct |
36 | Correct | 6 ms | 896 KB | Output is correct |
37 | Correct | 32 ms | 3576 KB | Output is correct |
38 | Correct | 34 ms | 3960 KB | Output is correct |
39 | Correct | 36 ms | 3832 KB | Output is correct |
40 | Correct | 32 ms | 3832 KB | Output is correct |
41 | Correct | 41 ms | 3920 KB | Output is correct |
42 | Correct | 10 ms | 768 KB | Output is correct |
43 | Correct | 12 ms | 768 KB | Output is correct |
44 | Correct | 8 ms | 768 KB | Output is correct |
45 | Correct | 40 ms | 6648 KB | Output is correct |
46 | Correct | 51 ms | 6648 KB | Output is correct |
47 | Correct | 62 ms | 11764 KB | Output is correct |
48 | Correct | 29 ms | 5748 KB | Output is correct |
49 | Correct | 22 ms | 4864 KB | Output is correct |
50 | Correct | 19 ms | 4736 KB | Output is correct |
51 | Correct | 54 ms | 8196 KB | Output is correct |
52 | Correct | 56 ms | 8636 KB | Output is correct |
53 | Correct | 29 ms | 5364 KB | Output is correct |
54 | Correct | 8 ms | 3072 KB | Output is correct |
55 | Correct | 8 ms | 3452 KB | Output is correct |
56 | Correct | 24 ms | 5112 KB | Output is correct |
57 | Correct | 24 ms | 11384 KB | Output is correct |
58 | Correct | 15 ms | 3704 KB | Output is correct |
59 | Correct | 17 ms | 4092 KB | Output is correct |
60 | Correct | 15 ms | 4860 KB | Output is correct |
61 | Correct | 15 ms | 4224 KB | Output is correct |
62 | Correct | 51 ms | 9336 KB | Output is correct |
63 | Correct | 117 ms | 26664 KB | Output is correct |
64 | Correct | 127 ms | 29520 KB | Output is correct |
65 | Correct | 153 ms | 39552 KB | Output is correct |
66 | Correct | 298 ms | 67876 KB | Output is correct |
67 | Correct | 220 ms | 67816 KB | Output is correct |