회원가입
로그인
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
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
여기 있는 반례 다해봤는데 틀린부분을 못찾겠습니다. 도와주세요ㅜ
1051번 - 숫자 정사각형
zheldgkrl
3년 전
0
여기 있는 반례 다해봤는데 틀린부분을 못찾겠습니다. 도와주세요ㅜ
import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { static int[][] matrix = new int[5][5]; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); String[] order = br.readLine().split(" "); int row = Integer.parseInt(order[0]); int column = Integer.parseInt(order[1]); int[][] matrix = new int[row][column]; for(int i=0; i<matrix.length; i++){ String line = br.readLine(); for(int j=0; j<matrix[i].length; j++){ matrix[i][j] = Character.getNumericValue(line.charAt(j)); } } int min = Math.min(row,column); int size = min-1; int x = 0; int y = 0; while(size != 0){ List<Integer> spot = new ArrayList<>(); for(int i=x; i<matrix.length; i+=(size)){ int isTwo = 0; for(int j=y; j<matrix[i].length; j+=(size)){ spot.add(matrix[i][j]); isTwo++; if(isTwo == 2){ break; } } } // 만약 꼭지점이 같지 않으면 int same = spot.get(0); boolean isSame = true; for(int z=1; z<spot.size(); z++){ if(spot.get(z) != same){ isSame = false; break; } } if(isSame){ bw.write((int)Math.pow(size+1,2) + ""); bw.flush(); break; } if((x+size) == row-1 && (y+size) == column-1){ size--; x = 0; y = 0; } else if((x+size) == row-1 && (y+size) != column-1){ y++; } else if((x+size) != row-1 && (y+size) == column-1){ x++; y = 0; }else{ y++; } } if(size == 0){ bw.write(1 + ""); bw.flush(); } bw.close(); } }
protarie
3년 전
0
더 단순한 방법을 생각해보시는게 좋을듯하네요...
댓글을 작성하려면
로그인
해야 합니다.
zheldgkrl 3년 전