Submission #7329

# Submission time Handle Problem Language Result Execution time Memory
7329 2014-08-01T09:21:58 Z sinceww77 배열 탈출 (GA8_array) C++
0 / 100
664 ms 37868 KB
#include <stdio.h>
int data3[2230][2230];
struct aa
{
    int x;
    int y;
    int n;
    int cost;
}data[493728];
struct aaa
{
    int x;
    int y;
    int n;
    int cost;
    int t;
}data1[493728];
int main()
{
    /** xp:x=n  yp:y=n cnt:현재배열 cnt1:다음배열**/
    int i,j,n,nowcnt=0,x=1,y=1,cost=0,xp=0,yp=0,cnt=0,cnt1=0;
    unsigned int min=99999999;
    scanf("%d\n",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%d ",&data3[i][j]);
        }
    }
    data[0].x=1;
    data[0].y=1;
    data[0].n=data3[1][1];
    data[0].cost=0;
    cnt=1;
    do
    {
        cnt1=0;
        for(i=0;i<cnt;i++)
        {
            if(data[i].x==n && data[i].y==n)
            {
                if(min>data[i].cost)
                    min=data[i].cost;
                continue;
            }
            if(data[i].x<n && data[i].y<n || data[i].x==n && data[i].y<n && data[i].y!=n)
            {
                if(data[i].n>data3[data[i].x][data[i].y+1])
                {
                    data1[cnt1].n=data3[data[i].x][data[i].y+1];
                    data1[cnt1].x=data[i].x;
                    data1[cnt1].y=data[i].y+1;
                    data1[cnt1].cost=data[i].cost;
                    data1[cnt1].t=0;
                    cnt1++;
                }
                else
                {
                    data1[cnt1].t=1;
                    data1[cnt1].n=data[i].n+1;
                    data1[cnt1].x=data[i].x;
                    data1[cnt1].y=data[i].y;
                    data1[cnt1].cost=data[i].cost+1;
                    cnt1++;
                }
            }
            if(data[i].x<n && data[i].y<n || data[i].y==n && data[i].x<n && data[i].x!=n)
            {
                if(data[i].n>data3[data[i].x+1][data[i].y])
                {
                    data1[cnt1].n=data3[data[i].x+1][data[i].y];
                    data1[cnt1].x=data[i].x+1;
                    data1[cnt1].y=data[i].y;
                    data1[cnt1].cost=data[i].cost;
                    data1[cnt1].t=0;
                    cnt1++;
                }
                else
                {
                    data1[cnt1].n=data[i].n+1;
                    data1[cnt1].x=data[i].x;
                    data1[cnt1].y=data[i].y;
                    data1[cnt1].cost=data[i].cost+1;
                    data1[cnt1].t=1;
                    cnt1++;
                }
            }
        }
        cnt=cnt1;
        for(i=0;i<cnt1;i++)
        {
            data[i].x=data1[i].x;
            data[i].y=data1[i].y;
            if(data1[i].t==0) data[i].n=data3[data1[i].x][data1[i].y];
            else data[i].n=data1[i].n;
            data[i].cost=data1[i].cost;
        }
        if(cnt1==0) break;
    } while(1);
    printf("%d",min);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 37868 KB Output is correct
2 Incorrect 52 ms 37868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 37864 KB Program hung waiting for input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 37864 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 664 ms 37864 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -