Submission #569198

# Submission time Handle Problem Language Result Execution time Memory
569198 2022-05-27T02:48:34 Z Alan Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
264 ms 112292 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
 
vector<int> adj[30001];
 
struct node {
	int u, di, vel;
};
 
int main() {
	ios::ios_base::sync_with_stdio(false);
	cin.tie(0);
	bitset<30001> vis[30001];
	int n, m, b, p, d0 = 0, d1 = 0;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &b, &p);
		if (i == 0) d0 = b;
		if (i == 1) d1 = b;
		if (0 <= b+p && b+p < n) adj[b].push_back(p);
		if (0 <= b-p && b-p < n) adj[b].push_back(-p);
	}

	queue<node> bfs;
	bfs.push({d0, 0, 0});
	while (!bfs.empty()) {
		auto [u, di, vel] = bfs.front();
		if (u == d1) {
			cout << di << "\n";
			return 0;
		}
		bfs.pop();
		if (u+vel >= 0 && u+vel < n && vel && !vis[u][u+vel]) bfs.push({u+vel, di+1, vel}), vis[u].set(u+vel);
		for (auto& s : adj[u]) if (s && !vis[u][u+s]) bfs.push({u+s, di+1, s}), vis[u].set(u+s);
	}
	cout << "-1\n";
	
	return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d %d", &b, &p);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 61 ms 111228 KB Output is correct
2 Correct 60 ms 111044 KB Output is correct
3 Correct 67 ms 111052 KB Output is correct
4 Correct 58 ms 111152 KB Output is correct
5 Correct 57 ms 111136 KB Output is correct
6 Correct 64 ms 111076 KB Output is correct
7 Correct 65 ms 111044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 111056 KB Output is correct
2 Correct 64 ms 111148 KB Output is correct
3 Correct 59 ms 111132 KB Output is correct
4 Correct 57 ms 111064 KB Output is correct
5 Correct 61 ms 111128 KB Output is correct
6 Correct 68 ms 111076 KB Output is correct
7 Correct 62 ms 111136 KB Output is correct
8 Correct 71 ms 111096 KB Output is correct
9 Correct 56 ms 111136 KB Output is correct
10 Correct 62 ms 111280 KB Output is correct
11 Correct 57 ms 111164 KB Output is correct
12 Correct 62 ms 111072 KB Output is correct
13 Correct 72 ms 111180 KB Output is correct
14 Correct 61 ms 111192 KB Output is correct
15 Correct 57 ms 111156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 111052 KB Output is correct
2 Correct 57 ms 111140 KB Output is correct
3 Correct 61 ms 111088 KB Output is correct
4 Correct 60 ms 111064 KB Output is correct
5 Correct 58 ms 111052 KB Output is correct
6 Correct 68 ms 111140 KB Output is correct
7 Correct 56 ms 111128 KB Output is correct
8 Correct 54 ms 111048 KB Output is correct
9 Correct 55 ms 111188 KB Output is correct
10 Correct 56 ms 111152 KB Output is correct
11 Correct 60 ms 111132 KB Output is correct
12 Correct 57 ms 111148 KB Output is correct
13 Correct 54 ms 111152 KB Output is correct
14 Correct 55 ms 111156 KB Output is correct
15 Correct 62 ms 111144 KB Output is correct
16 Correct 55 ms 111096 KB Output is correct
17 Correct 57 ms 111164 KB Output is correct
18 Correct 65 ms 111068 KB Output is correct
19 Correct 68 ms 111108 KB Output is correct
20 Correct 66 ms 111264 KB Output is correct
21 Correct 63 ms 111120 KB Output is correct
22 Correct 61 ms 111144 KB Output is correct
23 Correct 62 ms 111144 KB Output is correct
24 Correct 72 ms 111088 KB Output is correct
25 Correct 74 ms 111176 KB Output is correct
26 Correct 59 ms 111136 KB Output is correct
27 Correct 60 ms 111136 KB Output is correct
28 Correct 69 ms 111268 KB Output is correct
29 Correct 60 ms 111156 KB Output is correct
30 Correct 60 ms 111172 KB Output is correct
31 Correct 58 ms 111140 KB Output is correct
32 Correct 62 ms 111156 KB Output is correct
33 Correct 61 ms 111152 KB Output is correct
34 Correct 69 ms 111144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 111148 KB Output is correct
2 Correct 62 ms 111056 KB Output is correct
3 Correct 61 ms 111132 KB Output is correct
4 Correct 57 ms 111120 KB Output is correct
5 Correct 64 ms 111052 KB Output is correct
6 Correct 66 ms 111140 KB Output is correct
7 Correct 62 ms 111100 KB Output is correct
8 Correct 58 ms 111248 KB Output is correct
9 Correct 58 ms 111136 KB Output is correct
10 Correct 61 ms 111092 KB Output is correct
11 Correct 59 ms 111080 KB Output is correct
12 Correct 55 ms 111080 KB Output is correct
13 Correct 65 ms 111132 KB Output is correct
14 Correct 62 ms 111128 KB Output is correct
15 Correct 61 ms 111148 KB Output is correct
16 Correct 60 ms 111060 KB Output is correct
17 Correct 59 ms 111156 KB Output is correct
18 Correct 56 ms 111152 KB Output is correct
19 Correct 58 ms 111104 KB Output is correct
20 Correct 59 ms 111132 KB Output is correct
21 Correct 56 ms 111112 KB Output is correct
22 Correct 59 ms 111228 KB Output is correct
23 Correct 63 ms 111060 KB Output is correct
24 Correct 61 ms 111172 KB Output is correct
25 Correct 64 ms 111140 KB Output is correct
26 Correct 65 ms 111180 KB Output is correct
27 Correct 59 ms 111160 KB Output is correct
28 Correct 60 ms 111168 KB Output is correct
29 Correct 65 ms 111156 KB Output is correct
30 Correct 60 ms 111096 KB Output is correct
31 Correct 60 ms 111036 KB Output is correct
32 Correct 63 ms 111156 KB Output is correct
33 Correct 60 ms 111116 KB Output is correct
34 Correct 66 ms 111180 KB Output is correct
35 Correct 61 ms 111684 KB Output is correct
36 Correct 63 ms 111180 KB Output is correct
37 Correct 62 ms 111692 KB Output is correct
38 Correct 66 ms 111820 KB Output is correct
39 Correct 70 ms 111600 KB Output is correct
40 Correct 63 ms 111652 KB Output is correct
41 Correct 73 ms 111624 KB Output is correct
42 Correct 73 ms 111740 KB Output is correct
43 Correct 66 ms 111744 KB Output is correct
44 Correct 77 ms 111708 KB Output is correct
45 Correct 76 ms 111948 KB Output is correct
46 Correct 71 ms 111884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 111056 KB Output is correct
2 Correct 58 ms 111188 KB Output is correct
3 Correct 63 ms 111100 KB Output is correct
4 Correct 58 ms 111064 KB Output is correct
5 Correct 55 ms 111108 KB Output is correct
6 Correct 62 ms 111040 KB Output is correct
7 Correct 66 ms 111144 KB Output is correct
8 Correct 63 ms 111140 KB Output is correct
9 Correct 59 ms 111052 KB Output is correct
10 Correct 64 ms 111052 KB Output is correct
11 Correct 57 ms 111136 KB Output is correct
12 Correct 59 ms 111128 KB Output is correct
13 Correct 58 ms 111152 KB Output is correct
14 Correct 60 ms 111164 KB Output is correct
15 Correct 58 ms 111180 KB Output is correct
16 Correct 64 ms 111052 KB Output is correct
17 Correct 57 ms 111140 KB Output is correct
18 Correct 57 ms 111148 KB Output is correct
19 Correct 56 ms 111076 KB Output is correct
20 Correct 59 ms 111140 KB Output is correct
21 Correct 59 ms 111140 KB Output is correct
22 Correct 60 ms 111132 KB Output is correct
23 Correct 61 ms 111136 KB Output is correct
24 Correct 63 ms 111180 KB Output is correct
25 Correct 57 ms 111124 KB Output is correct
26 Correct 58 ms 111096 KB Output is correct
27 Correct 57 ms 111140 KB Output is correct
28 Correct 56 ms 111108 KB Output is correct
29 Correct 65 ms 111156 KB Output is correct
30 Correct 60 ms 111052 KB Output is correct
31 Correct 69 ms 111204 KB Output is correct
32 Correct 65 ms 111052 KB Output is correct
33 Correct 61 ms 111152 KB Output is correct
34 Correct 60 ms 111084 KB Output is correct
35 Correct 66 ms 111612 KB Output is correct
36 Correct 63 ms 111124 KB Output is correct
37 Correct 72 ms 111652 KB Output is correct
38 Correct 63 ms 111840 KB Output is correct
39 Correct 61 ms 111576 KB Output is correct
40 Correct 64 ms 111652 KB Output is correct
41 Correct 76 ms 111676 KB Output is correct
42 Correct 65 ms 111732 KB Output is correct
43 Correct 63 ms 111692 KB Output is correct
44 Correct 62 ms 111748 KB Output is correct
45 Correct 72 ms 111880 KB Output is correct
46 Correct 67 ms 111908 KB Output is correct
47 Correct 65 ms 111784 KB Output is correct
48 Correct 71 ms 111652 KB Output is correct
49 Correct 76 ms 111656 KB Output is correct
50 Correct 61 ms 111548 KB Output is correct
51 Correct 68 ms 111948 KB Output is correct
52 Correct 69 ms 112108 KB Output is correct
53 Correct 73 ms 111572 KB Output is correct
54 Correct 66 ms 111156 KB Output is correct
55 Correct 57 ms 111156 KB Output is correct
56 Correct 67 ms 112292 KB Output is correct
57 Correct 58 ms 111204 KB Output is correct
58 Correct 65 ms 111648 KB Output is correct
59 Correct 71 ms 111756 KB Output is correct
60 Correct 67 ms 111656 KB Output is correct
61 Correct 65 ms 111732 KB Output is correct
62 Correct 98 ms 111948 KB Output is correct
63 Correct 148 ms 111752 KB Output is correct
64 Correct 168 ms 111824 KB Output is correct
65 Correct 177 ms 112000 KB Output is correct
66 Correct 264 ms 111936 KB Output is correct
67 Correct 211 ms 111820 KB Output is correct