# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
8236 |
2014-09-07T11:39:05 Z |
baneling100 |
마술 (GCJ14_magic) |
C++ |
|
0 ms |
1088 KB |
#include <stdio.h>
int T, A[5][5], B[5][5], X, Y, Check[17];
void input(void) {
int i, j;
scanf("%d",&X);
for(i=1 ; i<=4 ; i++)
for(j=1 ; j<=4 ; j++)
scanf("%d",&A[i][j]);
scanf("%d",&Y);
for(i=1 ; i<=4 ; i++)
for(j=1 ; j<=4 ; j++)
scanf("%d",&B[i][j]);
}
int process(void) {
int i, cnt=0, v;
for(i=1 ; i<=16 ; i++)
Check[i]=0;
for(i=1 ; i<=4 ; i++)
Check[A[X][i]]=1;
for(i=1 ; i<=4 ; i++) {
if(Check[B[Y][i]]) {
cnt++;
v=B[Y][i];
}
}
if(cnt==1)
return v;
else if(cnt==0)
return 0;
return -1;
}
void output(int Num1, int Num2) {
if(Num2==0)
printf("Case #%d: Volunteer cheated!\n",Num1);
else if(Num2==-1)
printf("Case #%d: Bad magician!\n",Num1);
else
printf("Case #%d: %d\n",Num1,Num2);
}
int main(void) {
int i, temp;
scanf("%d",&T);
for(i=1 ; i<=T ; i++) {
input();
output(i,process());
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1088 KB |
Output is correct |