답안 #882798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882798 2023-12-03T18:03:43 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++11
100 / 100
547 ms 226896 KB
#include <bits/stdc++.h>
#define all(aa) aa.begin(), aa.end()
#define pb push_back
#define endl ("\n")
typedef long long ll;
using namespace std;

const ll INF (1000000000000000);
const int maxn = 30005, maxm = 30005;

int n, m, target, pos, sped;
bool vis[maxn][maxn];
vector<int> v[maxn];
queue<array<int, 3>> q;

void pushq(int u, int s, int dst){
	if(u - s >= 0) q.push({u - s, s, dst});
	if(u + s < n) q.push({u+s, s, dst});
}

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int b, p;
		cin >> b >> p;
		if(i == 0) sped = p, pos = b;
		if(i != 1) v[b].pb(p);
		else target = b;
	}
	for(int i = 0; i < n; i++){
		sort(all(v[i]));
		v[i].resize(unique(all(v[i])) - v[i].begin());
	}

	q.push({pos, sped, 0});
	while(!q.empty()){
		auto [u, s, dst] = q.front(); q.pop();
		if(target == u) cout << dst, exit(0);
		if(vis[u][s]) 
			continue;
		vis[u][s] = 1;
		for(int sp : v[u])
			pushq(u, sp, dst+1);
		pushq(u, s, dst+1);
	}

	cout << -1;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:37:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |   auto [u, s, dst] = q.front(); q.pop();
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2668 KB Output is correct
7 Correct 1 ms 2664 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 3 ms 3696 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2664 KB Output is correct
3 Correct 1 ms 2672 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 4 ms 3916 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 1 ms 2676 KB Output is correct
19 Correct 1 ms 2648 KB Output is correct
20 Correct 5 ms 10844 KB Output is correct
21 Correct 1 ms 2672 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 4 ms 8716 KB Output is correct
24 Correct 5 ms 10328 KB Output is correct
25 Correct 2 ms 4188 KB Output is correct
26 Correct 4 ms 9332 KB Output is correct
27 Correct 5 ms 9820 KB Output is correct
28 Correct 6 ms 11100 KB Output is correct
29 Correct 10 ms 10584 KB Output is correct
30 Correct 5 ms 10588 KB Output is correct
31 Correct 6 ms 10760 KB Output is correct
32 Correct 8 ms 10648 KB Output is correct
33 Correct 10 ms 11668 KB Output is correct
34 Correct 9 ms 11740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2668 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2452 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 2 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 4 ms 3816 KB Output is correct
15 Correct 2 ms 2940 KB Output is correct
16 Correct 1 ms 2672 KB Output is correct
17 Correct 2 ms 4472 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2756 KB Output is correct
20 Correct 6 ms 10588 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 4 ms 8796 KB Output is correct
24 Correct 5 ms 10380 KB Output is correct
25 Correct 2 ms 4188 KB Output is correct
26 Correct 5 ms 9336 KB Output is correct
27 Correct 5 ms 9816 KB Output is correct
28 Correct 7 ms 11104 KB Output is correct
29 Correct 6 ms 10584 KB Output is correct
30 Correct 5 ms 10584 KB Output is correct
31 Correct 5 ms 10588 KB Output is correct
32 Correct 6 ms 10504 KB Output is correct
33 Correct 12 ms 11864 KB Output is correct
34 Correct 10 ms 11740 KB Output is correct
35 Correct 15 ms 9852 KB Output is correct
36 Correct 3 ms 3264 KB Output is correct
37 Correct 11 ms 8392 KB Output is correct
38 Correct 14 ms 6492 KB Output is correct
39 Correct 13 ms 3108 KB Output is correct
40 Correct 12 ms 3932 KB Output is correct
41 Correct 13 ms 4860 KB Output is correct
42 Correct 14 ms 9564 KB Output is correct
43 Correct 13 ms 10232 KB Output is correct
44 Correct 19 ms 10844 KB Output is correct
45 Correct 161 ms 75616 KB Output is correct
46 Correct 127 ms 75128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2904 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 3 ms 3676 KB Output is correct
15 Correct 2 ms 2908 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 3 ms 4444 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 6 ms 10588 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 5 ms 8796 KB Output is correct
24 Correct 5 ms 10332 KB Output is correct
25 Correct 3 ms 3932 KB Output is correct
26 Correct 5 ms 9308 KB Output is correct
27 Correct 6 ms 9820 KB Output is correct
28 Correct 6 ms 11096 KB Output is correct
29 Correct 7 ms 10588 KB Output is correct
30 Correct 5 ms 10588 KB Output is correct
31 Correct 6 ms 10588 KB Output is correct
32 Correct 6 ms 10588 KB Output is correct
33 Correct 10 ms 11612 KB Output is correct
34 Correct 8 ms 11612 KB Output is correct
35 Correct 14 ms 9564 KB Output is correct
36 Correct 3 ms 3164 KB Output is correct
37 Correct 12 ms 7996 KB Output is correct
38 Correct 13 ms 6236 KB Output is correct
39 Correct 12 ms 2848 KB Output is correct
40 Correct 12 ms 3552 KB Output is correct
41 Correct 15 ms 4636 KB Output is correct
42 Correct 15 ms 9564 KB Output is correct
43 Correct 14 ms 10076 KB Output is correct
44 Correct 14 ms 10652 KB Output is correct
45 Correct 160 ms 76116 KB Output is correct
46 Correct 154 ms 75192 KB Output is correct
47 Correct 19 ms 14940 KB Output is correct
48 Correct 13 ms 3204 KB Output is correct
49 Correct 10 ms 3304 KB Output is correct
50 Correct 10 ms 3076 KB Output is correct
51 Correct 83 ms 116908 KB Output is correct
52 Correct 106 ms 165408 KB Output is correct
53 Correct 26 ms 22852 KB Output is correct
54 Correct 31 ms 64116 KB Output is correct
55 Correct 44 ms 84060 KB Output is correct
56 Correct 74 ms 125212 KB Output is correct
57 Correct 2 ms 4216 KB Output is correct
58 Correct 82 ms 124828 KB Output is correct
59 Correct 73 ms 115316 KB Output is correct
60 Correct 67 ms 115540 KB Output is correct
61 Correct 71 ms 112176 KB Output is correct
62 Correct 184 ms 226896 KB Output is correct
63 Correct 283 ms 145516 KB Output is correct
64 Correct 348 ms 141916 KB Output is correct
65 Correct 390 ms 149356 KB Output is correct
66 Correct 547 ms 196452 KB Output is correct
67 Correct 362 ms 192860 KB Output is correct