답안 #31724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31724 2017-09-02T16:21:32 Z top34051 Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
333 ms 17864 KB
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
struct node {
    int x,val;
    node(int _x = 0,int _val = 0) {
        x = _x; val = _val;
    }
    bool operator < (node a) const {
        return a.val<val;
    }
};
int n,m,st,ft;
int mem[2005];
int from[2005][2005];
priority_queue<node> heap;
main() {
    int i,j,x,y,pos,val;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++) for(j=0;j<n;j++) from[i][j] = inf;
    for(i=0;i<m;i++) {
        scanf("%d%d",&pos,&val);
        if(i==0) st = pos;
        if(i==1) ft = pos;
        for(x=0;x<n;x++) if(abs(pos-x)%val==0) from[pos][x] = min(from[pos][x],abs(pos-x)/val);
    }
    for(i=0;i<n;i++) mem[i] = inf;
    mem[st] = 0;
    heap.push(node(st,0));
    while(!heap.empty()) {
        x = heap.top().x; heap.pop();
        for(y=0;y<n;y++) {
            val = from[x][y];
            if(mem[y] > mem[x] + val) {
                mem[y] = mem[x] + val;
                heap.push(node(y,mem[y]));
            }
        }
    }
    if(mem[ft]==inf) printf("-1");
    else printf("%d",mem[ft]);
}

Compilation message

skyscraper.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:19:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
skyscraper.cpp:22:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&pos,&val);
                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17724 KB Output is correct
2 Correct 0 ms 17724 KB Output is correct
3 Correct 0 ms 17724 KB Output is correct
4 Correct 0 ms 17724 KB Output is correct
5 Correct 0 ms 17724 KB Output is correct
6 Correct 0 ms 17724 KB Output is correct
7 Correct 0 ms 17724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17724 KB Output is correct
2 Correct 0 ms 17724 KB Output is correct
3 Correct 0 ms 17724 KB Output is correct
4 Correct 0 ms 17724 KB Output is correct
5 Correct 0 ms 17724 KB Output is correct
6 Correct 0 ms 17724 KB Output is correct
7 Correct 0 ms 17724 KB Output is correct
8 Correct 0 ms 17724 KB Output is correct
9 Correct 0 ms 17724 KB Output is correct
10 Correct 0 ms 17724 KB Output is correct
11 Correct 3 ms 17724 KB Output is correct
12 Correct 0 ms 17724 KB Output is correct
13 Correct 0 ms 17724 KB Output is correct
14 Correct 0 ms 17724 KB Output is correct
15 Correct 0 ms 17724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17724 KB Output is correct
2 Correct 0 ms 17724 KB Output is correct
3 Correct 0 ms 17724 KB Output is correct
4 Correct 0 ms 17724 KB Output is correct
5 Correct 0 ms 17724 KB Output is correct
6 Correct 0 ms 17724 KB Output is correct
7 Correct 0 ms 17724 KB Output is correct
8 Correct 0 ms 17724 KB Output is correct
9 Correct 0 ms 17724 KB Output is correct
10 Correct 0 ms 17724 KB Output is correct
11 Correct 0 ms 17724 KB Output is correct
12 Correct 0 ms 17724 KB Output is correct
13 Correct 0 ms 17724 KB Output is correct
14 Correct 0 ms 17724 KB Output is correct
15 Correct 0 ms 17724 KB Output is correct
16 Correct 0 ms 17724 KB Output is correct
17 Correct 9 ms 17724 KB Output is correct
18 Correct 9 ms 17724 KB Output is correct
19 Correct 6 ms 17724 KB Output is correct
20 Correct 33 ms 17724 KB Output is correct
21 Correct 3 ms 17724 KB Output is correct
22 Correct 9 ms 17724 KB Output is correct
23 Correct 13 ms 17724 KB Output is correct
24 Correct 19 ms 17724 KB Output is correct
25 Correct 29 ms 17864 KB Output is correct
26 Correct 29 ms 17724 KB Output is correct
27 Correct 33 ms 17724 KB Output is correct
28 Correct 33 ms 17724 KB Output is correct
29 Correct 29 ms 17864 KB Output is correct
30 Correct 16 ms 17864 KB Output is correct
31 Correct 29 ms 17864 KB Output is correct
32 Correct 23 ms 17864 KB Output is correct
33 Correct 46 ms 17864 KB Output is correct
34 Correct 39 ms 17864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17724 KB Output is correct
2 Correct 0 ms 17724 KB Output is correct
3 Correct 0 ms 17724 KB Output is correct
4 Correct 0 ms 17724 KB Output is correct
5 Correct 0 ms 17724 KB Output is correct
6 Correct 0 ms 17724 KB Output is correct
7 Correct 0 ms 17724 KB Output is correct
8 Correct 0 ms 17724 KB Output is correct
9 Correct 0 ms 17724 KB Output is correct
10 Correct 0 ms 17724 KB Output is correct
11 Correct 0 ms 17724 KB Output is correct
12 Correct 0 ms 17724 KB Output is correct
13 Correct 0 ms 17724 KB Output is correct
14 Correct 0 ms 17724 KB Output is correct
15 Correct 0 ms 17724 KB Output is correct
16 Correct 0 ms 17724 KB Output is correct
17 Correct 13 ms 17724 KB Output is correct
18 Correct 6 ms 17724 KB Output is correct
19 Correct 9 ms 17724 KB Output is correct
20 Correct 29 ms 17724 KB Output is correct
21 Correct 3 ms 17724 KB Output is correct
22 Correct 6 ms 17724 KB Output is correct
23 Correct 19 ms 17724 KB Output is correct
24 Correct 29 ms 17724 KB Output is correct
25 Correct 29 ms 17864 KB Output is correct
26 Correct 29 ms 17724 KB Output is correct
27 Correct 23 ms 17724 KB Output is correct
28 Correct 29 ms 17724 KB Output is correct
29 Correct 26 ms 17864 KB Output is correct
30 Correct 19 ms 17864 KB Output is correct
31 Correct 19 ms 17864 KB Output is correct
32 Correct 19 ms 17864 KB Output is correct
33 Correct 39 ms 17864 KB Output is correct
34 Correct 39 ms 17864 KB Output is correct
35 Correct 193 ms 17864 KB Output is correct
36 Correct 39 ms 17724 KB Output is correct
37 Correct 206 ms 17864 KB Output is correct
38 Correct 313 ms 17864 KB Output is correct
39 Correct 313 ms 17864 KB Output is correct
40 Correct 303 ms 17864 KB Output is correct
41 Correct 333 ms 17864 KB Output is correct
42 Correct 309 ms 17724 KB Output is correct
43 Correct 293 ms 17724 KB Output is correct
44 Correct 289 ms 17724 KB Output is correct
45 Correct 309 ms 17864 KB Output is correct
46 Correct 313 ms 17864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 17724 KB Output is correct
2 Correct 0 ms 17724 KB Output is correct
3 Correct 0 ms 17724 KB Output is correct
4 Correct 0 ms 17724 KB Output is correct
5 Correct 0 ms 17724 KB Output is correct
6 Correct 0 ms 17724 KB Output is correct
7 Correct 0 ms 17724 KB Output is correct
8 Correct 0 ms 17724 KB Output is correct
9 Correct 0 ms 17724 KB Output is correct
10 Correct 0 ms 17724 KB Output is correct
11 Correct 0 ms 17724 KB Output is correct
12 Correct 0 ms 17724 KB Output is correct
13 Correct 0 ms 17724 KB Output is correct
14 Correct 0 ms 17724 KB Output is correct
15 Correct 0 ms 17724 KB Output is correct
16 Correct 0 ms 17724 KB Output is correct
17 Correct 6 ms 17724 KB Output is correct
18 Correct 16 ms 17724 KB Output is correct
19 Correct 3 ms 17724 KB Output is correct
20 Correct 26 ms 17724 KB Output is correct
21 Correct 3 ms 17724 KB Output is correct
22 Correct 9 ms 17724 KB Output is correct
23 Correct 13 ms 17724 KB Output is correct
24 Correct 29 ms 17724 KB Output is correct
25 Correct 29 ms 17864 KB Output is correct
26 Correct 33 ms 17724 KB Output is correct
27 Correct 23 ms 17724 KB Output is correct
28 Correct 23 ms 17724 KB Output is correct
29 Correct 39 ms 17864 KB Output is correct
30 Correct 16 ms 17864 KB Output is correct
31 Correct 23 ms 17864 KB Output is correct
32 Correct 33 ms 17864 KB Output is correct
33 Correct 43 ms 17864 KB Output is correct
34 Correct 43 ms 17864 KB Output is correct
35 Correct 186 ms 17864 KB Output is correct
36 Correct 26 ms 17724 KB Output is correct
37 Correct 196 ms 17864 KB Output is correct
38 Correct 313 ms 17864 KB Output is correct
39 Correct 316 ms 17864 KB Output is correct
40 Correct 306 ms 17864 KB Output is correct
41 Correct 303 ms 17864 KB Output is correct
42 Correct 306 ms 17724 KB Output is correct
43 Correct 293 ms 17724 KB Output is correct
44 Correct 306 ms 17724 KB Output is correct
45 Correct 319 ms 17864 KB Output is correct
46 Correct 333 ms 17864 KB Output is correct
47 Runtime error 19 ms 17724 KB Execution killed with signal 11 (could be triggered by violating memory limits)
48 Halted 0 ms 0 KB -