회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
2
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
반례가 있나요? Java
3085번 - 사탕 게임
wjdxo2633
3년 전
0
반례가 어떤게 있을까요?
여러가지 찾아봤는데 못찾겠습니다.
import java.io.*; import java.util.*; public class Main { public static char arr[][]; public static int num; public static int MAX = Integer.MIN_VALUE; public static int stack = 0; public static void getCount(char temp[][]) { int count = 0; int result = 0; stack++; /* * if(stack==32) { for(int i=1;i<=num;i++) { for(int j=1;j<=num;j++) { * System.out.print(temp[i][j]); } System.out.println(); } } */ //세로 check for(int i=1;i<=num;i++) { count = 1; for(int j=1;j<=num;j++) { if(i==j)continue; if(temp[j][i] == temp[j+1][i]) { count++; } } if(count > MAX)MAX = count; } //가로 check for(int i=1;i<=num;i++) { count = 1; for(int j=1;j<=num;j++) { if(i==j)continue; if(temp[i][j] == temp[i][j+1]) { count++; } } if(count > MAX)MAX = count; } } public static void getSwap1(int x, int y) { char temp_arr[][] = new char[num+2][num+2]; for(int i=0;i<=num;i++) { for(int j=0;j<=num;j++) { temp_arr[i][j] = arr[i][j]; } } char temp = temp_arr[x][y]; temp_arr[x][y] = temp_arr[x+1][y]; temp_arr[x+1][y] = temp; getCount(temp_arr); } public static void getSwap2(int x, int y) { char temp_arr[][] = new char[num+2][num+2]; for(int i=0;i<=num;i++) { for(int j=0;j<=num;j++) { temp_arr[i][j] = arr[i][j]; } } char temp = temp_arr[x][y]; temp_arr[x][y] = temp_arr[x][y+1]; temp_arr[x][y+1] = temp; getCount(temp_arr); } public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); num = Integer.parseInt(br.readLine()); //for(int i=0;i<55;i++)for(int j=0;j<55;j++)arr[i][j] = 'A'; //초기화 arr = new char[num+2][num+2]; //초기화 for(int i=1;i<=num;i++) { String temp = br.readLine(); for(int j=1;j<=num;j++) { arr[i][j] = temp.charAt(j-1); } } //Swap and calcu for(int i=1;i<=num;i++) { for(int j=1;j<=num;j++) { getSwap1(i,j); getSwap2(i,j); } } System.out.println(MAX); } }
댓글을 작성하려면
로그인
해야 합니다.
wjdxo2633 3년 전
반례가 어떤게 있을까요?
여러가지 찾아봤는데 못찾겠습니다.