Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 26 | 27 | 28 |
Tags
- ReactorKit
- 스위프트
- 대외활동
- 백준
- 스유
- 멋쟁이사자처럼
- spritekit
- dispatchqueue
- swift concurrency
- 문법
- 위젯킷
- uikit
- cs
- Protocol
- composable architecture
- 알고리즘
- widget
- TCA
- Swift
- 웹
- 네트워크
- c++
- 후기
- 컴퓨터그래픽스
- SwiftUI
- widgetkit
- 리액트
- 멋사
- 운영체제
- 영남대
Archives
- Today
- Total
맛동산이
백준 1018번 : 체스판 다시칠하기(c++) 본문
https://www.acmicpc.net/problem/1018
1018번: 체스판 다시 칠하기
첫째 줄에 N과 M이 주어진다. N과 M은 8보다 크거나 같고, 50보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에는 보드의 각 행의 상태가 주어진다. B는 검은색이며, W는 흰색이다.
www.acmicpc.net
처음 본 아이디어가 맞앗고, 쓰레기같은 문제인것은 확실하다.
그냥 귀찮았음.
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
string WB[8] = {
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW"
};
string BW[8] = {
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB",
"BWBWBWBW",
"WBWBWBWB"
};
string board[50];
int WB_cnt(int x, int y)
{
int cnt = 0;
for(int i = 0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
if(board[x+i][y+j] != WB[i][j])
cnt++;
}
}
return cnt;
}
int BW_cnt(int x, int y)
{
int cnt = 0;
for(int i = 0; i < 8; i++)
{
for(int j = 0; j < 8; j++)
{
if(board[x+i][y+j] != BW[i][j])
cnt++;
}
}
return cnt;
}
int main() {
int size[2];
int cnt;
int min_val = 12345;
pair<int, int> p1;
cin >> p1.first >> p1.second;
for(int i = 0; i < p1.first; i++)
cin >> board[i];
for(int i = 0; i + 8 <= p1.first; i++)
{
for(int j = 0; j + 8 <= p1.second; j++)
{
int tmp;
tmp = min(WB_cnt(i,j),BW_cnt(i,j));
if(tmp < min_val) {
min_val = tmp;
}
}
}
cout << min_val;
return 0;
}
아 코드는 내꺼가 아니고
https://cryptosalamander.tistory.com/13
[백준 / BOJ] - 1018번 체스판 다시 칠하기 C++ 풀이
백준 - 단계별로 풀어보기 [1018] 체스판 다시 칠하기 https://www.acmicpc.net/problem/1018 문제 M*N 크기의 보드를 잘라 8x8크기의 체스판을 얻으려고 하는데, 주어진 보드에서 8x8 체스판을 만들때, 가장 적.
cryptosalamander.tistory.com
이분꺼를 참고했다. ㅎㅎ
반응형