CSES - Datatähti 2024 alku - Results
Submission details
Task:Uolevin kalansaalis
Sender:Laserr
Submission time:2023-10-30 15:14:43 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:5:19: error: declaration does not declare anything [-fpermissive]
    5 | typedef long long int;
      |                   ^~~

Code

#include <iostream>

using namespace std;

typedef long long int;

int n, m, f, u, z;

int v[502][502];
int d[502][502][502];

int main() {
	cin >> n >> m >> f;
	u = -1e9; z = 0;
	for (int i = 0; i < f; i++) {
		int a, b; char c;
		cin >> a >> b >> c;
		if (c == 'H') {
			v[a][b]--;
			z++;
		}
		else {
			v[a][b] += 10;
			z -= 10;
		}
		
	}
	for (int k = m; k >= 1; k--) {
		for (int i = 1; i <= n; i++) {
			int s = 0;
			for (int j = 1; j <= m; j++) {
				s += v[i][j];
				if (j < k) continue;
				if (i % 2 == 1) d[k][i][j] = max(s, s + d[k + 1][i - 1][j]); //kato tätä
				else d[k][i][j] = max(s, s + d[k + 1][i - 1][j + 1]);

				s -= v[i][j-k+1];
			}
		}
	}

	for (int k = 1; k <= m; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (k == 1) u = max(u, d[k][i][j]);
				d[k][i][j] = 0;
			}
		}
	}
	for (int k = m; k >= 1; k--) {
		for (int i = n; i >= 1; i--) {
			int s = 0;
			for (int j = 1; j <= m; j++) {
				s += v[i][j];
				if (j < k) continue;
				if (i % 2 == 1) d[k][i][j] = max(s, s + d[k + 1][i + 1][j]);
				else d[k][i][j] = max(s, s + d[k + 1][i + 1][j + 1]);

				s -= v[i][j - k + 1];
			}
		}
	}

	for (int k = 1; k <= m; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (k == 1) u = max(u, d[k][i][j]);
				d[k][i][j] = 0;
			}
		}
	}



	cout << z + u;
}