답안 #16647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16647 2015-09-03T00:44:13 Z khsoo01 Jakarta Skyscrapers (APIO15_skyscraper) C++
57 / 100
1000 ms 5472 KB
#include<cstdio>
#include<vector>
#include<queue>
#define INF 0x7fffffff
#define f first
#define s second
using namespace std;
vector<int>cg[50005];
priority_queue<pair<int,int> >pq;
int dist[50005],ed[50005][2];
int n,m,a,b,cur,val,tmp;

inline bool valid(int idx) {
    if(idx<0 || idx>=n) return false;
    return true;
}

int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++) {
        scanf("%d%d",&ed[i][0],&ed[i][1]);
        cg[ed[i][0]].push_back(ed[i][1]);
    }
    for(i=0;i<n;i++) dist[i]=INF;
    dist[ed[0][0]]=0;
    pq.push({0,ed[0][0]});
    while(!pq.empty()) {
        val=-pq.top().first;
        cur=pq.top().second;
        pq.pop();
        if(cur==ed[1][0])break;
        if(dist[cur]!=val) continue;
        for(i=0;i<cg[cur].size();i++) {
            tmp=cg[cur][i];
            for(j=cur+tmp;j<n;j+=tmp) {
                if(dist[j]>dist[cur]+(j-cur)/tmp) {
                    dist[j]=dist[cur]+(j-cur)/tmp;
                    pq.push({-dist[j],j});
                }
            }
            for(j=cur-tmp;j>=0;j-=tmp) {
                if(dist[j]>dist[cur]+(cur-j)/tmp) {
                    dist[j]=dist[cur]+(cur-j)/tmp;
                    pq.push({-dist[j],j});
                }
            }
        }
    }
    printf("%d",dist[ed[1][0]]==INF?-1:dist[ed[1][0]]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3340 KB Output is correct
2 Correct 0 ms 3340 KB Output is correct
3 Correct 0 ms 3340 KB Output is correct
4 Correct 0 ms 3340 KB Output is correct
5 Correct 0 ms 3340 KB Output is correct
6 Correct 0 ms 3340 KB Output is correct
7 Correct 0 ms 3340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3340 KB Output is correct
2 Correct 0 ms 3340 KB Output is correct
3 Correct 0 ms 3340 KB Output is correct
4 Correct 0 ms 3340 KB Output is correct
5 Correct 0 ms 3340 KB Output is correct
6 Correct 0 ms 3340 KB Output is correct
7 Correct 0 ms 3340 KB Output is correct
8 Correct 0 ms 3340 KB Output is correct
9 Correct 0 ms 3340 KB Output is correct
10 Correct 1 ms 3340 KB Output is correct
11 Correct 0 ms 3340 KB Output is correct
12 Correct 0 ms 3340 KB Output is correct
13 Correct 3 ms 3340 KB Output is correct
14 Correct 0 ms 3340 KB Output is correct
15 Correct 0 ms 3340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3340 KB Output is correct
2 Correct 0 ms 3340 KB Output is correct
3 Correct 0 ms 3340 KB Output is correct
4 Correct 0 ms 3340 KB Output is correct
5 Correct 1 ms 3340 KB Output is correct
6 Correct 0 ms 3340 KB Output is correct
7 Correct 0 ms 3340 KB Output is correct
8 Correct 0 ms 3340 KB Output is correct
9 Correct 0 ms 3340 KB Output is correct
10 Correct 0 ms 3340 KB Output is correct
11 Correct 0 ms 3340 KB Output is correct
12 Correct 0 ms 3340 KB Output is correct
13 Correct 0 ms 3340 KB Output is correct
14 Correct 0 ms 3340 KB Output is correct
15 Correct 0 ms 3340 KB Output is correct
16 Correct 0 ms 3340 KB Output is correct
17 Correct 0 ms 3340 KB Output is correct
18 Correct 0 ms 3340 KB Output is correct
19 Correct 0 ms 3340 KB Output is correct
20 Correct 19 ms 3340 KB Output is correct
21 Correct 0 ms 3340 KB Output is correct
22 Correct 0 ms 3340 KB Output is correct
23 Correct 0 ms 3340 KB Output is correct
24 Correct 0 ms 3340 KB Output is correct
25 Correct 0 ms 3340 KB Output is correct
26 Correct 0 ms 3340 KB Output is correct
27 Correct 0 ms 3340 KB Output is correct
28 Correct 0 ms 3340 KB Output is correct
29 Correct 0 ms 3476 KB Output is correct
30 Correct 2 ms 3472 KB Output is correct
31 Correct 0 ms 3476 KB Output is correct
32 Correct 0 ms 3476 KB Output is correct
33 Correct 3 ms 3484 KB Output is correct
34 Correct 0 ms 3484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3340 KB Output is correct
2 Correct 0 ms 3340 KB Output is correct
3 Correct 0 ms 3340 KB Output is correct
4 Correct 0 ms 3340 KB Output is correct
5 Correct 0 ms 3340 KB Output is correct
6 Correct 0 ms 3340 KB Output is correct
7 Correct 0 ms 3340 KB Output is correct
8 Correct 0 ms 3340 KB Output is correct
9 Correct 0 ms 3340 KB Output is correct
10 Correct 0 ms 3340 KB Output is correct
11 Correct 1 ms 3340 KB Output is correct
12 Correct 0 ms 3340 KB Output is correct
13 Correct 0 ms 3340 KB Output is correct
14 Correct 0 ms 3340 KB Output is correct
15 Correct 0 ms 3340 KB Output is correct
16 Correct 0 ms 3340 KB Output is correct
17 Correct 1 ms 3340 KB Output is correct
18 Correct 0 ms 3340 KB Output is correct
19 Correct 0 ms 3340 KB Output is correct
20 Correct 19 ms 3340 KB Output is correct
21 Correct 1 ms 3340 KB Output is correct
22 Correct 0 ms 3340 KB Output is correct
23 Correct 0 ms 3340 KB Output is correct
24 Correct 2 ms 3340 KB Output is correct
25 Correct 0 ms 3340 KB Output is correct
26 Correct 0 ms 3340 KB Output is correct
27 Correct 0 ms 3340 KB Output is correct
28 Correct 0 ms 3340 KB Output is correct
29 Correct 0 ms 3476 KB Output is correct
30 Correct 0 ms 3472 KB Output is correct
31 Correct 0 ms 3476 KB Output is correct
32 Correct 2 ms 3476 KB Output is correct
33 Correct 0 ms 3484 KB Output is correct
34 Correct 0 ms 3484 KB Output is correct
35 Correct 13 ms 3604 KB Output is correct
36 Correct 0 ms 3340 KB Output is correct
37 Correct 5 ms 3640 KB Output is correct
38 Correct 14 ms 3604 KB Output is correct
39 Correct 10 ms 3604 KB Output is correct
40 Correct 5 ms 3604 KB Output is correct
41 Correct 5 ms 3604 KB Output is correct
42 Correct 5 ms 3472 KB Output is correct
43 Correct 7 ms 3472 KB Output is correct
44 Correct 308 ms 3472 KB Output is correct
45 Correct 8 ms 3648 KB Output is correct
46 Correct 12 ms 3644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3340 KB Output is correct
2 Correct 1 ms 3340 KB Output is correct
3 Correct 0 ms 3340 KB Output is correct
4 Correct 0 ms 3340 KB Output is correct
5 Correct 0 ms 3340 KB Output is correct
6 Correct 0 ms 3340 KB Output is correct
7 Correct 0 ms 3340 KB Output is correct
8 Correct 0 ms 3340 KB Output is correct
9 Correct 0 ms 3340 KB Output is correct
10 Correct 0 ms 3340 KB Output is correct
11 Correct 0 ms 3340 KB Output is correct
12 Correct 0 ms 3340 KB Output is correct
13 Correct 0 ms 3340 KB Output is correct
14 Correct 0 ms 3340 KB Output is correct
15 Correct 2 ms 3340 KB Output is correct
16 Correct 0 ms 3340 KB Output is correct
17 Correct 2 ms 3340 KB Output is correct
18 Correct 0 ms 3340 KB Output is correct
19 Correct 0 ms 3340 KB Output is correct
20 Correct 22 ms 3340 KB Output is correct
21 Correct 0 ms 3340 KB Output is correct
22 Correct 0 ms 3340 KB Output is correct
23 Correct 0 ms 3340 KB Output is correct
24 Correct 2 ms 3340 KB Output is correct
25 Correct 0 ms 3340 KB Output is correct
26 Correct 0 ms 3340 KB Output is correct
27 Correct 0 ms 3340 KB Output is correct
28 Correct 2 ms 3340 KB Output is correct
29 Correct 2 ms 3476 KB Output is correct
30 Correct 0 ms 3472 KB Output is correct
31 Correct 0 ms 3476 KB Output is correct
32 Correct 0 ms 3476 KB Output is correct
33 Correct 3 ms 3484 KB Output is correct
34 Correct 3 ms 3484 KB Output is correct
35 Correct 8 ms 3604 KB Output is correct
36 Correct 3 ms 3340 KB Output is correct
37 Correct 0 ms 3640 KB Output is correct
38 Correct 14 ms 3604 KB Output is correct
39 Correct 0 ms 3604 KB Output is correct
40 Correct 11 ms 3604 KB Output is correct
41 Correct 8 ms 3604 KB Output is correct
42 Correct 4 ms 3472 KB Output is correct
43 Correct 5 ms 3472 KB Output is correct
44 Correct 312 ms 3472 KB Output is correct
45 Correct 14 ms 3648 KB Output is correct
46 Correct 11 ms 3644 KB Output is correct
47 Correct 13 ms 4456 KB Output is correct
48 Correct 0 ms 3736 KB Output is correct
49 Correct 0 ms 3736 KB Output is correct
50 Correct 0 ms 3604 KB Output is correct
51 Correct 23 ms 5472 KB Output is correct
52 Correct 21 ms 4708 KB Output is correct
53 Correct 18 ms 4128 KB Output is correct
54 Correct 0 ms 3472 KB Output is correct
55 Correct 0 ms 3472 KB Output is correct
56 Execution timed out 1000 ms 4664 KB Program timed out
57 Halted 0 ms 0 KB -