Submission #14619

# Submission time Handle Problem Language Result Execution time Memory
14619 2015-05-22T04:28:37 Z ioojh6654 마술 (GCJ14_magic) C++
6 / 6
0 ms 1084 KB
#include<stdio.h>
 
int main()
{
    int i, j, k, n, a, m[6][6], cnt, out;
    int l[4][6];
    scanf("%d",&n);
    for(k=1 ; k<=n ; k++)
    {
        cnt=0;
        scanf("%d",&a);
        for(i=1 ; i<=4 ; i++)
        {
            for(j=1 ; j<=4 ; j++)
            {
                scanf("%d",&m[i][j]);
                if(i==a) l[1][j]=m[i][j];
            }
        }
        scanf("%d",&a);
        for(i=1 ; i<=4 ; i++)
        {
            for(j=1 ; j<=4 ; j++)
            {
                scanf("%d",&m[i][j]);
                if(i==a) l[2][j]=m[i][j];
            }
        }
        for(i=1 ; i<=4 ; i++) for(j=1 ; j<=4 ; j++) if(l[1][i]==l[2][j]) out=l[1][i], cnt++;
        if(cnt==0) printf("Case #%d: Volunteer cheated!\n",k);
        if(cnt==1) printf("Case #%d: %d\n",k,out);
        if(cnt>=2) printf("Case #%d: Bad magician!\n",k);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1084 KB Output is correct