binwon236   11달 전

코딩 시작한지 얼마 되지않아 코드가 아주 개판입니다.

알고리즘은 이렇습니다.

0. 문자열로 체스판을 입력 받는다.

1. 맨 처음의 체스 판의 색깔을 받고 key값에 저장한다.

2. check함수 호출

3. check 함수  key값이 'b' 일 경우 인덱스의 짝수 번이 'b' 이기에 b가 아니면 다음 문자열의 인덱스로 이동, count+1

4. 위 반대의 경우를 조건문으로 구현

가로 방향으로 모두 돌 경우 세로 방향으로 +1 하고 key값을 부정

대충 이렇습니다. 이것도 개판이네여 죄송합니다.

반례는 대충 다 넣어봤는데 1초만에 틀렸습니다가 뜹니다...

도와주십쇼~~~!!!!

314programs   11달 전

반례:

18 48
BBBBBWBBBWWWWWBBWWBBBWBBWBWBBBWBWWBWBBBWBWWBBBWB
BBWBBBWBBBWWWWWBBWBWBBBBBBBBBBBBBWWWWWBWWBWWBBWW
WBWWBWBWBBBWBWBBBWWWWBWBBWWWBWWWWWWWWWWBWWWBWBBW
BBWBWBBBBWWWBWWWWBBWBWWBBWWBBBBBWWBWBBBBBBWWBBBW
BBBWBWWBWBBWBBWBWBWBWWBWWBBWWWBWWBBWBBBBWWBBBWBB
WBWBBBWWWWBWWBBWWBWBBWBBBWBWWBBBBWBBBWBWBBWBWWBW
BWWWWBBWBBBBWWWWWBBBBBBBBBBWBBWBWWWWBBBBBWBWWWWW
WBWWBWBBWBBWBBWWBWWWWBWWWWWBBWWWBBWBBWWBWBBWBWWW
BWBWBBWBWBBWWBBBWBWWWWBWBWWBWWBWBWWWBWBBBWBBBBBW
WBWBWBWBWBWWWWWBWWBBWBBWWBBBBBBBBBBBBBWBBWWWWBBW
BBBWBBWBWWBBBWWWWWBBBWBBWBWWWWWBWBWBWBBBBBBBBBWB
WBWBWWWWBBBBBBWWWBBBWWBWWBWWWWWWBBWBBWWBWBBWBWBB
BBWWWWWBBWBBBBWWBBBWBBWWWBBBWWWBWWWWBBWBWWWWWWBB
BBWBBWBWWWBWBWBBWBBBBBWBBWWWWBWBBBWBWBBWBWBWBBWB
BWBWBBWBBWBBWWWBBWBBWBBWBBBWWWBWBBBWWBBWWWWBWBBB
WWWBWBWBWWWBWWBWWBBWWBBBBBBWBWWBWWWBBBBWWBWBBWWW
BBBWBBWBWWBBBBBBWBBBBBWWWBWBBBBWBWWBWWWWWWBWBBBW
BWBWWWWWWWWWWWBBBWWBBBWBBBWBWBBWBBBWBWBWBBWWBBWB

답: 20

출력: 21

binwon236   11달 전

단순히 정답 값에 +1 하면 되는거같진 않은데 제 알고리즘이 문제있는건가요?

314programs   11달 전

네, 다른 케이스도 틀렸어요.

반례들:

29 16
BWBBWBBWBBBBBBBB
WBBWWBWWWBWWBBWB
BBBWBWBWWBWBBWWW
BWWBBBBWWBWWBWBB
BWWBBBWBWWBBBBWW
WBBBBBWWWWBWBBBB
BBWWBBBWWBWWWBBW
WWWBWBWWBWBWBBWB
WWBWWWBWBWWBWBBW
WBBBWBBBBWWWBWBW
WBWBBBWWBWWBBBWB
BWBWBBWBWBWBBWBW
WBBWWWBBWWBWBWBW
BWBBWBWWBWWWBBWW
BBBBWBBBWWBWWBBW
WWBBBWWWBWWWWBWW
WWBBBBBWWBWBWBBW
BBBWBWBWBWWWBBBB
BWBWWBBBWBBWBBWW
WWWWWWBWWWBBBBWB
BBBWBWWWWWWWBBWW
BWBBWBWBWBWBWWWB
WWBBWWWWWWWWWBBB
WWBWWBWWWWBWBBBB
BBWWBWWBBWBBWBWB
WBBBBWBWWBWBWWBW
BWWBBBBWWWBBBBBB
BBWBWWWWBWWBBBBW
BWBWBWBWBWWBBBBW

정답: 22

출력: 23

17 22
BBBBBBBBWBWWBWBBWBWWBB
WBBBBWBWBWBWWBBWWBBWWB
BBBBWWWWWBBBWBWWBWBWWB
WWWBBBBBWBWWWWWWBBBWWW
BBBWBBWBWWBBWBWWWBWWWW
BWWWWWWWBBWBBBBBWWWWWB
BWWBBWBWWWBBWBBWBBWBWW
WWWWWBBBWWBBWBBBWBBWBW
BWWWWWBWBBBWWBBWBWBBWW
WWBWWBWWBWBWWBWWBWWBBW
BBWWBWWWWBBBWBBBWWBBBB
BWWWWWBBWBWWBBBWBWBBBB
WBWWWBWBWBWWBWBBWBBBWB
BBBWBWWWWBWWBBWWWBBWWW
WWBWBBWWWWBWBWWBBBBBWW
WBWWWBBBWBBWBWBBBWBWBW
WWBWWBBWBWBWBWWBWWWBWB

정답: 20

출력: 24

댓글에 추가한 더 많은 반례들: https://www.acmicpc.net/board/...

힘네세요!

댓글을 작성하려면 로그인해야 합니다.