답안 #14577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14577 2015-05-20T06:41:33 Z dohyun0324 Jakarta Skyscrapers (APIO15_skyscraper) C++
57 / 100
238 ms 230960 KB
#include<stdio.h>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
bool ch[30010][175];
vector<int>con[30010];
typedef pair<int,int> ppair;
struct data{
    int val,x,y;
    char c;
    bool operator<(const data&r)const{
        return val>r.val;
    }
}b;
data q[30010*300],imsi[30010*175];
int sw,n,m,root,s,pos,f=-1,r=0;
struct data2{
    int x,p;
}a[30010];
int main()
{
    int sw2,i,j,val,x,y,c,w=0;
    scanf("%d %d",&n,&m);
    root=sqrt(n);
    for(i=0;i<m;i++){scanf("%d %d",&a[i].x,&a[i].p); con[a[i].x].push_back(a[i].p);}
    b.val=0, b.x=a[0].x, b.y=a[0].p, q[0]=b;
    while(f<r){
        sw2=0;
        while(f<r){
            f++;
            if(q[f].y<=root){
                if(ch[q[f].x][q[f].y]){
                    if(f==r){
                        for(i=1;i<=w;i++) q[++r]=imsi[i];
                        w=0;
                    }
                    continue;
                }
                else{sw2=1; break;}
            }
            x=q[f].x; val=q[f].val; y=q[f].y; c=q[f].c;
            if(x==a[1].x){printf("%d",val); return 0;}
            if(ch[x][0]==0){
                for(i=0;i<con[x].size();i++){
                    b.val=val; b.x=x; b.y=con[x][i]; b.c=0;
                    q[++r]=b;
                }
            }
            if(c==1 || c==0){
                for(i=x+y;i<n;i+=y){
                    b.val=val+1; b.x=i; b.y=y; b.c=1; imsi[++w]=b; break;
                }
            }
            if(c==2 || c==0){
                for(i=x-y;i>=0;i-=y){
                    b.val=val+1; b.x=i; b.y=y; b.c=2; imsi[++w]=b; break;
                }
            }
            ch[x][0]=1;
            if(f==r){
                for(i=1;i<=w;i++) q[++r]=imsi[i];
                w=0;
            }
        }
        if(!sw2){sw=1; break;}
        val=q[f].val; x=q[f].x; y=q[f].y; ch[x][y]=1;
        if(x==a[1].x) break;
        if(ch[x][0]==0){
            for(i=0;i<con[x].size();i++){
                b.val=val; b.x=x; b.y=con[x][i]; b.c=0;
                q[++r]=b;
            }
        }
        ch[x][0]=1;
        if(x+y<n) b.val=val+1, b.x=x+y, b.y=y, b.c=0, imsi[++w]=b;
        if(x-y>=0) b.val=val+1, b.x=x-y, b.y=y, b.c=0, imsi[++w]=b;
        if(f==r){
            for(i=1;i<=w;i++) q[++r]=imsi[i];
            w=0;
        }
    }
    if(sw) printf("-1");
    else printf("%d",val);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 230036 KB Output is correct
2 Correct 0 ms 230036 KB Output is correct
3 Correct 0 ms 230036 KB Output is correct
4 Correct 0 ms 230036 KB Output is correct
5 Correct 0 ms 230036 KB Output is correct
6 Correct 0 ms 230036 KB Output is correct
7 Correct 0 ms 230036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 230036 KB Output is correct
2 Correct 0 ms 230036 KB Output is correct
3 Correct 0 ms 230036 KB Output is correct
4 Correct 0 ms 230036 KB Output is correct
5 Correct 0 ms 230036 KB Output is correct
6 Correct 0 ms 230036 KB Output is correct
7 Correct 0 ms 230036 KB Output is correct
8 Correct 0 ms 230036 KB Output is correct
9 Correct 0 ms 230036 KB Output is correct
10 Correct 0 ms 230036 KB Output is correct
11 Correct 0 ms 230036 KB Output is correct
12 Correct 0 ms 230036 KB Output is correct
13 Correct 1 ms 230036 KB Output is correct
14 Correct 0 ms 230036 KB Output is correct
15 Correct 0 ms 230036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 230036 KB Output is correct
2 Correct 0 ms 230036 KB Output is correct
3 Correct 0 ms 230036 KB Output is correct
4 Correct 0 ms 230036 KB Output is correct
5 Correct 0 ms 230036 KB Output is correct
6 Correct 0 ms 230036 KB Output is correct
7 Correct 0 ms 230036 KB Output is correct
8 Correct 0 ms 230036 KB Output is correct
9 Correct 0 ms 230036 KB Output is correct
10 Correct 0 ms 230036 KB Output is correct
11 Correct 0 ms 230036 KB Output is correct
12 Correct 0 ms 230036 KB Output is correct
13 Correct 0 ms 230036 KB Output is correct
14 Correct 0 ms 230036 KB Output is correct
15 Correct 0 ms 230036 KB Output is correct
16 Correct 0 ms 230036 KB Output is correct
17 Correct 0 ms 230036 KB Output is correct
18 Correct 0 ms 230036 KB Output is correct
19 Correct 0 ms 230036 KB Output is correct
20 Correct 0 ms 230036 KB Output is correct
21 Correct 0 ms 230036 KB Output is correct
22 Correct 1 ms 230036 KB Output is correct
23 Correct 0 ms 230036 KB Output is correct
24 Correct 0 ms 230036 KB Output is correct
25 Correct 0 ms 230036 KB Output is correct
26 Correct 0 ms 230036 KB Output is correct
27 Correct 0 ms 230036 KB Output is correct
28 Correct 0 ms 230036 KB Output is correct
29 Correct 4 ms 230036 KB Output is correct
30 Correct 0 ms 230036 KB Output is correct
31 Correct 0 ms 230036 KB Output is correct
32 Correct 2 ms 230036 KB Output is correct
33 Correct 3 ms 230036 KB Output is correct
34 Correct 3 ms 230036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 230036 KB Output is correct
2 Correct 0 ms 230036 KB Output is correct
3 Correct 0 ms 230036 KB Output is correct
4 Correct 0 ms 230036 KB Output is correct
5 Correct 0 ms 230036 KB Output is correct
6 Correct 0 ms 230036 KB Output is correct
7 Correct 0 ms 230036 KB Output is correct
8 Correct 0 ms 230036 KB Output is correct
9 Correct 0 ms 230036 KB Output is correct
10 Correct 0 ms 230036 KB Output is correct
11 Correct 0 ms 230036 KB Output is correct
12 Correct 0 ms 230036 KB Output is correct
13 Correct 0 ms 230036 KB Output is correct
14 Correct 1 ms 230036 KB Output is correct
15 Correct 1 ms 230036 KB Output is correct
16 Correct 0 ms 230036 KB Output is correct
17 Correct 0 ms 230036 KB Output is correct
18 Correct 1 ms 230036 KB Output is correct
19 Correct 0 ms 230036 KB Output is correct
20 Correct 0 ms 230036 KB Output is correct
21 Correct 0 ms 230036 KB Output is correct
22 Correct 0 ms 230036 KB Output is correct
23 Correct 1 ms 230036 KB Output is correct
24 Correct 1 ms 230036 KB Output is correct
25 Correct 0 ms 230036 KB Output is correct
26 Correct 0 ms 230036 KB Output is correct
27 Correct 0 ms 230036 KB Output is correct
28 Correct 0 ms 230036 KB Output is correct
29 Correct 4 ms 230036 KB Output is correct
30 Correct 0 ms 230036 KB Output is correct
31 Correct 2 ms 230036 KB Output is correct
32 Correct 0 ms 230036 KB Output is correct
33 Correct 3 ms 230036 KB Output is correct
34 Correct 3 ms 230036 KB Output is correct
35 Correct 6 ms 230168 KB Output is correct
36 Correct 0 ms 230036 KB Output is correct
37 Correct 3 ms 230168 KB Output is correct
38 Correct 8 ms 230168 KB Output is correct
39 Correct 10 ms 230168 KB Output is correct
40 Correct 9 ms 230168 KB Output is correct
41 Correct 11 ms 230168 KB Output is correct
42 Correct 7 ms 230168 KB Output is correct
43 Correct 6 ms 230168 KB Output is correct
44 Correct 6 ms 230168 KB Output is correct
45 Correct 19 ms 230168 KB Output is correct
46 Correct 11 ms 230168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 230036 KB Output is correct
2 Correct 0 ms 230036 KB Output is correct
3 Correct 0 ms 230036 KB Output is correct
4 Correct 0 ms 230036 KB Output is correct
5 Correct 0 ms 230036 KB Output is correct
6 Correct 0 ms 230036 KB Output is correct
7 Correct 0 ms 230036 KB Output is correct
8 Correct 0 ms 230036 KB Output is correct
9 Correct 0 ms 230036 KB Output is correct
10 Correct 0 ms 230036 KB Output is correct
11 Correct 1 ms 230036 KB Output is correct
12 Correct 0 ms 230036 KB Output is correct
13 Correct 0 ms 230036 KB Output is correct
14 Correct 0 ms 230036 KB Output is correct
15 Correct 0 ms 230036 KB Output is correct
16 Correct 0 ms 230036 KB Output is correct
17 Correct 0 ms 230036 KB Output is correct
18 Correct 0 ms 230036 KB Output is correct
19 Correct 0 ms 230036 KB Output is correct
20 Correct 0 ms 230036 KB Output is correct
21 Correct 0 ms 230036 KB Output is correct
22 Correct 0 ms 230036 KB Output is correct
23 Correct 0 ms 230036 KB Output is correct
24 Correct 0 ms 230036 KB Output is correct
25 Correct 0 ms 230036 KB Output is correct
26 Correct 0 ms 230036 KB Output is correct
27 Correct 0 ms 230036 KB Output is correct
28 Correct 1 ms 230036 KB Output is correct
29 Correct 4 ms 230036 KB Output is correct
30 Correct 0 ms 230036 KB Output is correct
31 Correct 3 ms 230036 KB Output is correct
32 Correct 0 ms 230036 KB Output is correct
33 Correct 6 ms 230036 KB Output is correct
34 Correct 0 ms 230036 KB Output is correct
35 Correct 5 ms 230168 KB Output is correct
36 Correct 0 ms 230036 KB Output is correct
37 Correct 6 ms 230168 KB Output is correct
38 Correct 8 ms 230168 KB Output is correct
39 Correct 7 ms 230168 KB Output is correct
40 Correct 0 ms 230168 KB Output is correct
41 Correct 7 ms 230168 KB Output is correct
42 Correct 3 ms 230168 KB Output is correct
43 Correct 0 ms 230168 KB Output is correct
44 Correct 6 ms 230168 KB Output is correct
45 Correct 20 ms 230168 KB Output is correct
46 Correct 8 ms 230168 KB Output is correct
47 Correct 6 ms 230300 KB Output is correct
48 Correct 8 ms 230432 KB Output is correct
49 Correct 0 ms 230432 KB Output is correct
50 Correct 7 ms 230300 KB Output is correct
51 Correct 11 ms 230564 KB Output is correct
52 Correct 11 ms 230564 KB Output is correct
53 Correct 7 ms 230564 KB Output is correct
54 Correct 0 ms 230036 KB Output is correct
55 Correct 0 ms 230036 KB Output is correct
56 Correct 13 ms 230960 KB Output is correct
57 Correct 0 ms 230036 KB Output is correct
58 Correct 10 ms 230168 KB Output is correct
59 Correct 12 ms 230168 KB Output is correct
60 Correct 6 ms 230172 KB Output is correct
61 Correct 0 ms 230184 KB Output is correct
62 Correct 34 ms 230960 KB Output is correct
63 Correct 67 ms 230168 KB Output is correct
64 Correct 74 ms 230168 KB Output is correct
65 Correct 135 ms 230168 KB Output is correct
66 Runtime error 238 ms 230164 KB Program hung waiting for input
67 Halted 0 ms 0 KB -