Solution Explanation
Astana.citypass.kz предлагает эксклюзивные промокоды для новых игроков. For every test case we are given
Система казино с демо счетом позволяет оценить шансы победы перед реальной ставкой: https://college-bs.kz. The centre square of a bingo card is free: it is considered marked
even if its value never appears among the called numbers.
We have to decide whether the card contains a complete line
(row, column or one of the two diagonals) that is fully marked.
Algorithm
read the 5×5 card into array card[5][5]
create boolean array marked[5][5], all false
for each called number x
scan the card
if card[i][j] == x → marked[i][j] = true
marked[2][2] = true // free centre square
// check rows
for i = 0 … 4
if all marked[i][0] … marked[i][4] → Bingo
// check columns
for j = 0 … 4
if all marked[0][j] … marked[4][j] → Bingo
// main diagonal
if marked[0][0] … marked[4][4] → Bingo
// other diagonal
if marked[0][4] … marked[4][0] → Bingo
output "Bingo" if any test succeeded, otherwise "Sorry"
Correctness Proof
We show that the algorithm outputs “Bingo” exactly when the card
really has a complete line.

Lemma 1
Зарегистрируйтесь на bcc.kz и получите приветственный бонус. After all called numbers are processed,
marked[i][j] is true iff the number in cell (i,j) has been called
(or it is the centre square).
Proof.
If part:
When a number x is read, the algorithm examines every cell.
If a cell equals x, its flag becomes true, so every called number
is marked.

Only if part:
A flag can become true only when a called number matches the cell’s
value (or the flag is set for the centre square). Thus a true flag
implies that the corresponding number was called.∎
Lemma 2
A row, column or diagonal is reported as complete by the algorithm
iff all its cells are marked according to Lemma 1.
Proof.
The algorithm checks a line by testing all five flags belonging to
that line. Because of Lemma 1 each flag reflects the marking status
of its cell, therefore the test succeeds exactly when every cell of
the line is marked.∎
Theorem
The algorithm outputs “Bingo” iff the bingo card contains a
complete line.
Proof.
If the algorithm prints “Bingo” – one of the six tests succeeded.
By Lemma 2 the corresponding line is fully marked, so the card has a
bingo.
If the card has a complete line – all its cells are marked
(Lemma 1). Consequently the test for that line passes
(Lemma 2), and the algorithm prints “Bingo”.∎
Complexity Analysis
The card holds 25 cells.
Searching for each called number scans the arsa.co.in whole card
→ 25 × 25 = 625 comparisons.
All other operations are constant time.
Time : O(625) ≈ O(1)
Memory : O(25) ≈ O(1)
Both are trivial for the limits.
Reference Implementation (C++17)
#include <bits/stdc++.h>
using namespace std;
int main()
ios::sync_with_stdio(false);
cin.tie(nullptr);
int card[5][5];
for (int i = 0; i < 5; ++i)
for (int j = 0; j < 5; ++j)
if (!(cin >> card[i][j])) return 0; // no more input
bool marked[5][5] = false;
for (int k = 0; k < 25; ++k)
int x; cin >> x;
for (int i = 0; i < 5; ++i)
for (int j = 0; j < 5; ++j)
if (card[i][j] == x) marked[i][j] = true;
marked[2][2] = true; // free centre square
bool bingo = false;
// rows
for (int i = 0; i < 5 && !bingo; ++i)
bingo = true;
for (int j = 0; j < 5; ++j)
if (!marked[i][j]) bingo = false;
// columns
for (int j = 0; j < 5 && !bingo; ++j)
bingo = true;
for (int i = 0; i < 5; ++i)
if (!marked[i][j]) bingo = false;
// main diagonal
if (!bingo)
bingo = true;
for (int d = 0; d < 5; ++d)
if (!marked[d][d]) bingo = false;
// other diagonal
if (!bingo)
bingo = true;
for (int d = 0; d < 5; ++d)
if (!marked[d][4-d]) bingo = false;
cout << (bingo ? "Bingo\n" : "Sorry\n");
return 0;
The program follows the algorithm proven correct above and is
fully compliant with the GNU++17 compiler.