답안 #985488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985488 2024-05-18T01:02:40 Z muratcepeda Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
88 ms 32592 KB
#include <bits/stdc++.h>

using namespace std;
#define lli long long int
#define rep(i, a, b) for(int i = a; i <= b; i++)


#define MAX 2000
#define MAXM 30000

int n, m, b[MAXM + 3], p[MAXM + 3], vis[MAX + 3][MAX + 3], opt[MAX + 3][MAX + 3], destino, res;
vector < int > v[MAX];
queue < pair < int, pair < int, int > > > q;

void salta(int largo, int pos, int salto){
    if(pos < n && pos >= 0 && !vis[pos][salto]){
        q.push({largo + 1, {pos, salto}});
        vis[pos][salto] = 1;  
        opt[pos][salto] = largo;
    }
}

int main(){

    cin >> n >> m;
    rep(i, 0, m - 1){
        cin >> b[i] >> p[i];
        v[b[i]].push_back(i);
    }
    res = -1;
    destino = b[1];
    vis[b[0]][p[0]] = 1;
    opt[b[0]][p[0]] = 0;
    q.push({0, {b[0], p[0]}});

    while(!q.empty()){
        int largo = q.front().first;
        int pos = q.front().second.first;
        int salto = q.front().second.second;
        q.pop();
        if(pos == destino){
            res = largo;
            break;
        }
        salta(largo, pos + salto, salto);
        salta(largo, pos - salto, salto);
        for(auto s: v[pos]){
            salta(largo, pos + p[s], p[s]);
            salta(largo, pos - p[s], p[s]);
        }
    }
    cout << res;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4696 KB Output is correct
14 Correct 2 ms 4700 KB Output is correct
15 Correct 1 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 2 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 2 ms 4700 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 3 ms 11868 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 16988 KB Output is correct
20 Correct 6 ms 24412 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 1 ms 4440 KB Output is correct
23 Correct 6 ms 23388 KB Output is correct
24 Correct 9 ms 26460 KB Output is correct
25 Correct 3 ms 18660 KB Output is correct
26 Correct 6 ms 23388 KB Output is correct
27 Correct 6 ms 24412 KB Output is correct
28 Correct 8 ms 27228 KB Output is correct
29 Correct 7 ms 24680 KB Output is correct
30 Correct 6 ms 24508 KB Output is correct
31 Correct 6 ms 24664 KB Output is correct
32 Correct 6 ms 24924 KB Output is correct
33 Correct 14 ms 24924 KB Output is correct
34 Correct 8 ms 24664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 2 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 2 ms 4736 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 3 ms 11868 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 3 ms 16984 KB Output is correct
20 Correct 6 ms 24412 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 7 ms 23384 KB Output is correct
24 Correct 7 ms 26460 KB Output is correct
25 Correct 4 ms 18460 KB Output is correct
26 Correct 6 ms 23132 KB Output is correct
27 Correct 6 ms 24412 KB Output is correct
28 Correct 8 ms 27228 KB Output is correct
29 Correct 7 ms 24684 KB Output is correct
30 Correct 6 ms 24668 KB Output is correct
31 Correct 6 ms 24664 KB Output is correct
32 Correct 6 ms 24924 KB Output is correct
33 Correct 12 ms 24924 KB Output is correct
34 Correct 8 ms 24664 KB Output is correct
35 Correct 18 ms 24408 KB Output is correct
36 Correct 4 ms 14952 KB Output is correct
37 Correct 15 ms 29532 KB Output is correct
38 Correct 22 ms 32592 KB Output is correct
39 Correct 13 ms 20060 KB Output is correct
40 Correct 16 ms 20336 KB Output is correct
41 Correct 17 ms 27996 KB Output is correct
42 Correct 14 ms 23900 KB Output is correct
43 Correct 15 ms 24920 KB Output is correct
44 Correct 16 ms 25180 KB Output is correct
45 Correct 81 ms 27636 KB Output is correct
46 Correct 67 ms 26704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4696 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 2 ms 4700 KB Output is correct
15 Correct 1 ms 4696 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 3 ms 11736 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 3 ms 16988 KB Output is correct
20 Correct 6 ms 24412 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 13 ms 23388 KB Output is correct
24 Correct 7 ms 26456 KB Output is correct
25 Correct 4 ms 18524 KB Output is correct
26 Correct 6 ms 23268 KB Output is correct
27 Correct 8 ms 24388 KB Output is correct
28 Correct 10 ms 27228 KB Output is correct
29 Correct 10 ms 24668 KB Output is correct
30 Correct 6 ms 24668 KB Output is correct
31 Correct 10 ms 24732 KB Output is correct
32 Correct 7 ms 24920 KB Output is correct
33 Correct 11 ms 24920 KB Output is correct
34 Correct 11 ms 24664 KB Output is correct
35 Correct 28 ms 24156 KB Output is correct
36 Correct 4 ms 15060 KB Output is correct
37 Correct 21 ms 29700 KB Output is correct
38 Correct 20 ms 32444 KB Output is correct
39 Correct 14 ms 20060 KB Output is correct
40 Correct 16 ms 20580 KB Output is correct
41 Correct 17 ms 27984 KB Output is correct
42 Correct 13 ms 23900 KB Output is correct
43 Correct 14 ms 24932 KB Output is correct
44 Correct 15 ms 25180 KB Output is correct
45 Correct 88 ms 27720 KB Output is correct
46 Correct 67 ms 26800 KB Output is correct
47 Runtime error 11 ms 2396 KB Execution killed with signal 11
48 Halted 0 ms 0 KB -