BRAVEDUCK 오답

  • raccond
    raccond

    문제에 주어진 샘플 확인시에는 문제가 없는데,
    제출하면 오답이 나옵니다.

    무엇이 문제일까요...
    도움 부탁 드립니다.

    감사합니다.

    #include<stdio.h>
    #include<string.h>
    
    const int TRUE = 1; 
    const int FALSE = 0; 
    
    int stone_X[102]; 
    int stone_Y[102]; 
    int stone_vistied[102]; 
    
    int number_of_stones; 
    
    int jump(int jump_power, int x, int y, int finish_X, int finish_Y); 
    
    int main()
    {
        int T = 0; 
        int i = 0;
        int j = 0;  
    
        int jump_power = 0; 
        int start_X = 0; 
        int start_Y = 0; 
        int finish_X = 0; 
        int finish_Y = 0; 
    
        int result = 0; 
    
        scanf("%d", &T);
    
        for(j = 0; j< T; j++)
        {
            scanf("%d", &jump_power);
    
            scanf("%d", &start_X);
            scanf("%d", &start_Y);
    
            scanf("%d", &finish_X);
            scanf("%d", &finish_Y);
    
            scanf("%d", &number_of_stones);
    
            memset(stone_X, 0x00, sizeof(stone_X)); 
            memset(stone_Y, 0x00, sizeof(stone_Y));
            memset(stone_vistied, 0x00, sizeof(stone_vistied)); //set NOT visited.
    
            for(i = 0;i<number_of_stones;i++)
            {
                scanf("%d", &stone_X[i]);
                scanf("%d", &stone_Y[i]);
            }
    
            result = jump(jump_power, start_X, start_Y, finish_X, finish_Y); 
    
            if(result==0)
            {
                printf("NO\n"); 
            }
            else
            {
                printf("YES\n"); 
            }
        }
    }
    
    int jump(int jump_power, int x, int y, int finish_X, int finish_Y)
    {
        int i = 0;
        int j = 0;  
        int check_if_finshed = 0; 
    
        for( i = 1; i <= jump_power; i++)
        {
            for(j =0; j< number_of_stones ; j++)
            {
                if(((x-i) == finish_X)&&(y == finish_Y))
                return TRUE; 
    
                if(((x-i)==stone_X[j])&&(y==stone_Y[j]))
                {
                    if(stone_vistied[j]==FALSE)
                    {   
                        stone_vistied[j]= TRUE; 
                        check_if_finshed += jump(jump_power, stone_X[j], stone_Y[j], finish_X, finish_Y);
                    }
                }
    
                if(((x+i) == finish_X)&&(y == finish_Y))
                    return TRUE;
    
                if(((x+i)==stone_X[j])&&(y==stone_Y[j]))
                {
                    if(stone_vistied[j]==FALSE)
                    {   
                        stone_vistied[j]= TRUE; 
                        check_if_finshed += jump(jump_power, stone_X[j], stone_Y[j], finish_X, finish_Y);
                    }               
                }
    
                if((x == finish_X)&&((y+i) == finish_Y))
                    return TRUE; 
    
                if(((x)==stone_X[j])&&((y+i)==stone_Y[j]))
                {
                    if(stone_vistied[j]==FALSE)
                    {   
                        stone_vistied[j]= TRUE; 
                        check_if_finshed += jump(jump_power, stone_X[j], stone_Y[j], finish_X, finish_Y);
                    }                   
                }
    
                if((x == finish_X)&&((y-i) == finish_Y))
                    return TRUE; 
    
                if(((x)==stone_X[j])&&((y-i)==stone_Y[j]))
                {
                    if(stone_vistied[j]==FALSE)
                    {   
                        stone_vistied[j]= TRUE; 
                        check_if_finshed += jump(jump_power, stone_X[j], stone_Y[j], finish_X, finish_Y);
                    }               
                }
            }
        }
        return check_if_finshed; 
    }
    

    10년 전
2개의 댓글이 있습니다.
  • 샥후
    샥후

    대각선으로 점프하는 경우를 고려해야합니다.


    10년 전 link
  • raccond
    raccond

    아 그렇군요! 감사합니다.


    10년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.