Submission #159699

# Submission time Handle Problem Language Result Execution time Memory
159699 2019-10-24T01:49:22 Z socho Strah (COCI18_strah) C++14
44 / 110
1000 ms 32760 KB
#include "bits/stdc++.h"
using namespace std;

int main() {
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	
	int grid[n][m];
	
	for (int i=0; i<n; i++) {
		string s;
		cin >> s;
		for (int j=0; j<m; j++) {
			grid[i][j] = (s[j] == '.');
		}
	}
	
	int pf[n+1][m+1];
	for (int i=0; i<n+1; i++) pf[i][0] = 0;
	for (int i=0; i<m+1; i++) pf[0][i] = 0;
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			pf[i+1][j+1] = pf[i+1][j] + pf[i][j+1] - pf[i][j] + grid[i][j];
		}
	}
	
	int sm = 0;
	
	for (int i=1; i<=n; i++) {
		bool ye = true;
		for (int j=i; j<=n && ye; j++) {
			int ot = sm;
			for (int a=1; a<=m; a++) {
				bool cg = true;
				for (int b=a; b<=m && cg; b++) {
					int area = (j - i + 1) * (b - a + 1);
					int qr = pf[j][b] - pf[j][a-1] - pf[i-1][b] + pf[i-1][a-1];
					if (area == qr) sm += area; 
					else cg = false;
				}
			}
			if (ot == sm) ye = false;
		}
	}
	
	cout << sm << endl;
	
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1016 KB Output is correct
2 Correct 35 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1080 KB Output is correct
2 Correct 34 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 1016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 115 ms 8440 KB Output is correct
2 Execution timed out 1087 ms 19064 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 276 ms 19704 KB Output is correct
2 Execution timed out 1082 ms 32760 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 12500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2424 KB Output is correct
2 Execution timed out 1077 ms 23288 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 31608 KB Time limit exceeded
2 Halted 0 ms 0 KB -