## 370 - Bingo

Moderator: Board moderators

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

### 370 - Bingo

The problem doesn't say anything about how bingos of the same kind should be sorted. If the input is

Code: Select all

``````0 0 0 1 0
3 0 2 0 1
0 0 0 0 0
4 0 7 0 8
0 5 6 0 0
1
2 3 5
0``````
am I right that the output is this?

Code: Select all

``````BINGO #1
3,1,FREE
3,2,FREE
3,3,FREE
3,4,FREE
3,5,FREE
BINGO #3
1,1,FREE
1,5,FREE
5,1,FREE
5,5,FREE
BINGO #4
1,1,FREE
2,2,FREE
3,3,FREE
4,4,FREE
5,5,FREE
BINGO #4
1,5,FREE
2,4,FREE
3,3,FREE
4,2,FREE
5,1,FREE

``````
And similarly, if there are even more zeros on the initial board, how should the bingos of type 1 and 2 be sorted? I've assumed row-ascending and col-ascending order, but you never know... I've had lots of WA, so if anyone could post a tricky test case, I'd appreciate it.

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm
That's what I did, and got AC. My output matches yours.

I can't imagine any trickies. The only thing I noticed when I saw your example is that you put more than one call in the same line. I took the
a series of lines each containing one ``called" number
quite literally and read only one numer per line, even if there are more. So for the input

Code: Select all

``````1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
1
2
3
4 5
0``````
my program doesn't call bingo. But I don't know if that is an issue with the judge's data.

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden
Thanks! Knowing that the problem wasn't in that part, I found the energy to construct some other test cases and found a really trivial error.

Concerning several numbers on the same line: the input doesn't seem to be dirty. I read all numbers one by one ignoring linebreaks altogether.

_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

### Now... what am I missing??.

My prog. gets WA at second 1+.
Well, here's the code, please take a look at it if you have the time:
[pascal]{ Bernardo E. L
_.

flavio
New poster
Posts: 11
Joined: Sun Mar 06, 2005 4:07 pm
Location: Porto Alegre - RS (Brazil)
Contact:

### I/O Help!!

Does anybody can help me!?
I need some input/output...

I've tested my program and I don't know what is wrong...

INPUT and OUTPUT are very welcome!!

Help Help!

Fl

leonardooo
New poster
Posts: 8
Joined: Sun Nov 28, 2004 9:26 am
Location: Campina Grande - PB / Brazil

### Some in/out examples

My AC Code generate this:

IN

Code: Select all

``````1  2  3  4  5
11 12 13 14 15
21 22  0 24 25
31 32 33 34 35
91 92 93 94 95
21
22
24
25
99
0
1  2  3  4  5
11 12 13 14 15
21 22  0 24 25
31 32 33 34 35
91 92 93 94 95
99
98
97
96
0
1  2  3  4  5
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
91 92 93 94 95
1
12
34
95
5
14
32
23
91
0
1  2  3  4  5
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
91 92 93 94 95
1
12
34
95
5
14
32
91
23
0
0  2  3  4  0
11 0 13 0 15
21 22 0 24 25
31 0 33 0 35
0 92 93 94 0
1
12
34
95
5
14
32
23
91
0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
2
7
12
17
22
0
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
1
2
3
4
5
0
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
1
7
13
19
25
0
1 1 1 1 1
1 0 0 0 1
1 1 1 1 1
1 0 0 0 1
1 1 1 1 1
1
0
``````
OUT

Code: Select all

``````BINGO #1
3,1,21
3,2,22
3,3,FREE
3,4,24
3,5,25

No BINGO on this card.

BINGO #4
1,1,1
2,2,12
3,3,23
4,4,34
5,5,95

BINGO #3
1,1,1
1,5,5
5,1,91
5,5,95

BINGO #3
1,1,FREE
1,5,FREE
5,1,FREE
5,5,FREE
BINGO #4
1,1,FREE
2,2,FREE
3,3,FREE
4,4,FREE
5,5,FREE
BINGO #4
1,5,FREE
2,4,FREE
3,3,FREE
4,2,FREE
5,1,FREE

BINGO #1
1,1,FREE
1,2,FREE
1,3,FREE
1,4,FREE
1,5,FREE
BINGO #1
2,1,FREE
2,2,FREE
2,3,FREE
2,4,FREE
2,5,FREE
BINGO #1
3,1,FREE
3,2,FREE
3,3,FREE
3,4,FREE
3,5,FREE
BINGO #1
4,1,FREE
4,2,FREE
4,3,FREE
4,4,FREE
4,5,FREE
BINGO #1
5,1,FREE
5,2,FREE
5,3,FREE
5,4,FREE
5,5,FREE
BINGO #2
1,1,FREE
2,1,FREE
3,1,FREE
4,1,FREE
5,1,FREE
BINGO #2
1,2,FREE
2,2,FREE
3,2,FREE
4,2,FREE
5,2,FREE
BINGO #2
1,3,FREE
2,3,FREE
3,3,FREE
4,3,FREE
5,3,FREE
BINGO #2
1,4,FREE
2,4,FREE
3,4,FREE
4,4,FREE
5,4,FREE
BINGO #2
1,5,FREE
2,5,FREE
3,5,FREE
4,5,FREE
5,5,FREE
BINGO #3
1,1,FREE
1,5,FREE
5,1,FREE
5,5,FREE
BINGO #4
1,1,FREE
2,2,FREE
3,3,FREE
4,4,FREE
5,5,FREE
BINGO #4
1,5,FREE
2,4,FREE
3,3,FREE
4,2,FREE
5,1,FREE

BINGO #2
1,2,2
2,2,7
3,2,12
4,2,17
5,2,22

BINGO #1
1,1,1
1,2,2
1,3,3
1,4,4
1,5,5

BINGO #4
1,1,1
2,2,7
3,3,13
4,4,19
5,5,25

BINGO #1
1,1,1
1,2,1
1,3,1
1,4,1
1,5,1
BINGO #1
2,1,1
2,2,FREE
2,3,FREE
2,4,FREE
2,5,1
BINGO #1
3,1,1
3,2,1
3,3,1
3,4,1
3,5,1
BINGO #1
4,1,1
4,2,FREE
4,3,FREE
4,4,FREE
4,5,1
BINGO #1
5,1,1
5,2,1
5,3,1
5,4,1
5,5,1
BINGO #2
1,1,1
2,1,1
3,1,1
4,1,1
5,1,1
BINGO #2
1,2,1
2,2,FREE
3,2,1
4,2,FREE
5,2,1
BINGO #2
1,3,1
2,3,FREE
3,3,1
4,3,FREE
5,3,1
BINGO #2
1,4,1
2,4,FREE
3,4,1
4,4,FREE
5,4,1
BINGO #2
1,5,1
2,5,1
3,5,1
4,5,1
5,5,1
BINGO #3
1,1,1
1,5,1
5,1,1
5,5,1
BINGO #4
1,1,1
2,2,FREE
3,3,1
4,4,FREE
5,5,1
BINGO #4
1,5,1
2,4,FREE
3,3,1
4,2,FREE
5,1,1

``````

[]
Eu sou foda? N

cysppol
New poster
Posts: 1
Joined: Wed Nov 22, 2006 9:53 am

### WA code for 370

Fallowing is my WA code, someone can tell me what mistake for me?
For above tests, my output are all right, but it is still a WA code.

Code: Select all

``````#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Rule1(i) (BingoCard[i][0][1]&&BingoCard[i][1][1]&&BingoCard[i][2][1]&&BingoCard[i][3][1]&&BingoCard[i][4][1])&&(BingoCard[i][0][2]||BingoCard[i][1][2]||BingoCard[i][2][2]||BingoCard[i][3][2]||BingoCard[i][4][2])
#define Rule2(j) (BingoCard[0][j][1]&&BingoCard[1][j][1]&&BingoCard[2][j][1]&&BingoCard[3][j][1]&&BingoCard[4][j][1])&&(BingoCard[0][j][3]||BingoCard[1][j][3]||BingoCard[2][j][3]||BingoCard[3][j][3]||BingoCard[4][j][3])
#define Rule3    (BingoCard[0][0][1]&&BingoCard[0][4][1]&&BingoCard[4][0][1]&&BingoCard[4][4][1])				     &&(BingoCard[0][0][4]||BingoCard[0][4][4]||BingoCard[4][0][4]||BingoCard[4][4][4])
#define Rule4_1  (BingoCard[0][0][1]&&BingoCard[1][1][1]&&BingoCard[2][2][1]&&BingoCard[3][3][1]&&BingoCard[4][4][1])&&(BingoCard[0][0][5]||BingoCard[1][1][5]||BingoCard[2][2][5]||BingoCard[3][3][5]||BingoCard[4][4][5])
#define Rule4_2  (BingoCard[0][4][1]&&BingoCard[1][3][1]&&BingoCard[2][2][1]&&BingoCard[3][1][1]&&BingoCard[4][0][1])&&(BingoCard[0][4][5]||BingoCard[1][3][5]||BingoCard[2][2][5]||BingoCard[3][1][5]||BingoCard[4][0][5])
#define IsCorner(i,j) (i==0&&j==0)||(i==0&&j==4)||(i==4&&j==0)||(i==4&&j==4)

int main()
{
int BingoCard[5][5][6];
int BingoFlag;
int CallValue;
char CallValueStr;
int CallValueSpaceFlag;
int i,j,k;

while(scanf("%d%d%d%d%d", &BingoCard[0][0][0],&BingoCard[0][1][0],&BingoCard[0][2][0],&BingoCard[0][3][0],&BingoCard[0][4][0]) == 5)
{
for (j=0;j<5;j++)
{
if (BingoCard[0][j][0]==0)
{
BingoCard[0][j][1]=1;
}
else
{
BingoCard[0][j][1]=0;
}
BingoCard[0][j][2]=1;
BingoCard[0][j][3]=1;
BingoCard[0][j][4]=1;
BingoCard[0][j][5]=1;
}

for (i=1;i<5;i++)
{
for (j=0;j<5;j++)
{
scanf("%d", &BingoCard[i][j][0]);
if (BingoCard[i][j][0]==0)
{
BingoCard[i][j][1]=1;
}
else
{
BingoCard[i][j][1]=0;
}
BingoCard[i][j][2]=1;
BingoCard[i][j][3]=1;
BingoCard[i][j][4]=1;
BingoCard[i][j][5]=1;
}
}

getchar();
CallValue = 100;
BingoFlag = 0;
while(CallValue!=0)
{
if (!BingoFlag)
{
for (i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
if (BingoCard[i][j][0] == CallValue)
{
BingoCard[i][j][1] = 1;
}
}
}

for (i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
if (BingoCard[i][j][1] == 1)
{
if (Rule1(i))
{
printf("BINGO #1\n");
for (k=0;k<5;k++)
{
if (BingoCard[i][k][0] == 0)
printf("%d,%d,FREE\n",i+1,k+1);
else
printf("%d,%d,%d\n",i+1,k+1,BingoCard[i][k][0]);

BingoCard[i][k][2] = 0;
}
BingoFlag = 1;
}
}
}
}

for (i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
if (BingoCard[i][j][1] == 1)
{
if (Rule2(j))
{
printf("BINGO #2\n");
for (k=0;k<5;k++)
{
if (BingoCard[k][j][0] == 0)
printf("%d,%d,FREE\n",k+1,j+1);
else
printf("%d,%d,%d\n",k+1,j+1,BingoCard[k][j][0]);

BingoCard[k][j][3] = 0;
}
BingoFlag = 1;
}
}
}
}

if (Rule3)
{
printf("BINGO #3\n");

if (BingoCard[0][0][0] == 0)
printf("%d,%d,FREE\n",1,1);
else
printf("%d,%d,%d\n",1,1,BingoCard[0][0][0]);

if (BingoCard[0][4][0] == 0)
printf("%d,%d,FREE\n",1,5);
else
printf("%d,%d,%d\n",1,5,BingoCard[0][4][0]);

if (BingoCard[4][0][0] == 0)
printf("%d,%d,FREE\n",5,1);
else
printf("%d,%d,%d\n",5,1,BingoCard[4][0][0]);

if (BingoCard[4][4][0] == 0)
printf("%d,%d,FREE\n",5,5);
else
printf("%d,%d,%d\n",5,5,BingoCard[4][4][0]);

BingoCard[0][0][4] = 0;
BingoCard[0][4][4] = 0;
BingoCard[4][0][4] = 0;
BingoCard[4][4][4] = 0;
BingoFlag = 1;
}

for (i=0;i<5;i++)
{
for (j=0;j<5;j++)
{
if (BingoCard[i][j][1] == 1 && i==j)
{
if (Rule4_1)
{
printf("BINGO #4\n");
for (k=0;k<5;k++)
{
if (BingoCard[k][k][0] == 0)
printf("%d,%d,FREE\n",k+1,k+1);
else
printf("%d,%d,%d\n",k+1,k+1,BingoCard[k][k][0]);
BingoCard[k][k][5] = 0;
}
BingoFlag = 1;
}
}
else if (BingoCard[i][j][1] == 1 && i==4-j)
{
if (Rule4_2)
{
printf("BINGO #4\n");
for (k=0;k<5;k++)
{
if (BingoCard[k][4-k][0] == 0)
printf("%d,%d,FREE\n",k+1,4-k+1);
else
printf("%d,%d,%d\n",k+1,4-k+1,BingoCard[k][4-k][0]);
BingoCard[k][4-k][5] = 0;
}
BingoFlag = 1;
}
}
}
}
}

CallValue = 0;
CallValueSpaceFlag = 1;
CallValueStr = getchar();
//printf("%c=",CallValueStr);
while(CallValueStr != 0x0A)
{
if (CallValueStr == 0x20)
CallValueSpaceFlag = 0;
if (CallValueSpaceFlag)
CallValue = CallValue*10 + ((int)CallValueStr - 48);
CallValueStr = getchar();
//printf("%d\n",(int)CallValueStr);
}
//printf("%d\n",CallValue);
}

if (!BingoFlag)
{
printf("No BINGO on this card.\n");
}

printf("\n");
}
}
``````

Roger
New poster
Posts: 1
Joined: Sat Jul 07, 2007 9:48 pm
Location: UE

### WA - Problem 370 (Bingo)

Hi,

I've been searching for errors and debugging but no idea about why WA.
The program outputs correctly the inputs given above, if anyone could take a look at it, it would be great. Thanks, here is my code:

Code: Select all

``````Removed after AC
``````
See you soon !
Last edited by Roger on Sun Jul 08, 2007 9:43 pm, edited 1 time in total.

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

### Re: 370 - Bingo

The solution on uDebug seems have some problem, it couldn't get right output for input:

Code: Select all

``````1 1 1 1 1
1 0 0 0 1
1 1 1 1 1
1 0 0 0 1
1 1 1 1 1
1
0
``````
the output of uDebug solution:

Code: Select all

``````No BINGO on this card.

``````
it is wrong obviously.