# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110722 | 2024-11-10T09:19:03 Z | hungnt | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 599 ms | 5364 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 | 1928 KB | Output is correct |
3 | Correct | 2 ms | 1872 KB | Output is correct |
4 | Correct | 2 ms | 2008 KB | Output is correct |
5 | Correct | 2 ms | 1872 KB | Output is correct |
6 | Correct | 2 ms | 1872 KB | Output is correct |
7 | Correct | 3 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 | 2036 KB | Output is correct |
5 | Correct | 2 ms | 2004 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 | 1872 KB | Output is correct |
9 | Correct | 2 ms | 1872 KB | Output is correct |
10 | Correct | 2 ms | 2040 KB | Output is correct |
11 | Correct | 2 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 | 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 | 1884 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 |
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 | 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 | 2 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 | 3 ms | 1872 KB | Output is correct |
19 | Correct | 3 ms | 1872 KB | Output is correct |
20 | Correct | 8 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 | 2040 KB | Output is correct |
24 | Correct | 3 ms | 1872 KB | Output is correct |
25 | Correct | 3 ms | 1872 KB | Output is correct |
26 | Correct | 6 ms | 1872 KB | Output is correct |
27 | Correct | 4 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 | 1872 KB | Output is correct |
33 | Correct | 3 ms | 2128 KB | Output is correct |
34 | Correct | 4 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 | 2 ms | 1872 KB | Output is correct |
7 | Correct | 2 ms | 2040 KB | Output is correct |
8 | Correct | 2 ms | 1872 KB | Output is correct |
9 | Correct | 4 ms | 1872 KB | Output is correct |
10 | Correct | 4 ms | 1872 KB | Output is correct |
11 | Correct | 4 ms | 1872 KB | Output is correct |
12 | Correct | 3 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 | 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 | 3 ms | 2040 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 | 2112 KB | Output is correct |
26 | Correct | 4 ms | 1872 KB | Output is correct |
27 | Correct | 5 ms | 2040 KB | Output is correct |
28 | Correct | 3 ms | 1872 KB | Output is correct |
29 | Correct | 3 ms | 2144 KB | Output is correct |
30 | Correct | 3 ms | 1872 KB | Output is correct |
31 | Correct | 3 ms | 2128 KB | Output is correct |
32 | Correct | 2 ms | 1872 KB | Output is correct |
33 | Correct | 4 ms | 2228 KB | Output is correct |
34 | Correct | 4 ms | 2128 KB | Output is correct |
35 | Correct | 10 ms | 2588 KB | Output is correct |
36 | Correct | 4 ms | 1872 KB | Output is correct |
37 | Correct | 8 ms | 2128 KB | Output is correct |
38 | Correct | 11 ms | 2384 KB | Output is correct |
39 | Correct | 10 ms | 2384 KB | Output is correct |
40 | Correct | 11 ms | 2384 KB | Output is correct |
41 | Correct | 11 ms | 2384 KB | Output is correct |
42 | Correct | 36 ms | 2172 KB | Output is correct |
43 | Correct | 38 ms | 2128 KB | Output is correct |
44 | Correct | 38 ms | 2128 KB | Output is correct |
45 | Correct | 12 ms | 2384 KB | Output is correct |
46 | Correct | 10 ms | 2388 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 | 2000 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 |
8 | Correct | 2 ms | 1872 KB | Output is correct |
9 | Correct | 2 ms | 2040 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 | 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 | 4 ms | 1896 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 | 1872 KB | Output is correct |
24 | Correct | 3 ms | 1872 KB | Output is correct |
25 | Correct | 3 ms | 2124 KB | Output is correct |
26 | Correct | 4 ms | 1872 KB | Output is correct |
27 | Correct | 4 ms | 2044 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 | 2128 KB | Output is correct |
31 | Correct | 3 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 | 4 ms | 2128 KB | Output is correct |
35 | Correct | 10 ms | 2384 KB | Output is correct |
36 | Correct | 4 ms | 1872 KB | Output is correct |
37 | Correct | 8 ms | 2128 KB | Output is correct |
38 | Correct | 11 ms | 2384 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 | 36 ms | 2324 KB | Output is correct |
43 | Correct | 38 ms | 2128 KB | Output is correct |
44 | Correct | 45 ms | 2264 KB | Output is correct |
45 | Correct | 11 ms | 2384 KB | Output is correct |
46 | Correct | 10 ms | 2348 KB | Output is correct |
47 | Correct | 18 ms | 3024 KB | Output is correct |
48 | Correct | 11 ms | 2384 KB | Output is correct |
49 | Correct | 10 ms | 2384 KB | Output is correct |
50 | Correct | 7 ms | 2384 KB | Output is correct |
51 | Correct | 29 ms | 3792 KB | Output is correct |
52 | Correct | 26 ms | 3280 KB | Output is correct |
53 | Correct | 18 ms | 3280 KB | Output is correct |
54 | Correct | 3 ms | 2128 KB | Output is correct |
55 | Correct | 3 ms | 2128 KB | Output is correct |
56 | Correct | 543 ms | 3408 KB | Output is correct |
57 | Correct | 35 ms | 5064 KB | Output is correct |
58 | Correct | 599 ms | 2488 KB | Output is correct |
59 | Correct | 455 ms | 2632 KB | Output is correct |
60 | Correct | 574 ms | 2384 KB | Output is correct |
61 | Correct | 437 ms | 2492 KB | Output is correct |
62 | Correct | 12 ms | 2896 KB | Output is correct |
63 | Correct | 27 ms | 3532 KB | Output is correct |
64 | Correct | 31 ms | 5364 KB | Output is correct |
65 | Correct | 33 ms | 5324 KB | Output is correct |
66 | Correct | 43 ms | 5324 KB | Output is correct |
67 | Correct | 45 ms | 5320 KB | Output is correct |