답안 #417793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417793 2021-06-04T09:58:25 Z DEQK Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 3140 KB
#include <bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 3e4 + 10;
vector<vector<int>> g(N);
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, m; cin >> n >> m;
	int f, s;
	for(short i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		if(i == 0) f = x;
		if(i == 1) s = x;
		if(y == 0) continue;
		g[x].push_back(y);
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> c;
	vector<int> d(n, 2e9);
	d[f] = 0;
	c.push({0, f});
	while(!c.empty()) {
		int u = c.top().second, w = c.top().first;
		c.pop();
		if(d[u] != w) continue;
		if(u == s) {
			cout << d[s];
			return 0;
		}
		for(int x : g[u]) {
			for(int j = u % x; j < n; j += x) {
				if(d[j] > d[u] + abs(j - u) / x) {
					d[j] = d[u] + abs(j - u) / x;
					c.push({d[j], j});
				} 
			}
		}
	}
	cout << -1;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:20:5: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |  d[f] = 0;
      |     ^
skyscraper.cpp:26:3: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |   if(u == s) {
      |   ^~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 1 ms 972 KB Output is correct
13 Correct 3 ms 972 KB Output is correct
14 Correct 1 ms 972 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
# 결과 실행 시간 메모리 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 2 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 2 ms 972 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 972 KB Output is correct
20 Correct 29 ms 1100 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 972 KB Output is correct
23 Correct 1 ms 972 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 1 ms 972 KB Output is correct
26 Correct 1 ms 972 KB Output is correct
27 Correct 1 ms 972 KB Output is correct
28 Correct 2 ms 1100 KB Output is correct
29 Correct 3 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 2 ms 1100 KB Output is correct
33 Correct 4 ms 1228 KB Output is correct
34 Correct 3 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 972 KB Output is correct
13 Correct 6 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 972 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 972 KB Output is correct
20 Correct 30 ms 1100 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 2 ms 972 KB Output is correct
23 Correct 2 ms 972 KB Output is correct
24 Correct 2 ms 1100 KB Output is correct
25 Correct 2 ms 972 KB Output is correct
26 Correct 1 ms 972 KB Output is correct
27 Correct 2 ms 972 KB Output is correct
28 Correct 2 ms 972 KB Output is correct
29 Correct 3 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 2 ms 1100 KB Output is correct
33 Correct 4 ms 1228 KB Output is correct
34 Correct 3 ms 1228 KB Output is correct
35 Correct 8 ms 1228 KB Output is correct
36 Correct 2 ms 1100 KB Output is correct
37 Correct 7 ms 1316 KB Output is correct
38 Correct 8 ms 1356 KB Output is correct
39 Correct 8 ms 1232 KB Output is correct
40 Correct 8 ms 1224 KB Output is correct
41 Correct 8 ms 1356 KB Output is correct
42 Correct 6 ms 1484 KB Output is correct
43 Correct 6 ms 1484 KB Output is correct
44 Correct 425 ms 1464 KB Output is correct
45 Correct 11 ms 1612 KB Output is correct
46 Correct 10 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 972 KB Output is correct
13 Correct 2 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 972 KB Output is correct
18 Correct 1 ms 972 KB Output is correct
19 Correct 1 ms 972 KB Output is correct
20 Correct 29 ms 1132 KB Output is correct
21 Correct 1 ms 972 KB Output is correct
22 Correct 1 ms 972 KB Output is correct
23 Correct 1 ms 972 KB Output is correct
24 Correct 2 ms 972 KB Output is correct
25 Correct 2 ms 972 KB Output is correct
26 Correct 1 ms 972 KB Output is correct
27 Correct 2 ms 972 KB Output is correct
28 Correct 2 ms 972 KB Output is correct
29 Correct 3 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 2 ms 1100 KB Output is correct
33 Correct 4 ms 1284 KB Output is correct
34 Correct 3 ms 1228 KB Output is correct
35 Correct 8 ms 1248 KB Output is correct
36 Correct 2 ms 1100 KB Output is correct
37 Correct 7 ms 1228 KB Output is correct
38 Correct 9 ms 1356 KB Output is correct
39 Correct 8 ms 1260 KB Output is correct
40 Correct 8 ms 1228 KB Output is correct
41 Correct 11 ms 1356 KB Output is correct
42 Correct 6 ms 1460 KB Output is correct
43 Correct 6 ms 1484 KB Output is correct
44 Correct 418 ms 1484 KB Output is correct
45 Correct 11 ms 1612 KB Output is correct
46 Correct 10 ms 1612 KB Output is correct
47 Correct 13 ms 2248 KB Output is correct
48 Correct 8 ms 1740 KB Output is correct
49 Correct 8 ms 1740 KB Output is correct
50 Correct 7 ms 1556 KB Output is correct
51 Correct 18 ms 3140 KB Output is correct
52 Correct 18 ms 2608 KB Output is correct
53 Correct 11 ms 2264 KB Output is correct
54 Correct 2 ms 1356 KB Output is correct
55 Correct 3 ms 1356 KB Output is correct
56 Execution timed out 1095 ms 2600 KB Time limit exceeded
57 Halted 0 ms 0 KB -