답안 #985487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985487 2024-05-18T01:00:19 Z muratcepeda Jakarta Skyscrapers (APIO15_skyscraper) C++17
36 / 100
10 ms 27228 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

int n, m, b[MAX + 3], p[MAX + 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 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 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 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 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 2 ms 4700 KB Output is correct
15 Correct 1 ms 4700 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 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 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 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 2 ms 16988 KB Output is correct
20 Correct 6 ms 24408 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 7 ms 23284 KB Output is correct
24 Correct 7 ms 26460 KB Output is correct
25 Correct 4 ms 18524 KB Output is correct
26 Correct 5 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 8 ms 24788 KB Output is correct
30 Correct 6 ms 24668 KB Output is correct
31 Correct 7 ms 24668 KB Output is correct
32 Correct 6 ms 24924 KB Output is correct
33 Correct 10 ms 24920 KB Output is correct
34 Correct 8 ms 24664 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 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 4440 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 4640 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 4440 KB Output is correct
17 Correct 3 ms 11864 KB Output is correct
18 Correct 1 ms 6488 KB Output is correct
19 Correct 2 ms 16816 KB Output is correct
20 Correct 6 ms 24412 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 5 ms 23400 KB Output is correct
24 Correct 7 ms 26460 KB Output is correct
25 Correct 4 ms 18520 KB Output is correct
26 Correct 6 ms 23228 KB Output is correct
27 Correct 6 ms 24268 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 24668 KB Output is correct
31 Correct 6 ms 24668 KB Output is correct
32 Correct 7 ms 24924 KB Output is correct
33 Correct 10 ms 24920 KB Output is correct
34 Correct 8 ms 24668 KB Output is correct
35 Incorrect 2 ms 4676 KB Output isn't correct
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 4596 KB Output is correct
9 Correct 1 ms 4600 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 2 ms 4444 KB Output is correct
12 Correct 2 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 2 ms 4700 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 3 ms 11864 KB Output is correct
18 Correct 2 ms 6488 KB Output is correct
19 Correct 3 ms 16988 KB Output is correct
20 Correct 6 ms 24464 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 5 ms 23388 KB Output is correct
24 Correct 7 ms 26492 KB Output is correct
25 Correct 4 ms 18524 KB Output is correct
26 Correct 5 ms 23388 KB Output is correct
27 Correct 6 ms 24408 KB Output is correct
28 Correct 8 ms 27124 KB Output is correct
29 Correct 9 ms 24668 KB Output is correct
30 Correct 6 ms 24668 KB Output is correct
31 Correct 6 ms 24668 KB Output is correct
32 Correct 7 ms 24924 KB Output is correct
33 Correct 10 ms 25056 KB Output is correct
34 Correct 8 ms 24664 KB Output is correct
35 Incorrect 2 ms 4696 KB Output isn't correct
36 Halted 0 ms 0 KB -