# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680167 | 2023-01-10T04:23:49 Z | Do_you_copy | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 642 ms | 7652 KB |
//Then #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using ll = long long; using ld = long double; using pii = pair <int, int>; mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 1e5 + 1; //const int Mod = 1e9 + 7; //const int inf = int n, m; int d[maxN]; vector <int> S[maxN]; int s, t; void Init(){ cin >> n >> m; for (int i = 1; i <= m; ++i){ int x, y; cin >> x >> y; S[x].pb(y); if (i == 1) s = x; if (i == 2) t = x; } for (int i = 0; i < n; ++i){ sort(S[i].begin(), S[i].end()); S[i].resize(unique(S[i].begin(), S[i].end()) - S[i].begin()); } priority_queue <pii, vector <pii>, greater <pii>> PQ; memset(d, 0x3f, sizeof(d)); PQ.push({0, s}); d[s] = 0; while (!PQ.empty()){ auto u = PQ.top(); PQ.pop(); if (u.fi != d[u.se]) continue; for (int j: S[u.se]){ for (int i = 1; u.se + i * j < n; ++i){ if (d[u.se + i * j] <= d[u.se] + i) continue; d[u.se + i * j] = d[u.se] + i; PQ.push({d[u.se] + i, u.se + i * j}); } for (int i = 1; u.se - i * j >= 0; ++i){ if (d[u.se - i * j] <= d[u.se] + i) continue; d[u.se - i * j] = d[u.se] + i; PQ.push({d[u.se] + i, u.se - i * j}); } } } cout << (d[t] == 0x3f3f3f3f ? -1 : d[t]); } #define debug #define taskname "test" signed main(){ faster if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } int tt = 1; //cin >> tt; while (tt--){ Init(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); timeout << signed(double(clock()) / CLOCKS_PER_SEC * 1000); timeout.close(); #ifndef debug cerr << "Time elapsed: " << signed(double(clock()) / CLOCKS_PER_SEC * 1000) << "ms\n"; #endif // debug } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3028 KB | Output is correct |
2 | Correct | 2 ms | 3028 KB | Output is correct |
3 | Correct | 2 ms | 3028 KB | Output is correct |
4 | Correct | 3 ms | 3028 KB | Output is correct |
5 | Correct | 2 ms | 3028 KB | Output is correct |
6 | Correct | 2 ms | 3028 KB | Output is correct |
7 | Correct | 2 ms | 3028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3028 KB | Output is correct |
2 | Correct | 2 ms | 3028 KB | Output is correct |
3 | Correct | 2 ms | 3028 KB | Output is correct |
4 | Correct | 2 ms | 3060 KB | Output is correct |
5 | Correct | 2 ms | 3028 KB | Output is correct |
6 | Correct | 2 ms | 3000 KB | Output is correct |
7 | Correct | 2 ms | 3028 KB | Output is correct |
8 | Correct | 2 ms | 3028 KB | Output is correct |
9 | Correct | 2 ms | 3064 KB | Output is correct |
10 | Correct | 2 ms | 3032 KB | Output is correct |
11 | Correct | 2 ms | 3028 KB | Output is correct |
12 | Correct | 2 ms | 3028 KB | Output is correct |
13 | Correct | 3 ms | 3072 KB | Output is correct |
14 | Correct | 2 ms | 3028 KB | Output is correct |
15 | Correct | 3 ms | 3028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3064 KB | Output is correct |
2 | Correct | 2 ms | 3060 KB | Output is correct |
3 | Correct | 2 ms | 3064 KB | Output is correct |
4 | Correct | 2 ms | 3028 KB | Output is correct |
5 | Correct | 2 ms | 3064 KB | Output is correct |
6 | Correct | 2 ms | 3028 KB | Output is correct |
7 | Correct | 2 ms | 3068 KB | Output is correct |
8 | Correct | 2 ms | 3028 KB | Output is correct |
9 | Correct | 2 ms | 3028 KB | Output is correct |
10 | Correct | 2 ms | 3028 KB | Output is correct |
11 | Correct | 2 ms | 3028 KB | Output is correct |
12 | Correct | 2 ms | 3028 KB | Output is correct |
13 | Correct | 2 ms | 3028 KB | Output is correct |
14 | Correct | 2 ms | 3028 KB | Output is correct |
15 | Correct | 3 ms | 3028 KB | Output is correct |
16 | Correct | 2 ms | 3028 KB | Output is correct |
17 | Correct | 3 ms | 3028 KB | Output is correct |
18 | Correct | 2 ms | 3028 KB | Output is correct |
19 | Correct | 2 ms | 3028 KB | Output is correct |
20 | Correct | 5 ms | 3076 KB | Output is correct |
21 | Correct | 2 ms | 3028 KB | Output is correct |
22 | Correct | 2 ms | 3028 KB | Output is correct |
23 | Correct | 2 ms | 3068 KB | Output is correct |
24 | Correct | 3 ms | 3156 KB | Output is correct |
25 | Correct | 3 ms | 3156 KB | Output is correct |
26 | Correct | 2 ms | 3028 KB | Output is correct |
27 | Correct | 2 ms | 3028 KB | Output is correct |
28 | Correct | 2 ms | 3028 KB | Output is correct |
29 | Correct | 4 ms | 3196 KB | Output is correct |
30 | Correct | 2 ms | 3064 KB | Output is correct |
31 | Correct | 3 ms | 3156 KB | Output is correct |
32 | Correct | 3 ms | 3156 KB | Output is correct |
33 | Correct | 5 ms | 3540 KB | Output is correct |
34 | Correct | 5 ms | 3412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3028 KB | Output is correct |
2 | Correct | 2 ms | 3064 KB | Output is correct |
3 | Correct | 2 ms | 3028 KB | Output is correct |
4 | Correct | 2 ms | 3068 KB | Output is correct |
5 | Correct | 2 ms | 3028 KB | Output is correct |
6 | Correct | 2 ms | 3068 KB | Output is correct |
7 | Correct | 2 ms | 3060 KB | Output is correct |
8 | Correct | 2 ms | 3064 KB | Output is correct |
9 | Correct | 2 ms | 3028 KB | Output is correct |
10 | Correct | 2 ms | 3028 KB | Output is correct |
11 | Correct | 2 ms | 3028 KB | Output is correct |
12 | Correct | 2 ms | 3028 KB | Output is correct |
13 | Correct | 2 ms | 3072 KB | Output is correct |
14 | Correct | 2 ms | 3028 KB | Output is correct |
15 | Correct | 2 ms | 3028 KB | Output is correct |
16 | Correct | 2 ms | 3028 KB | Output is correct |
17 | Correct | 3 ms | 3028 KB | Output is correct |
18 | Correct | 2 ms | 3028 KB | Output is correct |
19 | Correct | 2 ms | 3028 KB | Output is correct |
20 | Correct | 6 ms | 3156 KB | Output is correct |
21 | Correct | 2 ms | 3028 KB | Output is correct |
22 | Correct | 2 ms | 3064 KB | Output is correct |
23 | Correct | 2 ms | 3028 KB | Output is correct |
24 | Correct | 3 ms | 3028 KB | Output is correct |
25 | Correct | 3 ms | 3156 KB | Output is correct |
26 | Correct | 2 ms | 3028 KB | Output is correct |
27 | Correct | 2 ms | 3028 KB | Output is correct |
28 | Correct | 2 ms | 3072 KB | Output is correct |
29 | Correct | 3 ms | 3284 KB | Output is correct |
30 | Correct | 2 ms | 3064 KB | Output is correct |
31 | Correct | 3 ms | 3196 KB | Output is correct |
32 | Correct | 3 ms | 3156 KB | Output is correct |
33 | Correct | 5 ms | 3412 KB | Output is correct |
34 | Correct | 5 ms | 3412 KB | Output is correct |
35 | Correct | 8 ms | 3516 KB | Output is correct |
36 | Correct | 3 ms | 3200 KB | Output is correct |
37 | Correct | 6 ms | 3448 KB | Output is correct |
38 | Correct | 8 ms | 3652 KB | Output is correct |
39 | Correct | 8 ms | 3576 KB | Output is correct |
40 | Correct | 8 ms | 3680 KB | Output is correct |
41 | Correct | 8 ms | 3588 KB | Output is correct |
42 | Correct | 6 ms | 3444 KB | Output is correct |
43 | Correct | 5 ms | 3412 KB | Output is correct |
44 | Correct | 9 ms | 3460 KB | Output is correct |
45 | Correct | 9 ms | 3772 KB | Output is correct |
46 | Correct | 9 ms | 3828 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3028 KB | Output is correct |
2 | Correct | 2 ms | 3156 KB | Output is correct |
3 | Correct | 2 ms | 3032 KB | Output is correct |
4 | Correct | 2 ms | 3028 KB | Output is correct |
5 | Correct | 2 ms | 3028 KB | Output is correct |
6 | Correct | 2 ms | 3060 KB | Output is correct |
7 | Correct | 2 ms | 3028 KB | Output is correct |
8 | Correct | 2 ms | 3028 KB | Output is correct |
9 | Correct | 2 ms | 3028 KB | Output is correct |
10 | Correct | 2 ms | 3060 KB | Output is correct |
11 | Correct | 3 ms | 3028 KB | Output is correct |
12 | Correct | 2 ms | 3028 KB | Output is correct |
13 | Correct | 3 ms | 3028 KB | Output is correct |
14 | Correct | 3 ms | 3068 KB | Output is correct |
15 | Correct | 3 ms | 3028 KB | Output is correct |
16 | Correct | 2 ms | 3028 KB | Output is correct |
17 | Correct | 3 ms | 3028 KB | Output is correct |
18 | Correct | 2 ms | 3028 KB | Output is correct |
19 | Correct | 2 ms | 3068 KB | Output is correct |
20 | Correct | 8 ms | 3284 KB | Output is correct |
21 | Correct | 2 ms | 3076 KB | Output is correct |
22 | Correct | 2 ms | 3028 KB | Output is correct |
23 | Correct | 2 ms | 3072 KB | Output is correct |
24 | Correct | 3 ms | 3156 KB | Output is correct |
25 | Correct | 3 ms | 3076 KB | Output is correct |
26 | Correct | 2 ms | 3032 KB | Output is correct |
27 | Correct | 2 ms | 3084 KB | Output is correct |
28 | Correct | 2 ms | 3112 KB | Output is correct |
29 | Correct | 3 ms | 3208 KB | Output is correct |
30 | Correct | 3 ms | 3156 KB | Output is correct |
31 | Correct | 3 ms | 3156 KB | Output is correct |
32 | Correct | 3 ms | 3156 KB | Output is correct |
33 | Correct | 5 ms | 3412 KB | Output is correct |
34 | Correct | 5 ms | 3460 KB | Output is correct |
35 | Correct | 7 ms | 3456 KB | Output is correct |
36 | Correct | 3 ms | 3156 KB | Output is correct |
37 | Correct | 6 ms | 3412 KB | Output is correct |
38 | Correct | 9 ms | 3620 KB | Output is correct |
39 | Correct | 8 ms | 3668 KB | Output is correct |
40 | Correct | 8 ms | 3576 KB | Output is correct |
41 | Correct | 8 ms | 3588 KB | Output is correct |
42 | Correct | 6 ms | 3456 KB | Output is correct |
43 | Correct | 6 ms | 3448 KB | Output is correct |
44 | Correct | 9 ms | 3412 KB | Output is correct |
45 | Correct | 10 ms | 3796 KB | Output is correct |
46 | Correct | 11 ms | 3796 KB | Output is correct |
47 | Correct | 19 ms | 4304 KB | Output is correct |
48 | Correct | 7 ms | 3684 KB | Output is correct |
49 | Correct | 7 ms | 3668 KB | Output is correct |
50 | Correct | 7 ms | 3588 KB | Output is correct |
51 | Correct | 24 ms | 5068 KB | Output is correct |
52 | Correct | 22 ms | 4560 KB | Output is correct |
53 | Correct | 14 ms | 4628 KB | Output is correct |
54 | Correct | 3 ms | 3284 KB | Output is correct |
55 | Correct | 4 ms | 3284 KB | Output is correct |
56 | Correct | 642 ms | 4564 KB | Output is correct |
57 | Correct | 38 ms | 5320 KB | Output is correct |
58 | Correct | 8 ms | 3540 KB | Output is correct |
59 | Correct | 8 ms | 3668 KB | Output is correct |
60 | Correct | 8 ms | 3540 KB | Output is correct |
61 | Correct | 9 ms | 3584 KB | Output is correct |
62 | Correct | 10 ms | 4308 KB | Output is correct |
63 | Correct | 28 ms | 5712 KB | Output is correct |
64 | Correct | 30 ms | 5620 KB | Output is correct |
65 | Correct | 38 ms | 5700 KB | Output is correct |
66 | Correct | 78 ms | 7644 KB | Output is correct |
67 | Correct | 76 ms | 7652 KB | Output is correct |