CSES - Datatähti 2016 alku - Results
Submission details
Task:Tontti
Sender:retki5
Submission time:2015-10-01 22:04:25 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:45:9: warning: unused variable 'q' [-Wunused-variable]
     int q = 0, w = 0, e = 0, r = 0;
         ^
input/code.cpp:45:16: warning: unused variable 'w' [-Wunused-variable]
     int q = 0, w = 0, e = 0, r = 0;
                ^
input/code.cpp:45:23: warning: unused variable 'e' [-Wunused-variable]
     int q = 0, w = 0, e = 0, r = 0;
                       ^
input/code.cpp:45:30: warning: unused variable 'r' [-Wunused-variable]
     int q = 0, w = 0, e = 0, r = 0;
                              ^
input/code.cpp:74:10: error: expected '}' at end of input
  return 0;
          ^

Code

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
int main() {
	int y, x, vvv;
	std::cin >> y >> x >> vvv;
	char ** fr;
	int ** rows;
	int *** tr;
	int max = std::min(x, y);
	tr = new int**[max + 1];
	for (int i = 2; i < max + 1; i++) {
		tr[i] = new int*[y];
		for (int a = 0; a < y; a++) {
			tr[i][a] = new int[x];
		}
	}
	fr = new char*[y];
	rows = new int*[y];
	for (int i = 0; i < y; i++) {
		fr[i] = new char[x];
		rows[i] = new int[x];
		std::cin >> fr[i];
	}
	for (int i = 0; i < y; i++) {
		for (int a = 0; a < x; a++) {
			//tr[2][i][a] =1 ;
			if (i == 0 || a == 0) {
				if (fr[i][a] == '*') tr[2][i][a] = 1;
				else tr[2][i][a] = 0;
				continue;
			}
			int q = 0, w = 0, e = 0, r = 0;
			if (fr[i - 1][a - 1] == '*') q = 1;
			if (fr[i - 1][a] == '*') w = 1;
			if (fr[i][a - 1] == '*') e = 1;
			if (fr[i][a] == '*') r = 1;
			tr[2][i][a] = q + w + e + r;
		}
	}
	for (int s = 3; s <= max; s++) {
		for (int i = s - 1; i < y; i++) {
			for (int a = s - 1; a < x; a++) {
				int q = 0, w = 0, e = 0, r = 0;
				//std::cout << s << ", " << i << ", " << a << std::endl;
				//tr[s][i][a] = 0;
				if (fr[i][a] == '*') tr[s][i][a]++;
				tr[s][i][a] = tr[s - 1][i - 1][a - 1];
				for (int c = 1; c < s; c++) {
					if (fr[i][a - c] == '*') tr[s][i][a]++;
				}
				for (int c = 1; c < s; c++) {
					if (fr[i - c][a] == '*') tr[s][i][a]++;
				}
			}
		}
	}
	int ans = 0;
	for (int s = 2; s <= max; s++) {
		for (int i = 0; i < y; i++) {
			for (int a = 0; a < x; a++) {
				//std::cout << tr[s][i][a] << " ";
				if (tr[s][i][a] == vvv) ans++;
			}
			//std::cout << std::endl;
		}
	}
	std::cout << ans << "\n";
	int d = 3;
	while (d == 3) {
		std::cin >> d;
	}
	return 0;