11620 - pD - Distrait
raw download clone
C
views 31
,
size 2485 b
#include <stdio.h>

int card[6][6];
int valid[26];
int place(void);

int main(void)
{
    int t, n, temp, ans;

    for(int i=1; i<=5; i++)
    {
        for(int j=1; j<=5; j++)
            scanf("%d", &card[i][j]);
    }
    scanf("%d", &t);
    for(int k=1; k<=t; k++)
    {
        ans = 0;
        for(int l=1; l<=25; l++)
            valid[l] = 0;
        scanf("%d", &n);
        for(int m=1; m<=n; m++)
        {
            scanf("%d", &temp);
            valid[temp] = 1;
            if(ans == 0)
            {
                if(place() == 1)
                    ans = m;
            }
        }
        if(ans != 0)
            printf("Case #%d: %d\n", k, ans);
        else
            printf("Case #%d: Not yet \\(^o^)/\n", k);
    }

    return 0;
}

int place(void)
{
    if(valid[card[1][1]] * valid[card[1][2]] * valid[card[1][3]] * valid[card[1][4]] * valid[card[1][5]] == 1)
        return 1;
    else if(valid[card[2][1]] * valid[card[2][2]] * valid[card[2][3]] * valid[card[2][4]] * valid[card[2][5]] == 1)
        return 1;
    else if(valid[card[3][1]] * valid[card[3][2]] * valid[card[3][3]] * valid[card[3][4]] * valid[card[3][5]] == 1)
        return 1;
    else if(valid[card[4][1]] * valid[card[4][2]] * valid[card[4][3]] * valid[card[4][4]] * valid[card[4][5]] == 1)
        return 1;
    else if(valid[card[5][1]] * valid[card[5][2]] * valid[card[5][3]] * valid[card[5][4]] * valid[card[5][5]] == 1)
        return 1;
    else if(valid[card[1][1]] * valid[card[2][1]] * valid[card[3][1]] * valid[card[4][1]] * valid[card[5][1]] == 1)
        return 1;
    else if(valid[card[1][2]] * valid[card[2][2]] * valid[card[3][2]] * valid[card[4][2]] * valid[card[5][2]] == 1)
        return 1;
    else if(valid[card[1][3]] * valid[card[2][3]] * valid[card[3][3]] * valid[card[4][3]] * valid[card[5][3]] == 1)
        return 1;
    else if(valid[card[1][4]] * valid[card[2][4]] * valid[card[3][4]] * valid[card[4][4]] * valid[card[5][4]] == 1)
        return 1;
    else if(valid[card[1][5]] * valid[card[2][5]] * valid[card[3][5]] * valid[card[4][5]] * valid[card[5][5]] == 1)
        return 1;
    else if(valid[card[1][1]] * valid[card[2][2]] * valid[card[3][3]] * valid[card[4][4]] * valid[card[5][5]] == 1)
        return 1;
    else if(valid[card[1][5]] * valid[card[2][4]] * valid[card[3][3]] * valid[card[4][2]] * valid[card[5][1]] == 1)
        return 1;
    else
        return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.