Submission #1474774


Source Code Expand

#include <stdio.h>
#include <stdlib.h>

int max(int a, int b){
	if(a > b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int H, W, C, i, j, k, l, ans = 0;
	scanf("%d%d", &H, &W);
	int **black = (int **)malloc(sizeof(int *) * (H + 1));
	int **white = (int **)malloc(sizeof(int *) * (H + 1));
	for(i = 0; i <= H; i++){
		black[i] = (int *)malloc(sizeof(int) * (W + 1));
		white[i] = (int *)malloc(sizeof(int) * (W + 1));
		for(j = 0; j <= W; j++){
			black[i][j] = 0;
			white[i][j] = 0;
		}
	}
	for(i = 1; i <= H; i++){
		for(j = 1; j <= W; j++){
			scanf("%d", &C);
			if((i + j) % 2 == 0){
				black[i][j] = C;
			}
			else{
				white[i][j] = C;
			}
		}
	}
	for(i = 1; i <= H; i++){
		for(j = 1; j <= W; j++){
			black[i][j] += black[i - 1][j] + black[i][j - 1] - black[i - 1][j - 1];
			white[i][j] += white[i - 1][j] + white[i][j - 1] - white[i - 1][j - 1];
		}
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			for(k = i + 1; k <= H; k++){
				for(l = j + 1; l <= W; l++){
					if(black[k][l] - black[i][l] - black[k][j] + black[i][j]
						 == 
						 white[k][l] - white[i][l] - white[k][j] + white[i][j]){
						ans = max(ans, (k - i) * (l - j));
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task B - チョコレート
User abc050
Language C (GCC 5.4.1)
Score 100
Code Size 1285 Byte
Status AC
Exec Time 57 ms
Memory 256 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:15:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &H, &W);
  ^
./Main.c:28:4: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &C);
    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 5
AC × 25
Set Name Test Cases
Sample subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask0_sample-04.txt, subtask0_sample-05.txt
All subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask0_sample-04.txt, subtask0_sample-05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Case Name Status Exec Time Memory
subtask0_sample-01.txt AC 1 ms 128 KB
subtask0_sample-02.txt AC 1 ms 128 KB
subtask0_sample-03.txt AC 1 ms 128 KB
subtask0_sample-04.txt AC 1 ms 128 KB
subtask0_sample-05.txt AC 1 ms 128 KB
subtask1_01.txt AC 1 ms 128 KB
subtask1_02.txt AC 1 ms 128 KB
subtask1_03.txt AC 1 ms 128 KB
subtask1_04.txt AC 1 ms 128 KB
subtask1_05.txt AC 1 ms 128 KB
subtask1_06.txt AC 1 ms 128 KB
subtask1_07.txt AC 1 ms 128 KB
subtask1_08.txt AC 1 ms 128 KB
subtask1_09.txt AC 55 ms 256 KB
subtask1_10.txt AC 9 ms 256 KB
subtask1_11.txt AC 44 ms 256 KB
subtask1_12.txt AC 44 ms 256 KB
subtask1_13.txt AC 44 ms 256 KB
subtask1_14.txt AC 56 ms 256 KB
subtask1_15.txt AC 57 ms 256 KB
subtask1_16.txt AC 42 ms 256 KB
subtask1_17.txt AC 45 ms 256 KB
subtask1_18.txt AC 1 ms 128 KB
subtask1_19.txt AC 1 ms 128 KB
subtask1_20.txt AC 52 ms 256 KB