Submission #972118

# Submission time Handle Problem Language Result Execution time Memory
972118 2024-04-30T06:26:31 Z Halym2007 Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
154 ms 66376 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define pii pair <int, int>
const int N = 3e4 + 5;

map <int, bool> m[N];
vector <pii> v[N];
vector <int> q[N];
int n, k, dis[N], a[N], b[N];

priority_queue <pii, vector <pii>, greater <pii>> p;

int main () {
//	freopen ("input.txt", "r", stdin);
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		cin >> a[i] >> b[i];
		if (m[a[i]].find (b[i]) == m[a[i]].end()) {
			q[a[i]].pb (b[i]);
			m[a[i]][b[i]] = 1;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j : q[i]) {
			int val = i + j;
			int bal = 1;
			while (val < n) {
				v[i].pb ({val, bal});
				if (m[val].find (j) != m[val].end()) {
					break;
				}
				bal++;
				val += j;
			}
			val = i - j;
			bal = 1;
			while (val >= 0) {
				v[i].pb ({val, bal});
				if (m[val].find (j) != m[val].end()) {
					break;
				}
				bal++;
				val -= j;
			}
		}
	}
	for (int i = 0; i < n; ++i) {
		dis[i] = 1e9;
	}
	p.push ({0, a[0]});
	dis[a[0]] = 0;
	while (!p.empty()) {
		int x = p.top().ss;
		p.pop();
		for (pii i : v[x]) {
			if (dis[i.ff] > dis[x] + i.ss) {
				dis[i.ff] = dis[x] + i.ss;
				p.push({dis[i.ff], i.ff});
			}
		}
	}
	if (dis[a[1]] == 1e9) dis[a[1]] = -1;
	cout << dis[a[1]];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 1 ms 3420 KB Output is correct
10 Correct 1 ms 3420 KB Output is correct
11 Correct 2 ms 3420 KB Output is correct
12 Correct 2 ms 3420 KB Output is correct
13 Correct 2 ms 3420 KB Output is correct
14 Correct 2 ms 3420 KB Output is correct
15 Correct 3 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3416 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3420 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 1 ms 3420 KB Output is correct
10 Correct 1 ms 3420 KB Output is correct
11 Correct 2 ms 3420 KB Output is correct
12 Correct 2 ms 3420 KB Output is correct
13 Correct 2 ms 3420 KB Output is correct
14 Correct 2 ms 3416 KB Output is correct
15 Correct 2 ms 3420 KB Output is correct
16 Correct 2 ms 3420 KB Output is correct
17 Correct 2 ms 3672 KB Output is correct
18 Correct 2 ms 3420 KB Output is correct
19 Correct 1 ms 3536 KB Output is correct
20 Correct 2 ms 3676 KB Output is correct
21 Correct 2 ms 3672 KB Output is correct
22 Correct 2 ms 3676 KB Output is correct
23 Correct 2 ms 3420 KB Output is correct
24 Correct 3 ms 3928 KB Output is correct
25 Correct 3 ms 3676 KB Output is correct
26 Correct 2 ms 3516 KB Output is correct
27 Correct 2 ms 3420 KB Output is correct
28 Correct 2 ms 3676 KB Output is correct
29 Correct 3 ms 4184 KB Output is correct
30 Correct 2 ms 3672 KB Output is correct
31 Correct 2 ms 3676 KB Output is correct
32 Correct 2 ms 3672 KB Output is correct
33 Correct 5 ms 4700 KB Output is correct
34 Correct 5 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3420 KB Output is correct
2 Correct 1 ms 3420 KB Output is correct
3 Correct 1 ms 3420 KB Output is correct
4 Correct 1 ms 3420 KB Output is correct
5 Correct 1 ms 3420 KB Output is correct
6 Correct 1 ms 3440 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 1 ms 3420 KB Output is correct
10 Correct 1 ms 3420 KB Output is correct
11 Correct 2 ms 3420 KB Output is correct
12 Correct 2 ms 3420 KB Output is correct
13 Correct 1 ms 3432 KB Output is correct
14 Correct 2 ms 3420 KB Output is correct
15 Correct 2 ms 3420 KB Output is correct
16 Correct 1 ms 3420 KB Output is correct
17 Correct 3 ms 3676 KB Output is correct
18 Correct 2 ms 3420 KB Output is correct
19 Correct 1 ms 3420 KB Output is correct
20 Correct 2 ms 3684 KB Output is correct
21 Correct 2 ms 3420 KB Output is correct
22 Correct 2 ms 3420 KB Output is correct
23 Correct 2 ms 3600 KB Output is correct
24 Correct 3 ms 3676 KB Output is correct
25 Correct 3 ms 3700 KB Output is correct
26 Correct 2 ms 3420 KB Output is correct
27 Correct 2 ms 3420 KB Output is correct
28 Correct 2 ms 3676 KB Output is correct
29 Correct 3 ms 4188 KB Output is correct
30 Correct 2 ms 3676 KB Output is correct
31 Correct 3 ms 3676 KB Output is correct
32 Correct 2 ms 3676 KB Output is correct
33 Correct 5 ms 4792 KB Output is correct
34 Correct 5 ms 4700 KB Output is correct
35 Correct 18 ms 5812 KB Output is correct
36 Correct 5 ms 3932 KB Output is correct
37 Correct 22 ms 6480 KB Output is correct
38 Correct 24 ms 6848 KB Output is correct
39 Correct 24 ms 6992 KB Output is correct
40 Correct 28 ms 7000 KB Output is correct
41 Correct 24 ms 7012 KB Output is correct
42 Correct 11 ms 3688 KB Output is correct
43 Correct 11 ms 3688 KB Output is correct
44 Correct 11 ms 3776 KB Output is correct
45 Correct 23 ms 9560 KB Output is correct
46 Correct 24 ms 9308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 3432 KB Output is correct
2 Correct 1 ms 3432 KB Output is correct
3 Correct 1 ms 3260 KB Output is correct
4 Correct 1 ms 3432 KB Output is correct
5 Correct 1 ms 3432 KB Output is correct
6 Correct 2 ms 3432 KB Output is correct
7 Correct 1 ms 3420 KB Output is correct
8 Correct 1 ms 3420 KB Output is correct
9 Correct 2 ms 3420 KB Output is correct
10 Correct 1 ms 3420 KB Output is correct
11 Correct 2 ms 3416 KB Output is correct
12 Correct 3 ms 3420 KB Output is correct
13 Correct 1 ms 3420 KB Output is correct
14 Correct 2 ms 3420 KB Output is correct
15 Correct 2 ms 3416 KB Output is correct
16 Correct 3 ms 3420 KB Output is correct
17 Correct 4 ms 3672 KB Output is correct
18 Correct 2 ms 3416 KB Output is correct
19 Correct 2 ms 3420 KB Output is correct
20 Correct 2 ms 3420 KB Output is correct
21 Correct 1 ms 3420 KB Output is correct
22 Correct 2 ms 3420 KB Output is correct
23 Correct 2 ms 3420 KB Output is correct
24 Correct 4 ms 3676 KB Output is correct
25 Correct 4 ms 3672 KB Output is correct
26 Correct 2 ms 3420 KB Output is correct
27 Correct 2 ms 3420 KB Output is correct
28 Correct 3 ms 3676 KB Output is correct
29 Correct 3 ms 4188 KB Output is correct
30 Correct 2 ms 3672 KB Output is correct
31 Correct 2 ms 3676 KB Output is correct
32 Correct 2 ms 3676 KB Output is correct
33 Correct 5 ms 4700 KB Output is correct
34 Correct 5 ms 4892 KB Output is correct
35 Correct 21 ms 5980 KB Output is correct
36 Correct 4 ms 3932 KB Output is correct
37 Correct 18 ms 6532 KB Output is correct
38 Correct 25 ms 7000 KB Output is correct
39 Correct 25 ms 6996 KB Output is correct
40 Correct 24 ms 6944 KB Output is correct
41 Correct 23 ms 6992 KB Output is correct
42 Correct 11 ms 3676 KB Output is correct
43 Correct 10 ms 3676 KB Output is correct
44 Correct 11 ms 3712 KB Output is correct
45 Correct 30 ms 9528 KB Output is correct
46 Correct 24 ms 9296 KB Output is correct
47 Correct 47 ms 14028 KB Output is correct
48 Correct 20 ms 7420 KB Output is correct
49 Correct 19 ms 6492 KB Output is correct
50 Correct 13 ms 5980 KB Output is correct
51 Correct 39 ms 9428 KB Output is correct
52 Correct 41 ms 9872 KB Output is correct
53 Correct 25 ms 7128 KB Output is correct
54 Correct 3 ms 3676 KB Output is correct
55 Correct 4 ms 4312 KB Output is correct
56 Correct 18 ms 6748 KB Output is correct
57 Correct 33 ms 12512 KB Output is correct
58 Correct 11 ms 4560 KB Output is correct
59 Correct 15 ms 4828 KB Output is correct
60 Correct 15 ms 5592 KB Output is correct
61 Correct 18 ms 4828 KB Output is correct
62 Correct 28 ms 10972 KB Output is correct
63 Correct 67 ms 26576 KB Output is correct
64 Correct 70 ms 29760 KB Output is correct
65 Correct 93 ms 40644 KB Output is correct
66 Correct 154 ms 66376 KB Output is correct
67 Correct 150 ms 66364 KB Output is correct