Submission #499347

# Submission time Handle Problem Language Result Execution time Memory
499347 2021-12-28T04:27:57 Z pavement Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 8268 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
//#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int C = 200;
bool has[30005][205];
int N, M, st, ed, dist[30005];
vector<int> dog[30005];
priority_queue<ii, vector<ii>, greater<ii> > pq;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	for (int i = 0, B, P; i < M; i++) {
		cin >> B >> P;
		dog[B].eb(P);
		if (P <= C) has[B][P] = 1;
		if (i == 0) st = B;
		else if (i == 1) ed = B;
	}
	for (int i = 0; i < N; i++) dist[i] = 1e9;
	dist[st] = 0;
	pq.emplace(0, st);
	while (!pq.empty()) {
		auto [d, v] = pq.top();
		pq.pop();
		if (dist[v] != d) continue;
		for (auto u : dog[v]) {
			for (int i = v - u; i >= 0; i -= u) {
				if (dist[i] > d + (v - i) / u) {
					dist[i] = d + (v - i) / u;
					pq.emplace(dist[i], i);
				}
				if (u <= C && has[i][u]) break;
			}
			for (int i = v + u; i < N; i += u) {
				if (dist[i] > d + (i - v) / u) {
					dist[i] = d + (i - v) / u;
					pq.emplace(dist[i], i);
				}
				if (u <= C && has[i][u]) break;
			}
		}
	}
	cout << (dist[ed] == 1e9 ? -1 : dist[ed]) << '\n';
}

Compilation message

skyscraper.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 1032 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 2 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 972 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 2 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 972 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 1228 KB Output is correct
18 Correct 1 ms 1228 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1484 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1228 KB Output is correct
23 Correct 2 ms 1228 KB Output is correct
24 Correct 2 ms 1356 KB Output is correct
25 Correct 2 ms 1100 KB Output is correct
26 Correct 23 ms 1244 KB Output is correct
27 Correct 22 ms 1188 KB Output is correct
28 Correct 2 ms 1100 KB Output is correct
29 Correct 3 ms 1228 KB Output is correct
30 Correct 1 ms 1100 KB Output is correct
31 Correct 1 ms 1100 KB Output is correct
32 Correct 1 ms 1100 KB Output is correct
33 Correct 3 ms 1228 KB Output is correct
34 Correct 3 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 972 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 972 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 1020 KB Output is correct
12 Correct 2 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 972 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 1228 KB Output is correct
18 Correct 1 ms 1228 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 1 ms 1484 KB Output is correct
21 Correct 1 ms 1100 KB Output is correct
22 Correct 1 ms 1228 KB Output is correct
23 Correct 1 ms 1228 KB Output is correct
24 Correct 2 ms 1356 KB Output is correct
25 Correct 1 ms 1100 KB Output is correct
26 Correct 22 ms 1228 KB Output is correct
27 Correct 21 ms 1184 KB Output is correct
28 Correct 1 ms 1100 KB Output is correct
29 Correct 2 ms 1228 KB Output is correct
30 Correct 2 ms 1100 KB Output is correct
31 Correct 2 ms 1100 KB Output is correct
32 Correct 1 ms 1100 KB Output is correct
33 Correct 3 ms 1228 KB Output is correct
34 Correct 3 ms 1228 KB Output is correct
35 Correct 6 ms 1520 KB Output is correct
36 Correct 2 ms 1228 KB Output is correct
37 Correct 5 ms 1612 KB Output is correct
38 Correct 7 ms 1740 KB Output is correct
39 Correct 7 ms 1740 KB Output is correct
40 Correct 7 ms 1740 KB Output is correct
41 Correct 7 ms 1740 KB Output is correct
42 Correct 359 ms 1448 KB Output is correct
43 Correct 358 ms 1400 KB Output is correct
44 Correct 5 ms 1612 KB Output is correct
45 Correct 8 ms 1484 KB Output is correct
46 Correct 8 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 972 KB Output is correct
4 Correct 1 ms 972 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 976 KB Output is correct
12 Correct 2 ms 976 KB Output is correct
13 Correct 1 ms 976 KB Output is correct
14 Correct 1 ms 972 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 1232 KB Output is correct
18 Correct 1 ms 1320 KB Output is correct
19 Correct 1 ms 1104 KB Output is correct
20 Correct 1 ms 1488 KB Output is correct
21 Correct 1 ms 1104 KB Output is correct
22 Correct 1 ms 1232 KB Output is correct
23 Correct 1 ms 1232 KB Output is correct
24 Correct 1 ms 1360 KB Output is correct
25 Correct 2 ms 1108 KB Output is correct
26 Correct 23 ms 1232 KB Output is correct
27 Correct 21 ms 1104 KB Output is correct
28 Correct 1 ms 1104 KB Output is correct
29 Correct 2 ms 1232 KB Output is correct
30 Correct 1 ms 1104 KB Output is correct
31 Correct 1 ms 1104 KB Output is correct
32 Correct 1 ms 1104 KB Output is correct
33 Correct 3 ms 1232 KB Output is correct
34 Correct 3 ms 1232 KB Output is correct
35 Correct 5 ms 1616 KB Output is correct
36 Correct 2 ms 1232 KB Output is correct
37 Correct 6 ms 1616 KB Output is correct
38 Correct 7 ms 1752 KB Output is correct
39 Correct 8 ms 1752 KB Output is correct
40 Correct 7 ms 1740 KB Output is correct
41 Correct 7 ms 1776 KB Output is correct
42 Correct 363 ms 1452 KB Output is correct
43 Correct 353 ms 1396 KB Output is correct
44 Correct 5 ms 1612 KB Output is correct
45 Correct 8 ms 1484 KB Output is correct
46 Correct 8 ms 1484 KB Output is correct
47 Correct 17 ms 4600 KB Output is correct
48 Correct 6 ms 2324 KB Output is correct
49 Correct 6 ms 2252 KB Output is correct
50 Correct 4 ms 2052 KB Output is correct
51 Correct 23 ms 3336 KB Output is correct
52 Correct 25 ms 3528 KB Output is correct
53 Correct 14 ms 2760 KB Output is correct
54 Correct 3 ms 1292 KB Output is correct
55 Correct 3 ms 1272 KB Output is correct
56 Correct 12 ms 8268 KB Output is correct
57 Correct 25 ms 6600 KB Output is correct
58 Execution timed out 1039 ms 1612 KB Time limit exceeded
59 Halted 0 ms 0 KB -