답안 #124235

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124235 2019-07-02T21:17:02 Z elabensaad Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
492 ms 262144 KB
#include <bits/stdc++.h>

using namespace std;

int n, m, x, y, vis[30005], p[30005], pos, sta;
vector <pair <int , int> > t[30005];

void DJ(int u){
	priority_queue <pair <int, int> >q;
    vis[u] = 1;
    q.push({-1, u});
    while(!q.empty()){
        int l = q.top().second;
        q.pop();
        for(int i = 0;i < t[l].size();i++){
            int nc = vis[l]+t[l][i].second;
            if(vis[t[l][i].first] == 0 || nc < vis[t[l][i].first]){
                vis[t[l][i].first] = nc;
                q.push({-nc, t[l][i].first});
            }
        }
    }
}

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> x >> p[i];
		int c = x;
		if(i == 0)sta = x;
		if(i == 1)pos = x;
		int k = x;
		//t[i].push_back({x, 0});
		int cur = 0;
		while(x+p[i] < n){
			x+=p[i];
			cur++;
			t[c].push_back({x, cur});
		}
		cur = 0;
		while(k-p[i] >= 0){
			k-=p[i];
			cur++;
			t[c].push_back({k, cur});
		}
	}
	DJ(sta);
	if(vis[pos] == 0)cout << -1;
	else cout << vis[pos]-1 ;
}

Compilation message

skyscraper.cpp: In function 'void DJ(int)':
skyscraper.cpp:15:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i < t[l].size();i++){
                       ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 2 ms 1016 KB Output is correct
3 Correct 3 ms 1016 KB Output is correct
4 Correct 3 ms 1020 KB Output is correct
5 Correct 2 ms 1016 KB Output is correct
6 Correct 3 ms 1016 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 2 ms 1016 KB Output is correct
3 Correct 2 ms 1016 KB Output is correct
4 Correct 2 ms 1016 KB Output is correct
5 Correct 2 ms 1016 KB Output is correct
6 Correct 2 ms 1016 KB Output is correct
7 Correct 3 ms 1016 KB Output is correct
8 Correct 4 ms 1016 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 3 ms 1144 KB Output is correct
11 Correct 3 ms 1272 KB Output is correct
12 Correct 8 ms 3188 KB Output is correct
13 Correct 7 ms 3324 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 2 ms 1016 KB Output is correct
4 Correct 2 ms 1016 KB Output is correct
5 Correct 2 ms 1016 KB Output is correct
6 Correct 2 ms 1020 KB Output is correct
7 Correct 2 ms 1016 KB Output is correct
8 Correct 2 ms 1016 KB Output is correct
9 Correct 2 ms 1016 KB Output is correct
10 Correct 2 ms 1016 KB Output is correct
11 Correct 3 ms 1144 KB Output is correct
12 Correct 7 ms 3312 KB Output is correct
13 Correct 7 ms 3196 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1144 KB Output is correct
16 Correct 3 ms 1144 KB Output is correct
17 Correct 4 ms 1400 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 3 ms 1144 KB Output is correct
20 Correct 74 ms 33272 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 3 ms 1144 KB Output is correct
24 Correct 4 ms 1272 KB Output is correct
25 Correct 4 ms 1272 KB Output is correct
26 Correct 84 ms 34112 KB Output is correct
27 Correct 81 ms 34148 KB Output is correct
28 Correct 4 ms 1400 KB Output is correct
29 Correct 5 ms 1912 KB Output is correct
30 Correct 4 ms 1400 KB Output is correct
31 Correct 4 ms 1528 KB Output is correct
32 Correct 4 ms 1400 KB Output is correct
33 Correct 7 ms 2552 KB Output is correct
34 Correct 7 ms 2472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 3 ms 1016 KB Output is correct
3 Correct 2 ms 1016 KB Output is correct
4 Correct 2 ms 1016 KB Output is correct
5 Correct 2 ms 1016 KB Output is correct
6 Correct 2 ms 1016 KB Output is correct
7 Correct 2 ms 1016 KB Output is correct
8 Correct 2 ms 1016 KB Output is correct
9 Correct 2 ms 1016 KB Output is correct
10 Correct 2 ms 1144 KB Output is correct
11 Correct 3 ms 1144 KB Output is correct
12 Correct 7 ms 3316 KB Output is correct
13 Correct 7 ms 3324 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1144 KB Output is correct
16 Correct 3 ms 1144 KB Output is correct
17 Correct 4 ms 1400 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 3 ms 1144 KB Output is correct
20 Correct 74 ms 33272 KB Output is correct
21 Correct 3 ms 1020 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 3 ms 1144 KB Output is correct
24 Correct 4 ms 1272 KB Output is correct
25 Correct 4 ms 1272 KB Output is correct
26 Correct 83 ms 34244 KB Output is correct
27 Correct 81 ms 34164 KB Output is correct
28 Correct 4 ms 1288 KB Output is correct
29 Correct 5 ms 1912 KB Output is correct
30 Correct 4 ms 1400 KB Output is correct
31 Correct 4 ms 1528 KB Output is correct
32 Correct 4 ms 1400 KB Output is correct
33 Correct 7 ms 2556 KB Output is correct
34 Correct 7 ms 2552 KB Output is correct
35 Correct 13 ms 2936 KB Output is correct
36 Correct 5 ms 1400 KB Output is correct
37 Correct 16 ms 4600 KB Output is correct
38 Correct 17 ms 3940 KB Output is correct
39 Correct 17 ms 4216 KB Output is correct
40 Correct 17 ms 4088 KB Output is correct
41 Correct 17 ms 3960 KB Output is correct
42 Runtime error 492 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1016 KB Output is correct
2 Correct 2 ms 1016 KB Output is correct
3 Correct 2 ms 1016 KB Output is correct
4 Correct 2 ms 1016 KB Output is correct
5 Correct 2 ms 1016 KB Output is correct
6 Correct 2 ms 1016 KB Output is correct
7 Correct 2 ms 1016 KB Output is correct
8 Correct 2 ms 1020 KB Output is correct
9 Correct 3 ms 1016 KB Output is correct
10 Correct 3 ms 1148 KB Output is correct
11 Correct 3 ms 1144 KB Output is correct
12 Correct 7 ms 3316 KB Output is correct
13 Correct 7 ms 3324 KB Output is correct
14 Correct 3 ms 1144 KB Output is correct
15 Correct 3 ms 1144 KB Output is correct
16 Correct 3 ms 1144 KB Output is correct
17 Correct 4 ms 1400 KB Output is correct
18 Correct 3 ms 1144 KB Output is correct
19 Correct 3 ms 1144 KB Output is correct
20 Correct 73 ms 33144 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 3 ms 1144 KB Output is correct
24 Correct 4 ms 1272 KB Output is correct
25 Correct 4 ms 1272 KB Output is correct
26 Correct 92 ms 34180 KB Output is correct
27 Correct 88 ms 34276 KB Output is correct
28 Correct 4 ms 1400 KB Output is correct
29 Correct 6 ms 1912 KB Output is correct
30 Correct 4 ms 1400 KB Output is correct
31 Correct 4 ms 1528 KB Output is correct
32 Correct 4 ms 1400 KB Output is correct
33 Correct 7 ms 2552 KB Output is correct
34 Correct 7 ms 2552 KB Output is correct
35 Correct 12 ms 2936 KB Output is correct
36 Correct 4 ms 1400 KB Output is correct
37 Correct 15 ms 4600 KB Output is correct
38 Correct 17 ms 4104 KB Output is correct
39 Correct 17 ms 4216 KB Output is correct
40 Correct 17 ms 4088 KB Output is correct
41 Correct 17 ms 4088 KB Output is correct
42 Runtime error 453 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
43 Halted 0 ms 0 KB -