• + 0 comments

    13, 14, 15, 16 timed out.

    Any clue on this ??

    include

    int X, Y, order, odr, limit, bfound= 0;

    int f[50];

    void calAns(int idx, int x, int y);

    void init();

    void init()

    {

    int i;
    
    order = 0;
    
    odr = 0;
    
    limit = 0;
    
    bfound = 0;
    
    for(i = 0; i<50; i++)
    
        f[i] = 0;
    

    }

    int main()

    {

    int T, tc;
    
    scanf("%d",&T);
    
    for(tc = 1; tc<= T; tc++)
    
    {
    
        init();
    
        scanf("%d",&X);
    
        scanf("%d",&Y);
    
        scanf("%d",&order);
    
        limit = X + Y;
    
        calAns(0, 0, 0);
    
    }
    
    return 0;
    

    }

    void calAns(int idx, int x, int y)

    {

    int i;
    
    if(x == X && y == Y)
    
    {
    
        if(odr == order)
    
        {
    
            for(i = 0; i < limit; i++)
    
            {
    
                if(f[i])
    
                    printf("H");
    
                else
    
                    printf("V");
    
            }
    
            printf("\n");
    
            bfound = 1;
    
        }
    
        odr++;
    
        return;
    
    }
    
    if(x > X || y > Y)
        return;
    
    if(bfound == 0){
        f[idx] = 1;
        calAns(idx+1, x+1, y);
        f[idx] = 0;
        calAns(idx+1, x, y+1);
    }
    

    }