Skip to content

Commit

Permalink
2024-05-30 ๋น™๊ณ 
Browse files Browse the repository at this point in the history
  • Loading branch information
oesnuj committed May 30, 2024
1 parent db33368 commit d8f1ecc
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions oesnuj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
| 6์ฐจ์‹œ | 2024.05.06 | ๊ธฐํ•˜ํ•™ | [์ •์‚ฌ๊ฐํ˜•](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) |
| 7์ฐจ์‹œ | 2024.05.08 | ์Šคํƒ, ํ, ๋ฑ | [queuestack](https://www.acmicpc.net/problem/24511) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/24) |
| 8์ฐจ์‹œ | 2024.05.13 | ์šฐ์„ ์ˆœ์œ„ ํ | [์นด๋“œ ์ •๋ ฌํ•˜๊ธฐ](https://www.acmicpc.net/problem/1715) | [#27](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/27) |
| 9์ฐจ์‹œ | 2024.05.30 | ๊ตฌํ˜„ | [๋น™๊ณ ](https://www.acmicpc.net/problem/2578) | [#30](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/30) |
---
79 changes: 79 additions & 0 deletions oesnuj/๊ตฌํ˜„/2578.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <iostream>
using namespace std;

const int BINGO_SIZE = 5;
int board[BINGO_SIZE][BINGO_SIZE];

void changeBingo(int target);
int checkBingo();



int main()
{
ios::sync_with_stdio(0); cin.tie(0);
for (int i = 0; i < BINGO_SIZE; i++)
{
for (int j = 0; j < BINGO_SIZE; j++)
{
cin >> board[i][j];
}
}

int sayCnt = 0;
for (int i = 0; i < BINGO_SIZE * BINGO_SIZE; i++)
{
int num;
cin >> num;
sayCnt++;
changeBingo(num);
if (checkBingo() >= 3) {
cout << sayCnt;
return 0;
}
}
return 0;
}


void changeBingo(int target) //์‚ฌํšŒ์ž๊ฐ€ ๋ถ€๋ฅธ ์ˆ˜ ์ฒดํฌํ•˜๊ธฐ
{
for (int i = 0; i < BINGO_SIZE; i++){
for (int j = 0; j < BINGO_SIZE; j++){
if (board[i][j] == target){
board[i][j] = 0;
return;
}
}
}
return;
}

int checkBingo() //ํ˜„์žฌ ๋ณด๋“œํŒ์— ๋น™๊ณ ๊ฐ€ ๋ช‡์ค„์ธ์ง€
{
int bingoCnt = 0;

for (int i = 0; i < BINGO_SIZE; i++) //๊ฐ€๋กœ, ์„ธ๋กœ ๋น™๊ณ  ํ™•์ธ
{
int horizontal = 0, vertical = 0;
for (int j = 0; j < BINGO_SIZE; j++){
if (!board[i][j])
horizontal++;
if (!board[j][i])
vertical++;
}
if (horizontal == BINGO_SIZE) bingoCnt++;
if (vertical == BINGO_SIZE) bingoCnt++;
}

int right_diagonal = 0, left_diagonal = 0;
for (int i = 0; i < BINGO_SIZE; i++) //๋Œ€๊ฐ์„  2๊ฐœ ๋น™๊ณ  ํ™•์ธ
{
if (!board[i][i]) right_diagonal++;
if (!board[i][BINGO_SIZE - i - 1]) left_diagonal++;
}
if (right_diagonal == BINGO_SIZE) bingoCnt++;
if (left_diagonal == BINGO_SIZE) bingoCnt++;

return bingoCnt;
}

0 comments on commit d8f1ecc

Please sign in to comment.