CSES - Datatähti 2016 alku - Results
Submission details
Task:Tontti
Sender:6502
Submission time:2015-09-29 13:20:43 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:23:13: error: invalid operands of types 'int [n][m]' and 'int' to binary 'operator^'
     sz += a^k;
             ^

Code

#include <iostream>
#include <math.h>

using namespace std;

#define ull unsigned long long

int main() {
	cin.sync_with_stdio(false);
	int i, j, n, m, k, x, s, sz, q, w, b;
	cin >> n >> m >> k;
	char input[n][m];
	int a[n][m];
	int f[n][m];
	for (i = 0; i < n; i++)
		cin >> input[i];
	sz = (int)ceil(sqrt((double)k));
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			a[i][j] = !(input[i][j]=='.');
			f[i][j] = 0;
			if(sz==1 && k<2)
				sz += a^k;
		}
	x = b = 0;
	int c = max(sz,2);
	for (s = c; s <= min(n,m); s++) {
		for (i = s - 1; i < n; i++)
			for (j = s - 1; j < m; j++) {
				int t = f[i][j];
				if (s == c) {
					for (q = i - s + 1; q <= i; q++) {
						for (w = j - s + 1; w <= j; w++) {
							t += a[q][w];
						}
					}
					f[i][j] = t;
				} else {
					for (q = 0; q < s - 1; q++) {
						t += a[i-s+1][j-q];
						t += a[i-q][j-s+1];
					}
					t += a[i-s+1][j-s+1];
					f[i][j] = t;
				}
				b = 0;
				if (t == k) x++;
			}
	}
	cout << x << "\n";
	return 0;
}