Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
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 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

코드와이

[정올] 1037. 오류교정 본문

정올

[정올] 1037. 오류교정

코드와이 2021. 2. 24. 18:05

 

문제링크

jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=316&sca=99&sfl=wr_subject&stx=%EC%98%A4%EB%A5%98

 

JUNGOL

 

www.jungol.co.kr

 

package 정올;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class 오류교정 {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		int n = Integer.parseInt(br.readLine());
		int[][] arr = new int[n][n];
		
		int check = 0; // 짝수인지 확인
		int r = 0;
		for(int i = 0 ; i < n ; i++) {
			st = new StringTokenizer(br.readLine());
			int sum = 0;
			for(int j = 0 ; j < n ; j++) {
				arr[i][j] = Integer.parseInt(st.nextToken());
				sum += arr[i][j];
			}
			if (sum % 2 != 0) {
				r = i;
				check += 1;
			}
		}
		
		if(check > 1) {
			System.out.println("Corrupt");
			return;
		}
		else {
			check = 0;
			int c = 0;
			for(int i = 0 ; i < n ; i++) {
				int sum = 0;
				for(int j = 0 ; j < n ; j++) {
					sum += arr[j][i];
				}
				if (sum % 2 != 0) {
					c = i;
					check += 1;
				}
			}
			if( check > 1 ) {
				System.out.println("Corrupt");
				return;
			}
			else if(check == 1) {
				System.out.println("Change bit (" + (r+1) + "," + (1+c) + ")");
			}
			else System.out.println("OK");
		}
		
		
	}
}

'정올' 카테고리의 다른 글

[정올] 1863. 종교  (0) 2021.03.19
[정올] 1205. 조커  (0) 2021.02.24