답안 #18886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18886 2016-02-16T11:11:28 Z chan492811 Jakarta Skyscrapers (APIO15_skyscraper) C++
36 / 100
372 ms 262144 KB
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

struct data{
    int to,dist;
};
struct cmp{
    bool operator()(data d1,data d2){
        return d1.dist>d2.dist;
    }
};
int n,m;
int dist[2010];
data arr[30010];
bool visit[2010],visit2[2010][2010];
vector<data> vt[2010];
priority_queue<data,vector<data>,cmp> pq;

void dij(int a){
    int i,j,flag=1,now;
    data s;
    while(flag){
        flag=0; now=21e8;
        for(i=0;i<n;i++){
            if(!visit[i] && dist[i] && dist[i]<now) a=i,flag=1,now=dist[i];
        }
        if(!flag) break; visit[a]=1;
        for(i=0;i<vt[a].size();i++){
            s=vt[a][i];
            if(!dist[s.to] || dist[s.to]>dist[a]+s.dist) dist[s.to]=dist[a]+s.dist;
        }
    }
}
int main(){
    int i,j;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++) scanf("%d %d",&arr[i].to,&arr[i].dist),visit[arr[i].to]=1;
    for(i=0;i<m;i++){
        visit2[arr[i].to][arr[i].to]=1;
        for(j=0;j<n;j++){
            if(!(abs(arr[i].to-j)%arr[i].dist) && !visit2[arr[i].to][j]) vt[arr[i].to].push_back((data){j,abs(arr[i].to-j)/arr[i].dist});
        }
    }
    memset(visit,0,sizeof(visit));
    dist[arr[0].to]=1;
    dij(0);
    if(!visit[arr[1].to]) printf("-1");
    else printf("%d",dist[arr[1].to]-1);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5812 KB Output is correct
2 Correct 0 ms 5812 KB Output is correct
3 Correct 0 ms 5812 KB Output is correct
4 Correct 0 ms 5812 KB Output is correct
5 Correct 0 ms 5812 KB Output is correct
6 Correct 0 ms 5812 KB Output is correct
7 Correct 0 ms 5812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5812 KB Output is correct
2 Correct 0 ms 5812 KB Output is correct
3 Correct 0 ms 5812 KB Output is correct
4 Correct 0 ms 5812 KB Output is correct
5 Correct 0 ms 5812 KB Output is correct
6 Correct 0 ms 5812 KB Output is correct
7 Correct 0 ms 5812 KB Output is correct
8 Correct 0 ms 5812 KB Output is correct
9 Correct 0 ms 5812 KB Output is correct
10 Correct 0 ms 5812 KB Output is correct
11 Correct 2 ms 5812 KB Output is correct
12 Correct 5 ms 8892 KB Output is correct
13 Correct 0 ms 8904 KB Output is correct
14 Correct 2 ms 5812 KB Output is correct
15 Correct 0 ms 5812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5812 KB Output is correct
2 Correct 0 ms 5812 KB Output is correct
3 Correct 0 ms 5812 KB Output is correct
4 Correct 0 ms 5812 KB Output is correct
5 Correct 0 ms 5812 KB Output is correct
6 Correct 0 ms 5812 KB Output is correct
7 Correct 0 ms 5812 KB Output is correct
8 Correct 0 ms 5812 KB Output is correct
9 Correct 0 ms 5812 KB Output is correct
10 Correct 1 ms 5812 KB Output is correct
11 Correct 0 ms 5812 KB Output is correct
12 Correct 0 ms 8892 KB Output is correct
13 Correct 4 ms 8904 KB Output is correct
14 Correct 2 ms 5812 KB Output is correct
15 Correct 2 ms 5812 KB Output is correct
16 Correct 0 ms 5812 KB Output is correct
17 Correct 8 ms 5944 KB Output is correct
18 Correct 8 ms 5812 KB Output is correct
19 Correct 7 ms 5812 KB Output is correct
20 Correct 71 ms 37748 KB Output is correct
21 Correct 0 ms 5812 KB Output is correct
22 Correct 8 ms 5812 KB Output is correct
23 Correct 16 ms 5812 KB Output is correct
24 Correct 32 ms 5944 KB Output is correct
25 Correct 30 ms 5812 KB Output is correct
26 Correct 83 ms 55100 KB Output is correct
27 Correct 76 ms 55032 KB Output is correct
28 Correct 35 ms 5944 KB Output is correct
29 Correct 14 ms 6536 KB Output is correct
30 Correct 10 ms 5944 KB Output is correct
31 Correct 16 ms 6076 KB Output is correct
32 Correct 14 ms 5944 KB Output is correct
33 Correct 35 ms 7256 KB Output is correct
34 Correct 35 ms 7152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5812 KB Output is correct
2 Correct 0 ms 5812 KB Output is correct
3 Correct 0 ms 5812 KB Output is correct
4 Correct 0 ms 5812 KB Output is correct
5 Correct 0 ms 5812 KB Output is correct
6 Correct 0 ms 5812 KB Output is correct
7 Correct 0 ms 5812 KB Output is correct
8 Correct 0 ms 5812 KB Output is correct
9 Correct 0 ms 5812 KB Output is correct
10 Correct 0 ms 5812 KB Output is correct
11 Correct 0 ms 5812 KB Output is correct
12 Correct 3 ms 8892 KB Output is correct
13 Correct 2 ms 8904 KB Output is correct
14 Correct 2 ms 5812 KB Output is correct
15 Correct 0 ms 5812 KB Output is correct
16 Correct 0 ms 5812 KB Output is correct
17 Correct 11 ms 5944 KB Output is correct
18 Correct 11 ms 5812 KB Output is correct
19 Correct 3 ms 5812 KB Output is correct
20 Correct 89 ms 37748 KB Output is correct
21 Correct 0 ms 5812 KB Output is correct
22 Correct 9 ms 5812 KB Output is correct
23 Correct 16 ms 5812 KB Output is correct
24 Correct 32 ms 5944 KB Output is correct
25 Correct 30 ms 5812 KB Output is correct
26 Correct 75 ms 55100 KB Output is correct
27 Correct 60 ms 55032 KB Output is correct
28 Correct 32 ms 5944 KB Output is correct
29 Correct 18 ms 6536 KB Output is correct
30 Correct 11 ms 5944 KB Output is correct
31 Correct 16 ms 6076 KB Output is correct
32 Correct 14 ms 5944 KB Output is correct
33 Correct 35 ms 7256 KB Output is correct
34 Correct 35 ms 7152 KB Output is correct
35 Correct 219 ms 7292 KB Output is correct
36 Correct 34 ms 5944 KB Output is correct
37 Correct 245 ms 9032 KB Output is correct
38 Correct 369 ms 8356 KB Output is correct
39 Correct 371 ms 8608 KB Output is correct
40 Correct 371 ms 8384 KB Output is correct
41 Correct 366 ms 8236 KB Output is correct
42 Memory limit exceeded 271 ms 262144 KB Memory limit exceeded
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5812 KB Output is correct
2 Correct 0 ms 5812 KB Output is correct
3 Correct 0 ms 5812 KB Output is correct
4 Correct 0 ms 5812 KB Output is correct
5 Correct 0 ms 5812 KB Output is correct
6 Correct 0 ms 5812 KB Output is correct
7 Correct 0 ms 5812 KB Output is correct
8 Correct 0 ms 5812 KB Output is correct
9 Correct 0 ms 5812 KB Output is correct
10 Correct 1 ms 5812 KB Output is correct
11 Correct 0 ms 5812 KB Output is correct
12 Correct 5 ms 8892 KB Output is correct
13 Correct 0 ms 8904 KB Output is correct
14 Correct 0 ms 5812 KB Output is correct
15 Correct 0 ms 5812 KB Output is correct
16 Correct 0 ms 5812 KB Output is correct
17 Correct 8 ms 5944 KB Output is correct
18 Correct 7 ms 5812 KB Output is correct
19 Correct 8 ms 5812 KB Output is correct
20 Correct 71 ms 37748 KB Output is correct
21 Correct 3 ms 5812 KB Output is correct
22 Correct 6 ms 5812 KB Output is correct
23 Correct 16 ms 5812 KB Output is correct
24 Correct 32 ms 5944 KB Output is correct
25 Correct 35 ms 5812 KB Output is correct
26 Correct 81 ms 55100 KB Output is correct
27 Incorrect 69 ms 55032 KB Output isn't correct - wrong output format : File not found: "/var/www/temp/18886/outputtS05_1"
28 Halted 0 ms 0 KB -
29 Correct 13 ms 6536 KB Output is correct
30 Correct 10 ms 5944 KB Output is correct
31 Correct 11 ms 6076 KB Output is correct
32 Correct 14 ms 5944 KB Output is correct
33 Correct 27 ms 7256 KB Output is correct
34 Correct 35 ms 7152 KB Output is correct
35 Correct 217 ms 7292 KB Output is correct
36 Correct 34 ms 5944 KB Output is correct
37 Correct 246 ms 9032 KB Output is correct
38 Correct 364 ms 8356 KB Output is correct
39 Correct 368 ms 8608 KB Output is correct
40 Correct 368 ms 8384 KB Output is correct
41 Correct 372 ms 8236 KB Output is correct
42 Memory limit exceeded 253 ms 262144 KB Memory limit exceeded
43 Halted 0 ms 0 KB -