답안 #112119

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112119 2019-05-17T12:48:42 Z Runtime_error_ Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
164 ms 65528 KB
#include <bits/stdc++.h>
using namespace std;
const int inf=2e3+9,M=3e4+9;
int n,m;
int building[M],speed[M],dis[inf][inf][2];//dis[building][speed]
bool vis[inf][inf][2];
vector<int> dogs[inf];
struct State{

    int B,S;
    bool Pass;
};
deque<State>q;

int main(){

    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
        scanf("%d%d",building+i,speed+i),building[i]++,dogs[building[i]].push_back(i);

    memset(dis,21,sizeof(dis));

    int goal=building[2];

    dis[building[1]][speed[1]][0]=0;
    q.push_front({building[1],speed[1],0});

    while(!q.empty()){
        State cur=q.front();
        q.pop_front();

        if(vis[cur.B][cur.S][cur.Pass])
            continue;
        vis[cur.B][cur.S][cur.Pass]=1;
        if(cur.B==goal)
            printf("%d\n",dis[cur.B][cur.S][cur.Pass]),exit(0);

        if(!cur.Pass){
            dis[cur.B][cur.S][1]=dis[cur.B][cur.S][0];
            q.push_front({cur.B,cur.S,1});

            for(auto o:dogs[cur.B])
                if(dis[ building[o] ][ speed[o] ] [1] >= dis[ cur.B ] [ cur.S ] [cur.Pass] )
                    dis[ building[o] ][ speed[o] ] [1] = dis[ cur.B ] [ cur.S ] [cur.Pass],
                    q.push_front(  {building[o],speed[o],1} );
            continue;
        }

        if(cur.B+cur.S<=n && dis[ cur.B+cur.S ][ cur.S ][0]> dis[cur.B][cur.S][cur.Pass]+1 )
            dis[ cur.B+cur.S ][ cur.S ][0] = dis[cur.B][cur.S][cur.Pass]+1,
            q.push_back({cur.B+cur.S , cur.S , 0});

        if(cur.B - cur.S >=1 && dis[cur.B-cur.S] [ cur.S ][0] > dis[cur.B] [cur.S] [cur.Pass]+1)
            dis[cur.B-cur.S] [ cur.S ][0] = dis[cur.B] [cur.S] [cur.Pass]+1,
            q.push_back({cur.B-cur.S , cur.S , 0});
    }

    printf("-1\n");
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
skyscraper.cpp:19:55: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",building+i,speed+i),building[i]++,dogs[building[i]].push_back(i);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 32000 KB Output is correct
2 Correct 27 ms 31992 KB Output is correct
3 Correct 23 ms 31992 KB Output is correct
4 Correct 24 ms 32000 KB Output is correct
5 Correct 24 ms 32000 KB Output is correct
6 Correct 26 ms 32120 KB Output is correct
7 Correct 26 ms 32024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 32000 KB Output is correct
2 Correct 23 ms 32000 KB Output is correct
3 Correct 23 ms 32000 KB Output is correct
4 Correct 27 ms 31992 KB Output is correct
5 Correct 30 ms 31992 KB Output is correct
6 Correct 24 ms 31992 KB Output is correct
7 Correct 25 ms 31992 KB Output is correct
8 Correct 23 ms 31864 KB Output is correct
9 Correct 26 ms 32120 KB Output is correct
10 Correct 24 ms 32256 KB Output is correct
11 Correct 23 ms 31992 KB Output is correct
12 Correct 24 ms 32384 KB Output is correct
13 Correct 24 ms 32384 KB Output is correct
14 Correct 25 ms 32384 KB Output is correct
15 Correct 24 ms 32376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 32000 KB Output is correct
2 Correct 23 ms 32036 KB Output is correct
3 Correct 23 ms 31992 KB Output is correct
4 Correct 24 ms 32000 KB Output is correct
5 Correct 24 ms 32000 KB Output is correct
6 Correct 24 ms 32000 KB Output is correct
7 Correct 25 ms 32020 KB Output is correct
8 Correct 33 ms 31928 KB Output is correct
9 Correct 26 ms 32128 KB Output is correct
10 Correct 26 ms 32228 KB Output is correct
11 Correct 25 ms 32120 KB Output is correct
12 Correct 29 ms 32384 KB Output is correct
13 Correct 25 ms 32384 KB Output is correct
14 Correct 26 ms 32456 KB Output is correct
15 Correct 24 ms 32376 KB Output is correct
16 Correct 26 ms 31932 KB Output is correct
17 Correct 27 ms 33920 KB Output is correct
18 Correct 23 ms 32000 KB Output is correct
19 Correct 28 ms 32120 KB Output is correct
20 Correct 32 ms 39928 KB Output is correct
21 Correct 32 ms 31996 KB Output is correct
22 Correct 26 ms 32000 KB Output is correct
23 Correct 34 ms 38008 KB Output is correct
24 Correct 33 ms 39040 KB Output is correct
25 Correct 25 ms 33536 KB Output is correct
26 Correct 31 ms 38648 KB Output is correct
27 Correct 31 ms 39160 KB Output is correct
28 Correct 42 ms 39928 KB Output is correct
29 Correct 39 ms 39928 KB Output is correct
30 Correct 34 ms 39800 KB Output is correct
31 Correct 41 ms 39900 KB Output is correct
32 Correct 37 ms 39804 KB Output is correct
33 Correct 46 ms 39928 KB Output is correct
34 Correct 40 ms 39928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 32000 KB Output is correct
2 Correct 29 ms 31992 KB Output is correct
3 Correct 26 ms 31992 KB Output is correct
4 Correct 24 ms 31972 KB Output is correct
5 Correct 26 ms 32000 KB Output is correct
6 Correct 26 ms 31992 KB Output is correct
7 Correct 26 ms 31992 KB Output is correct
8 Correct 26 ms 31996 KB Output is correct
9 Correct 24 ms 32128 KB Output is correct
10 Correct 30 ms 32376 KB Output is correct
11 Correct 24 ms 31992 KB Output is correct
12 Correct 25 ms 32376 KB Output is correct
13 Correct 25 ms 32452 KB Output is correct
14 Correct 30 ms 32512 KB Output is correct
15 Correct 26 ms 32356 KB Output is correct
16 Correct 27 ms 32000 KB Output is correct
17 Correct 26 ms 33912 KB Output is correct
18 Correct 24 ms 31992 KB Output is correct
19 Correct 23 ms 32000 KB Output is correct
20 Correct 31 ms 39864 KB Output is correct
21 Correct 24 ms 31992 KB Output is correct
22 Correct 32 ms 31992 KB Output is correct
23 Correct 30 ms 37888 KB Output is correct
24 Correct 31 ms 39236 KB Output is correct
25 Correct 26 ms 33528 KB Output is correct
26 Correct 31 ms 38656 KB Output is correct
27 Correct 35 ms 39288 KB Output is correct
28 Correct 39 ms 39900 KB Output is correct
29 Correct 36 ms 39796 KB Output is correct
30 Correct 37 ms 39800 KB Output is correct
31 Correct 35 ms 39800 KB Output is correct
32 Correct 41 ms 39880 KB Output is correct
33 Correct 47 ms 39884 KB Output is correct
34 Correct 43 ms 39928 KB Output is correct
35 Correct 46 ms 38388 KB Output is correct
36 Correct 32 ms 33724 KB Output is correct
37 Correct 39 ms 38392 KB Output is correct
38 Correct 42 ms 37112 KB Output is correct
39 Correct 33 ms 33016 KB Output is correct
40 Correct 36 ms 34296 KB Output is correct
41 Correct 49 ms 40548 KB Output is correct
42 Correct 35 ms 39356 KB Output is correct
43 Correct 35 ms 39800 KB Output is correct
44 Correct 36 ms 40796 KB Output is correct
45 Correct 142 ms 41000 KB Output is correct
46 Correct 141 ms 40832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 32000 KB Output is correct
2 Correct 23 ms 32000 KB Output is correct
3 Correct 24 ms 31992 KB Output is correct
4 Correct 24 ms 32000 KB Output is correct
5 Correct 26 ms 31992 KB Output is correct
6 Correct 24 ms 32000 KB Output is correct
7 Correct 23 ms 32000 KB Output is correct
8 Correct 24 ms 32000 KB Output is correct
9 Correct 24 ms 32120 KB Output is correct
10 Correct 26 ms 32248 KB Output is correct
11 Correct 27 ms 32128 KB Output is correct
12 Correct 29 ms 32384 KB Output is correct
13 Correct 21 ms 32376 KB Output is correct
14 Correct 29 ms 32612 KB Output is correct
15 Correct 28 ms 32376 KB Output is correct
16 Correct 24 ms 32000 KB Output is correct
17 Correct 26 ms 33912 KB Output is correct
18 Correct 24 ms 32000 KB Output is correct
19 Correct 23 ms 32000 KB Output is correct
20 Correct 31 ms 39928 KB Output is correct
21 Correct 24 ms 32000 KB Output is correct
22 Correct 26 ms 32000 KB Output is correct
23 Correct 34 ms 37752 KB Output is correct
24 Correct 32 ms 39032 KB Output is correct
25 Correct 25 ms 33528 KB Output is correct
26 Correct 31 ms 38648 KB Output is correct
27 Correct 31 ms 39160 KB Output is correct
28 Correct 37 ms 39928 KB Output is correct
29 Correct 40 ms 39800 KB Output is correct
30 Correct 32 ms 39800 KB Output is correct
31 Correct 46 ms 39904 KB Output is correct
32 Correct 33 ms 39800 KB Output is correct
33 Correct 44 ms 39928 KB Output is correct
34 Correct 38 ms 39936 KB Output is correct
35 Correct 42 ms 38460 KB Output is correct
36 Correct 28 ms 33792 KB Output is correct
37 Correct 38 ms 38392 KB Output is correct
38 Correct 47 ms 37000 KB Output is correct
39 Correct 32 ms 32760 KB Output is correct
40 Correct 36 ms 34296 KB Output is correct
41 Correct 48 ms 40568 KB Output is correct
42 Correct 38 ms 39296 KB Output is correct
43 Correct 39 ms 39780 KB Output is correct
44 Correct 36 ms 40828 KB Output is correct
45 Correct 164 ms 41028 KB Output is correct
46 Correct 147 ms 40772 KB Output is correct
47 Runtime error 64 ms 65528 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Halted 0 ms 0 KB -