Submission #1047714

# Submission time Handle Problem Language Result Execution time Memory
1047714 2024-08-07T15:17:32 Z vjudge1 Rectangles (IOI19_rect) C++17
0 / 100
78 ms 46248 KB
#include "rect.h"
#include <bits/stdc++.h>
#define inf ((int)1e9)
using namespace std;

long long count_rectangles(std::vector<std::vector<int> > a) {
	vector <vector<int> > next, cnt;
	// bi birlerde kendinden bir sonraki sıfırı tutuyoruz
	// bir de gene birlerde kendinden sonraki ardışık sıfır sayısını tutuyoruz
	int n = a.size(), m = a[0].size();
	next = cnt = vector <vector<int> > (n, vector<int>(m));
	for(int i = 0; i < n; i++) {
		int zero = m;
		for(int j = m - 1; j > 0; j--) {
			if(a[i][j]) {
				next[i][j] = zero;
			}
			else {
				zero = j;
			}
		}
		int before = 0;
		for(int j = 0; j < m; j++) {
			if(a[i][j]) {
				before = j;
			}
			else {
				cnt[i][before]++;
			}
		}
	}
	// column column gez
	// duvara çarpma edge casesi, 0 alan edge casesi
	long long ans = 0;
	for(int j = 1; j < m - 1; j++) {
		int val = -1, prevdist = 0;
		for(int i = 0; i < n; i++) {
			if(a[i][j]) {
				int dist = next[i][j] - j;
				if(prevdist >= val and dist >= val and val != inf and val > 0 and j + val != m) {
					ans++;
				}
				val = -1;
				prevdist = dist;
			}
			else {
				if(val == -1) {
					val = cnt[i][j - 1];
				}
				else if(val != cnt[i][j - 1]) val = inf;
			}
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 78 ms 46248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -