Submission #948076

# Submission time Handle Problem Language Result Execution time Memory
948076 2024-03-17T14:49:41 Z 4QT0R Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 2240 KB
#include <bits/stdc++.h>
using namespace std;

struct info{
	int badge;
	int cur_pos;
	int nr_of_jumps;
};

bool vis[30002];
deque<info> dq;
vector<int> doges[30002];
int jmp[30002];
int n,m;

void bfs01(int doge, int pos, int kon){
	dq.push_back({doge,pos,0});
	dq.push_back({-doge,pos,0});
	vis[doge]=true;
	while(dq.size()){
		info now=dq.front();
		dq.pop_front();
		if (now.cur_pos==kon){
			cout << now.nr_of_jumps << '\n';
			return;
		}
		for (auto u : doges[now.cur_pos])if (!vis[u]){
			vis[u]=true;
			if (jmp[u]==jmp[abs(now.badge)])continue;
			dq.push_front({u,now.cur_pos,now.nr_of_jumps});
			dq.push_front({-u,now.cur_pos,now.nr_of_jumps});
		}
		if (now.cur_pos>=jmp[abs(now.badge)] && now.badge<0){
			dq.push_back({now.badge,now.cur_pos-jmp[abs(now.badge)],now.nr_of_jumps+1});
		}
		if (now.cur_pos+jmp[abs(now.badge)]<n && now.badge>0){
			dq.push_back({now.badge,now.cur_pos+jmp[now.badge],now.nr_of_jumps+1});
		}
	}
	cout << "-1\n";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int b,p,st,nd;
	cin >> n >> m;
	cin >> st >> jmp[1];
	doges[st].push_back(1);
	cin >> nd >> p;
	for (int i = 2; i<m; i++){
		cin >> b >> jmp[i];
		doges[b].push_back(i);
	}
	bfs01(1,st,nd);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1272 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1112 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1112 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1116 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 2 ms 1116 KB Output is correct
32 Correct 1 ms 1112 KB Output is correct
33 Correct 2 ms 1116 KB Output is correct
34 Correct 2 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1268 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1112 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1112 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1112 KB Output is correct
27 Correct 1 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1116 KB Output is correct
34 Correct 2 ms 1112 KB Output is correct
35 Correct 6 ms 1628 KB Output is correct
36 Correct 1 ms 1112 KB Output is correct
37 Correct 4 ms 1628 KB Output is correct
38 Correct 5 ms 1628 KB Output is correct
39 Correct 4 ms 1368 KB Output is correct
40 Correct 5 ms 1368 KB Output is correct
41 Correct 7 ms 1628 KB Output is correct
42 Correct 4 ms 1372 KB Output is correct
43 Correct 4 ms 1372 KB Output is correct
44 Correct 4 ms 1372 KB Output is correct
45 Correct 21 ms 1884 KB Output is correct
46 Correct 19 ms 1700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1120 KB Output is correct
17 Correct 1 ms 1120 KB Output is correct
18 Correct 1 ms 1120 KB Output is correct
19 Correct 1 ms 1120 KB Output is correct
20 Correct 2 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 1 ms 1112 KB Output is correct
27 Correct 1 ms 1112 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 2 ms 1112 KB Output is correct
30 Correct 1 ms 1112 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1112 KB Output is correct
34 Correct 2 ms 1116 KB Output is correct
35 Correct 6 ms 1628 KB Output is correct
36 Correct 1 ms 1116 KB Output is correct
37 Correct 4 ms 1636 KB Output is correct
38 Correct 6 ms 1628 KB Output is correct
39 Correct 5 ms 1372 KB Output is correct
40 Correct 5 ms 1372 KB Output is correct
41 Correct 7 ms 1628 KB Output is correct
42 Correct 4 ms 1372 KB Output is correct
43 Correct 3 ms 1368 KB Output is correct
44 Correct 4 ms 1372 KB Output is correct
45 Correct 21 ms 1888 KB Output is correct
46 Correct 22 ms 1864 KB Output is correct
47 Correct 5 ms 1628 KB Output is correct
48 Correct 5 ms 1628 KB Output is correct
49 Correct 4 ms 1628 KB Output is correct
50 Correct 3 ms 1368 KB Output is correct
51 Correct 8 ms 1968 KB Output is correct
52 Correct 8 ms 1884 KB Output is correct
53 Correct 6 ms 1884 KB Output is correct
54 Correct 1 ms 1116 KB Output is correct
55 Correct 1 ms 1116 KB Output is correct
56 Correct 5 ms 2240 KB Output is correct
57 Correct 1 ms 1116 KB Output is correct
58 Execution timed out 1097 ms 2148 KB Time limit exceeded
59 Halted 0 ms 0 KB -