Created
December 15, 2014 10:16
-
-
Save amoshyc/78c50d2c0a4d1e8f4d50 to your computer and use it in GitHub Desktop.
uva541.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int main() { | |
| int N; | |
| while (scanf("%d", &N)) { | |
| if (N == 0) break; | |
| int row_sum[N]; | |
| int col_sum[N]; | |
| memset(row_sum, 0, sizeof(row_sum)); | |
| memset(col_sum, 0, sizeof(col_sum)); | |
| int col, row; | |
| for(col=0; col<N; col++) { | |
| for(row=0; row<N; row++) { | |
| int elem; | |
| scanf("%d", &elem); | |
| row_sum[row] += elem; | |
| col_sum[col] += elem; | |
| } | |
| } | |
| int odd_row_cnt = 0; | |
| int odd_col_cnt = 0; | |
| int row_idx = -1; | |
| int col_idx = -1; | |
| int i; | |
| for(i=0; i<N; i++) { | |
| if (row_sum[i] % 2 == 1) { | |
| odd_row_cnt++; | |
| row_idx = i; | |
| } | |
| if (col_sum[i] % 2 == 1) { | |
| odd_col_cnt++; | |
| col_idx = i; | |
| } | |
| } | |
| if (odd_col_cnt == 0 && odd_row_cnt == 0) | |
| printf("OK\n"); | |
| else if (odd_col_cnt == 1 && odd_row_cnt == 1) | |
| printf("Change bit (%d,%d)\n", col_idx+1, row_idx+1); | |
| else | |
| printf("Corrupt\n"); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment