# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110723 | 2024-11-10T09:20:34 Z | hungnt | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 611 ms | 5324 KB |
#pragma GCC optimize("O3") #pragma GCC optimize("O1") #pragma GCC optimize("O1") #pragma GCC optimize("unroll-loops") #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #include <bits/stdc++.h> #define BIT(x, k) (((x) >> (k)) & 1) #define on(x, k) ((x) ^ (1ll << (k))) #define pii pair<int, int> #define fi first #define se second #define all(x) x.begin(), x.end() #define ll long long using namespace std; const int N = 50002; int n, m; int a[N]; vector<int> adj[N]; ll dp[N]; signed main() { // ios_base::sync_with_stdio(0); // cin.tie(0);cout.tie(0); #define TASK "TASK" if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } cin >> n >> m; for(int i = 0, x; i < m; i++) { cin >> a[i] >> x; adj[a[i]].push_back(x); } priority_queue<pii, vector<pii>, greater<pii>> pq; memset(dp, 0x3f, sizeof dp); dp[a[0]] = 0; pq.push({0, a[0]}); while(!pq.empty()) { pii tmp = pq.top();pq.pop(); int u = tmp.se; if(dp[u] != tmp.fi) continue; for(auto &step : adj[u]) { int w = tmp.fi; for(int v = u + step; v < n; v += step) { if (dp[v] > ++w) { dp[v] = w; pq.push({dp[v], v}); } } w = tmp.fi; for(int v = u - step; v >= 0; v -= step) { if (dp[v] > ++w) { dp[v] = w; pq.push({dp[v], v}); } } } } if(dp[a[1]] < dp[n]) cout << dp[a[1]]; else cout << -1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1872 KB | Output is correct |
2 | Correct | 2 ms | 1872 KB | Output is correct |
3 | Correct | 2 ms | 1872 KB | Output is correct |
4 | Correct | 2 ms | 1872 KB | Output is correct |
5 | Correct | 2 ms | 1872 KB | Output is correct |
6 | Correct | 2 ms | 1872 KB | Output is correct |
7 | Correct | 2 ms | 1872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1872 KB | Output is correct |
2 | Correct | 2 ms | 1872 KB | Output is correct |
3 | Correct | 2 ms | 1872 KB | Output is correct |
4 | Correct | 2 ms | 1872 KB | Output is correct |
5 | Correct | 2 ms | 1872 KB | Output is correct |
6 | Correct | 2 ms | 1852 KB | Output is correct |
7 | Correct | 2 ms | 1872 KB | Output is correct |
8 | Correct | 2 ms | 1872 KB | Output is correct |
9 | Correct | 2 ms | 1872 KB | Output is correct |
10 | Correct | 2 ms | 1872 KB | Output is correct |
11 | Correct | 2 ms | 1932 KB | Output is correct |
12 | Correct | 2 ms | 1872 KB | Output is correct |
13 | Correct | 2 ms | 2036 KB | Output is correct |
14 | Correct | 2 ms | 1872 KB | Output is correct |
15 | Correct | 2 ms | 1872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1872 KB | Output is correct |
2 | Correct | 2 ms | 1872 KB | Output is correct |
3 | Correct | 2 ms | 1872 KB | Output is correct |
4 | Correct | 2 ms | 1872 KB | Output is correct |
5 | Correct | 2 ms | 1872 KB | Output is correct |
6 | Correct | 3 ms | 1872 KB | Output is correct |
7 | Correct | 2 ms | 1872 KB | Output is correct |
8 | Correct | 2 ms | 1872 KB | Output is correct |
9 | Correct | 2 ms | 1872 KB | Output is correct |
10 | Correct | 2 ms | 1872 KB | Output is correct |
11 | Correct | 3 ms | 1872 KB | Output is correct |
12 | Correct | 2 ms | 1872 KB | Output is correct |
13 | Correct | 2 ms | 1872 KB | Output is correct |
14 | Correct | 2 ms | 1872 KB | Output is correct |
15 | Correct | 2 ms | 1968 KB | Output is correct |
16 | Correct | 2 ms | 2044 KB | Output is correct |
17 | Correct | 4 ms | 1872 KB | Output is correct |
18 | Correct | 2 ms | 1872 KB | Output is correct |
19 | Correct | 2 ms | 1872 KB | Output is correct |
20 | Correct | 5 ms | 1872 KB | Output is correct |
21 | Correct | 2 ms | 1872 KB | Output is correct |
22 | Correct | 2 ms | 1872 KB | Output is correct |
23 | Correct | 3 ms | 1872 KB | Output is correct |
24 | Correct | 3 ms | 1872 KB | Output is correct |
25 | Correct | 3 ms | 1872 KB | Output is correct |
26 | Correct | 4 ms | 2044 KB | Output is correct |
27 | Correct | 4 ms | 1872 KB | Output is correct |
28 | Correct | 3 ms | 1872 KB | Output is correct |
29 | Correct | 3 ms | 2128 KB | Output is correct |
30 | Correct | 2 ms | 1872 KB | Output is correct |
31 | Correct | 2 ms | 2128 KB | Output is correct |
32 | Correct | 3 ms | 2128 KB | Output is correct |
33 | Correct | 4 ms | 2128 KB | Output is correct |
34 | Correct | 6 ms | 2128 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1872 KB | Output is correct |
2 | Correct | 2 ms | 1872 KB | Output is correct |
3 | Correct | 2 ms | 1872 KB | Output is correct |
4 | Correct | 2 ms | 1872 KB | Output is correct |
5 | Correct | 2 ms | 1872 KB | Output is correct |
6 | Correct | 3 ms | 1872 KB | Output is correct |
7 | Correct | 2 ms | 2012 KB | Output is correct |
8 | Correct | 3 ms | 1872 KB | Output is correct |
9 | Correct | 3 ms | 1872 KB | Output is correct |
10 | Correct | 2 ms | 1872 KB | Output is correct |
11 | Correct | 2 ms | 1872 KB | Output is correct |
12 | Correct | 3 ms | 1872 KB | Output is correct |
13 | Correct | 2 ms | 2044 KB | Output is correct |
14 | Correct | 3 ms | 1872 KB | Output is correct |
15 | Correct | 3 ms | 1872 KB | Output is correct |
16 | Correct | 2 ms | 1872 KB | Output is correct |
17 | Correct | 3 ms | 1872 KB | Output is correct |
18 | Correct | 2 ms | 1872 KB | Output is correct |
19 | Correct | 2 ms | 1872 KB | Output is correct |
20 | Correct | 7 ms | 1872 KB | Output is correct |
21 | Correct | 3 ms | 1872 KB | Output is correct |
22 | Correct | 2 ms | 1872 KB | Output is correct |
23 | Correct | 3 ms | 1872 KB | Output is correct |
24 | Correct | 4 ms | 2052 KB | Output is correct |
25 | Correct | 3 ms | 1872 KB | Output is correct |
26 | Correct | 5 ms | 2040 KB | Output is correct |
27 | Correct | 5 ms | 1872 KB | Output is correct |
28 | Correct | 3 ms | 1872 KB | Output is correct |
29 | Correct | 3 ms | 2128 KB | Output is correct |
30 | Correct | 2 ms | 1872 KB | Output is correct |
31 | Correct | 3 ms | 2128 KB | Output is correct |
32 | Correct | 3 ms | 1872 KB | Output is correct |
33 | Correct | 4 ms | 2128 KB | Output is correct |
34 | Correct | 4 ms | 2128 KB | Output is correct |
35 | Correct | 11 ms | 2128 KB | Output is correct |
36 | Correct | 4 ms | 1872 KB | Output is correct |
37 | Correct | 9 ms | 2128 KB | Output is correct |
38 | Correct | 12 ms | 2428 KB | Output is correct |
39 | Correct | 12 ms | 2384 KB | Output is correct |
40 | Correct | 12 ms | 2384 KB | Output is correct |
41 | Correct | 12 ms | 2384 KB | Output is correct |
42 | Correct | 38 ms | 2264 KB | Output is correct |
43 | Correct | 40 ms | 2128 KB | Output is correct |
44 | Correct | 46 ms | 2300 KB | Output is correct |
45 | Correct | 12 ms | 2384 KB | Output is correct |
46 | Correct | 11 ms | 2384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1872 KB | Output is correct |
2 | Correct | 2 ms | 1872 KB | Output is correct |
3 | Correct | 2 ms | 1872 KB | Output is correct |
4 | Correct | 2 ms | 1872 KB | Output is correct |
5 | Correct | 3 ms | 1872 KB | Output is correct |
6 | Correct | 2 ms | 1872 KB | Output is correct |
7 | Correct | 2 ms | 1872 KB | Output is correct |
8 | Correct | 2 ms | 2048 KB | Output is correct |
9 | Correct | 2 ms | 1872 KB | Output is correct |
10 | Correct | 2 ms | 1872 KB | Output is correct |
11 | Correct | 3 ms | 1872 KB | Output is correct |
12 | Correct | 2 ms | 1872 KB | Output is correct |
13 | Correct | 3 ms | 1872 KB | Output is correct |
14 | Correct | 2 ms | 1872 KB | Output is correct |
15 | Correct | 3 ms | 1900 KB | Output is correct |
16 | Correct | 3 ms | 1884 KB | Output is correct |
17 | Correct | 3 ms | 1872 KB | Output is correct |
18 | Correct | 3 ms | 1872 KB | Output is correct |
19 | Correct | 2 ms | 1872 KB | Output is correct |
20 | Correct | 5 ms | 1872 KB | Output is correct |
21 | Correct | 2 ms | 1872 KB | Output is correct |
22 | Correct | 2 ms | 1872 KB | Output is correct |
23 | Correct | 2 ms | 2056 KB | Output is correct |
24 | Correct | 3 ms | 1872 KB | Output is correct |
25 | Correct | 3 ms | 1872 KB | Output is correct |
26 | Correct | 4 ms | 2044 KB | Output is correct |
27 | Correct | 7 ms | 1872 KB | Output is correct |
28 | Correct | 3 ms | 1872 KB | Output is correct |
29 | Correct | 4 ms | 2128 KB | Output is correct |
30 | Correct | 3 ms | 1872 KB | Output is correct |
31 | Correct | 3 ms | 2128 KB | Output is correct |
32 | Correct | 3 ms | 2044 KB | Output is correct |
33 | Correct | 4 ms | 2128 KB | Output is correct |
34 | Correct | 4 ms | 2128 KB | Output is correct |
35 | Correct | 10 ms | 2128 KB | Output is correct |
36 | Correct | 4 ms | 2040 KB | Output is correct |
37 | Correct | 8 ms | 2384 KB | Output is correct |
38 | Correct | 11 ms | 2348 KB | Output is correct |
39 | Correct | 13 ms | 2396 KB | Output is correct |
40 | Correct | 12 ms | 2384 KB | Output is correct |
41 | Correct | 12 ms | 2384 KB | Output is correct |
42 | Correct | 39 ms | 2220 KB | Output is correct |
43 | Correct | 40 ms | 2128 KB | Output is correct |
44 | Correct | 39 ms | 2260 KB | Output is correct |
45 | Correct | 11 ms | 2384 KB | Output is correct |
46 | Correct | 11 ms | 2384 KB | Output is correct |
47 | Correct | 29 ms | 3024 KB | Output is correct |
48 | Correct | 10 ms | 2384 KB | Output is correct |
49 | Correct | 9 ms | 2392 KB | Output is correct |
50 | Correct | 8 ms | 2396 KB | Output is correct |
51 | Correct | 26 ms | 3772 KB | Output is correct |
52 | Correct | 27 ms | 3280 KB | Output is correct |
53 | Correct | 22 ms | 3292 KB | Output is correct |
54 | Correct | 3 ms | 2128 KB | Output is correct |
55 | Correct | 4 ms | 2128 KB | Output is correct |
56 | Correct | 598 ms | 3408 KB | Output is correct |
57 | Correct | 37 ms | 5064 KB | Output is correct |
58 | Correct | 611 ms | 2384 KB | Output is correct |
59 | Correct | 461 ms | 2384 KB | Output is correct |
60 | Correct | 573 ms | 2384 KB | Output is correct |
61 | Correct | 445 ms | 2496 KB | Output is correct |
62 | Correct | 15 ms | 2896 KB | Output is correct |
63 | Correct | 30 ms | 3508 KB | Output is correct |
64 | Correct | 30 ms | 5324 KB | Output is correct |
65 | Correct | 36 ms | 5324 KB | Output is correct |
66 | Correct | 46 ms | 5324 KB | Output is correct |
67 | Correct | 50 ms | 5320 KB | Output is correct |