Submission #130442

# Submission time Handle Problem Language Result Execution time Memory
130442 2019-07-15T08:11:36 Z 임유진(#3151) Dominance (CEOI08_dominance) C++14
20 / 100
36 ms 24568 KB
#include <stdio.h>
#include <algorithm>

using namespace std;

#define MAXH 2005
#define MAXN 3005

char C[MAXN];
int A[MAXN], B[MAXN], R[MAXN];
int dp[MAXH][MAXH];

int main() {
	int H, W, N;

	scanf("%d%d%d", &H, &W, &N);
	for(int i = 0; i < N; i++) scanf("\n%c%d%d%d", C + i, A + i, B + i, R + i);

	//for(int i = 0; i < N; i++) printf("[%c]", C[i]);

	for(int i = 0; i < N; i++) {
		int z = C[i] == 'W' ? 1 : -1;
		for(int j = max(0, B[i] - R[i]); j < B[i]; j++) {
			dp[j][max(0, A[i] + B[i] - R[i] - j)] += z;
			dp[j][min(W, A[i] - B[i] + R[i] + j + 1)] -= z;
		}
		for(int j = B[i]; j < min(H, B[i] + R[i] + 1); j++) {
			dp[j][max(0, A[i] - B[i] - R[i] + j)] += z;
			dp[j][min(W, A[i] + B[i] + R[i] - j + 1)] -= z;
		}
	}

	int ansp = 0, ansm = 0;
	for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) {
		if(j > 0) dp[i][j] += dp[i][j - 1];
		if(dp[i][j] > 0) ansp++;
		else if(dp[i][j] < 0) ansm++;
	}

	printf("%d %d", ansp, ansm);
	return 0;
}

Compilation message

dominance.cpp: In function 'int main()':
dominance.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &H, &W, &N);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
dominance.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < N; i++) scanf("\n%c%d%d%d", C + i, A + i, B + i, R + i);
                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Runtime error 21 ms 13560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 36 ms 24568 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Correct 3 ms 1784 KB Output is correct
15 Runtime error 33 ms 23672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Correct 13 ms 8184 KB Output is correct
17 Correct 12 ms 8184 KB Output is correct
18 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Incorrect 3 ms 1272 KB Output isn't correct
20 Incorrect 20 ms 15480 KB Output isn't correct