# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238174 | 2020-06-10T06:02:22 Z | Mercenary | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 105 ms | 6776 KB |
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "SKY" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 5e4 + 5; const int mod = 1e9 + 7; int dis[maxn] , n , m; unordered_set<int> s[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n >> m; int ft = 0 , lt = 0; for(int i = 0 ; i < m ; ++i){ int u ,v;cin >> u >> v;s[u].insert(v); if(i == 0)ft = u; if(i == 1)lt = u; } priority_queue<ii , vector<ii> , greater<ii> > pq; fill_n(dis,maxn,1e9); dis[ft] = 0;pq.push(mp(0,ft)); while(pq.size()){ auto u = pq.top();pq.pop(); if(dis[u.second] != u.first)continue; for(auto &c : s[u.second]){ int cnt = 0; for(int i = u.second + c ; i < n ; i += c){ cnt++; if(u.first + cnt < dis[i]){ dis[i] = u.first + cnt;pq.push(mp(dis[i],i)); } if(s[i].count(c))break; } cnt = 0; for(int i = u.second - c ; i >= 0 ; i -= c){ cnt++; if(u.first + cnt < dis[i]){ dis[i] = u.first + cnt;pq.push(mp(dis[i],i)); } if(s[i].count(c))break; } } } if(dis[lt] == 1e9)cout << -1; else cout << dis[lt]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3328 KB | Output is correct |
2 | Correct | 6 ms | 3200 KB | Output is correct |
3 | Correct | 6 ms | 3328 KB | Output is correct |
4 | Correct | 6 ms | 3328 KB | Output is correct |
5 | Correct | 7 ms | 3328 KB | Output is correct |
6 | Correct | 6 ms | 3328 KB | Output is correct |
7 | Correct | 6 ms | 3200 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3328 KB | Output is correct |
2 | Correct | 7 ms | 3328 KB | Output is correct |
3 | Correct | 6 ms | 3288 KB | Output is correct |
4 | Correct | 6 ms | 3200 KB | Output is correct |
5 | Correct | 7 ms | 3328 KB | Output is correct |
6 | Correct | 6 ms | 3200 KB | Output is correct |
7 | Correct | 6 ms | 3328 KB | Output is correct |
8 | Correct | 6 ms | 3328 KB | Output is correct |
9 | Correct | 6 ms | 3328 KB | Output is correct |
10 | Correct | 7 ms | 3328 KB | Output is correct |
11 | Correct | 7 ms | 3328 KB | Output is correct |
12 | Correct | 6 ms | 3328 KB | Output is correct |
13 | Correct | 7 ms | 3328 KB | Output is correct |
14 | Correct | 8 ms | 3328 KB | Output is correct |
15 | Correct | 7 ms | 3328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3200 KB | Output is correct |
2 | Correct | 6 ms | 3328 KB | Output is correct |
3 | Correct | 6 ms | 3328 KB | Output is correct |
4 | Correct | 6 ms | 3200 KB | Output is correct |
5 | Correct | 8 ms | 3328 KB | Output is correct |
6 | Correct | 6 ms | 3200 KB | Output is correct |
7 | Correct | 6 ms | 3200 KB | Output is correct |
8 | Correct | 6 ms | 3328 KB | Output is correct |
9 | Correct | 6 ms | 3328 KB | Output is correct |
10 | Correct | 6 ms | 3328 KB | Output is correct |
11 | Correct | 7 ms | 3328 KB | Output is correct |
12 | Correct | 7 ms | 3328 KB | Output is correct |
13 | Correct | 7 ms | 3328 KB | Output is correct |
14 | Correct | 7 ms | 3328 KB | Output is correct |
15 | Correct | 7 ms | 3328 KB | Output is correct |
16 | Correct | 6 ms | 3328 KB | Output is correct |
17 | Correct | 7 ms | 3328 KB | Output is correct |
18 | Correct | 6 ms | 3328 KB | Output is correct |
19 | Correct | 6 ms | 3328 KB | Output is correct |
20 | Correct | 8 ms | 3456 KB | Output is correct |
21 | Correct | 8 ms | 3328 KB | Output is correct |
22 | Correct | 6 ms | 3328 KB | Output is correct |
23 | Correct | 7 ms | 3328 KB | Output is correct |
24 | Correct | 8 ms | 3456 KB | Output is correct |
25 | Correct | 7 ms | 3456 KB | Output is correct |
26 | Correct | 6 ms | 3328 KB | Output is correct |
27 | Correct | 7 ms | 3328 KB | Output is correct |
28 | Correct | 7 ms | 3328 KB | Output is correct |
29 | Correct | 8 ms | 3456 KB | Output is correct |
30 | Correct | 7 ms | 3328 KB | Output is correct |
31 | Correct | 7 ms | 3456 KB | Output is correct |
32 | Correct | 7 ms | 3456 KB | Output is correct |
33 | Correct | 10 ms | 3584 KB | Output is correct |
34 | Correct | 9 ms | 3584 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3328 KB | Output is correct |
2 | Correct | 6 ms | 3328 KB | Output is correct |
3 | Correct | 6 ms | 3200 KB | Output is correct |
4 | Correct | 6 ms | 3328 KB | Output is correct |
5 | Correct | 6 ms | 3328 KB | Output is correct |
6 | Correct | 6 ms | 3200 KB | Output is correct |
7 | Correct | 6 ms | 3328 KB | Output is correct |
8 | Correct | 7 ms | 3328 KB | Output is correct |
9 | Correct | 6 ms | 3328 KB | Output is correct |
10 | Correct | 6 ms | 3328 KB | Output is correct |
11 | Correct | 7 ms | 3328 KB | Output is correct |
12 | Correct | 6 ms | 3328 KB | Output is correct |
13 | Correct | 6 ms | 3328 KB | Output is correct |
14 | Correct | 8 ms | 3456 KB | Output is correct |
15 | Correct | 8 ms | 3456 KB | Output is correct |
16 | Correct | 6 ms | 3328 KB | Output is correct |
17 | Correct | 7 ms | 3328 KB | Output is correct |
18 | Correct | 6 ms | 3328 KB | Output is correct |
19 | Correct | 7 ms | 3328 KB | Output is correct |
20 | Correct | 7 ms | 3456 KB | Output is correct |
21 | Correct | 6 ms | 3328 KB | Output is correct |
22 | Correct | 7 ms | 3328 KB | Output is correct |
23 | Correct | 7 ms | 3328 KB | Output is correct |
24 | Correct | 7 ms | 3456 KB | Output is correct |
25 | Correct | 8 ms | 3456 KB | Output is correct |
26 | Correct | 7 ms | 3328 KB | Output is correct |
27 | Correct | 6 ms | 3328 KB | Output is correct |
28 | Correct | 8 ms | 3328 KB | Output is correct |
29 | Correct | 8 ms | 3456 KB | Output is correct |
30 | Correct | 7 ms | 3328 KB | Output is correct |
31 | Correct | 7 ms | 3456 KB | Output is correct |
32 | Correct | 8 ms | 3456 KB | Output is correct |
33 | Correct | 9 ms | 3584 KB | Output is correct |
34 | Correct | 9 ms | 3632 KB | Output is correct |
35 | Correct | 18 ms | 4480 KB | Output is correct |
36 | Correct | 9 ms | 3584 KB | Output is correct |
37 | Correct | 18 ms | 4224 KB | Output is correct |
38 | Correct | 22 ms | 4608 KB | Output is correct |
39 | Correct | 21 ms | 4736 KB | Output is correct |
40 | Correct | 24 ms | 4864 KB | Output is correct |
41 | Correct | 22 ms | 4864 KB | Output is correct |
42 | Correct | 11 ms | 3328 KB | Output is correct |
43 | Correct | 11 ms | 3328 KB | Output is correct |
44 | Correct | 11 ms | 3456 KB | Output is correct |
45 | Correct | 19 ms | 4736 KB | Output is correct |
46 | Correct | 19 ms | 4736 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3328 KB | Output is correct |
2 | Correct | 7 ms | 3200 KB | Output is correct |
3 | Correct | 6 ms | 3328 KB | Output is correct |
4 | Correct | 6 ms | 3200 KB | Output is correct |
5 | Correct | 6 ms | 3200 KB | Output is correct |
6 | Correct | 6 ms | 3200 KB | Output is correct |
7 | Correct | 6 ms | 3200 KB | Output is correct |
8 | Correct | 7 ms | 3200 KB | Output is correct |
9 | Correct | 6 ms | 3328 KB | Output is correct |
10 | Correct | 6 ms | 3328 KB | Output is correct |
11 | Correct | 7 ms | 3328 KB | Output is correct |
12 | Correct | 7 ms | 3328 KB | Output is correct |
13 | Correct | 7 ms | 3328 KB | Output is correct |
14 | Correct | 7 ms | 3456 KB | Output is correct |
15 | Correct | 7 ms | 3328 KB | Output is correct |
16 | Correct | 6 ms | 3328 KB | Output is correct |
17 | Correct | 9 ms | 3328 KB | Output is correct |
18 | Correct | 7 ms | 3328 KB | Output is correct |
19 | Correct | 6 ms | 3328 KB | Output is correct |
20 | Correct | 7 ms | 3328 KB | Output is correct |
21 | Correct | 6 ms | 3328 KB | Output is correct |
22 | Correct | 6 ms | 3328 KB | Output is correct |
23 | Correct | 7 ms | 3328 KB | Output is correct |
24 | Correct | 7 ms | 3456 KB | Output is correct |
25 | Correct | 7 ms | 3456 KB | Output is correct |
26 | Correct | 7 ms | 3328 KB | Output is correct |
27 | Correct | 7 ms | 3328 KB | Output is correct |
28 | Correct | 8 ms | 3456 KB | Output is correct |
29 | Correct | 8 ms | 3584 KB | Output is correct |
30 | Correct | 7 ms | 3456 KB | Output is correct |
31 | Correct | 7 ms | 3456 KB | Output is correct |
32 | Correct | 7 ms | 3328 KB | Output is correct |
33 | Correct | 9 ms | 3584 KB | Output is correct |
34 | Correct | 9 ms | 3584 KB | Output is correct |
35 | Correct | 19 ms | 4480 KB | Output is correct |
36 | Correct | 8 ms | 3584 KB | Output is correct |
37 | Correct | 19 ms | 4224 KB | Output is correct |
38 | Correct | 25 ms | 4736 KB | Output is correct |
39 | Correct | 24 ms | 4736 KB | Output is correct |
40 | Correct | 22 ms | 4736 KB | Output is correct |
41 | Correct | 22 ms | 4736 KB | Output is correct |
42 | Correct | 11 ms | 3328 KB | Output is correct |
43 | Correct | 11 ms | 3328 KB | Output is correct |
44 | Correct | 11 ms | 3456 KB | Output is correct |
45 | Correct | 19 ms | 4736 KB | Output is correct |
46 | Correct | 19 ms | 4864 KB | Output is correct |
47 | Correct | 41 ms | 5120 KB | Output is correct |
48 | Correct | 16 ms | 4480 KB | Output is correct |
49 | Correct | 15 ms | 4480 KB | Output is correct |
50 | Correct | 12 ms | 4096 KB | Output is correct |
51 | Correct | 43 ms | 5504 KB | Output is correct |
52 | Correct | 42 ms | 5504 KB | Output is correct |
53 | Correct | 27 ms | 5504 KB | Output is correct |
54 | Correct | 7 ms | 3584 KB | Output is correct |
55 | Correct | 8 ms | 3456 KB | Output is correct |
56 | Correct | 19 ms | 5120 KB | Output is correct |
57 | Correct | 32 ms | 4096 KB | Output is correct |
58 | Correct | 12 ms | 3584 KB | Output is correct |
59 | Correct | 15 ms | 3464 KB | Output is correct |
60 | Correct | 15 ms | 3584 KB | Output is correct |
61 | Correct | 15 ms | 3712 KB | Output is correct |
62 | Correct | 26 ms | 5248 KB | Output is correct |
63 | Correct | 57 ms | 5756 KB | Output is correct |
64 | Correct | 59 ms | 5756 KB | Output is correct |
65 | Correct | 76 ms | 6772 KB | Output is correct |
66 | Correct | 104 ms | 6776 KB | Output is correct |
67 | Correct | 105 ms | 6776 KB | Output is correct |