Submission #200948

# Submission time Handle Problem Language Result Execution time Memory
200948 2020-02-08T18:44:20 Z Lawliet Rectangles (IOI19_rect) C++17
13 / 100
322 ms 237820 KB
#include <bits/stdc++.h>
#include "rect.h"

using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

const int MAXN = 3000;
const int INF = 1000000010;

int n, m;

int v[MAXN][MAXN];
int sv[MAXN][MAXN];

int qtdDown[MAXN][MAXN][2];
int qtdRight[MAXN][MAXN][2];

int sum(int x1, int y1, int x2, int y2)
{
	int ans = sv[x2][y2] + sv[x1 - 1][y1 - 1];
	ans -= sv[x2][y1 - 1] + sv[x1 - 1][y2];

	return ans;
}

long long count_rectangles(vector< vector<int> > a) //Grids pequenos
{
	n = a.size();
	m = a[0].size();

	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; j < m ; j++)
			v[i + 1][j + 1] = a[i][j];

	for(int i = 1 ; i <= n ; i++)
		for(int j = 1 ; j <= m ; j++)
			sv[i][j] = sv[i - 1][j] + sv[i][j - 1] - sv[i - 1][j - 1] + v[i][j];

	for(int i = n ; i > 0 ; i--)
	{
		for(int j = m ; j > 0 ; j--)
		{
			int val = v[i][j];
		
			qtdDown[i][j][val] = qtdDown[i + 1][j][val] + 1;
			qtdRight[i][j][val] = qtdRight[i][j + 1][val] + 1;
		}
	}

	lli ans = 0;

	for(int i = 2 ; i < n ; i++)
	{
		for(int j = 2 ; j < m ; j++)
		{
			if( v[i][j] == 1 ) continue;

			int x2 = i + qtdDown[i][j][0] - 1;
			int y2 = j + qtdRight[i][j][0] - 1;

			if( sum( i , j , x2 , y2 ) != 0 ) continue;

			if( qtdDown[i][j - 1][1] < qtdDown[i][j][0] ) continue;
			if( qtdRight[i - 1][j][1] < qtdRight[i][j][0] ) continue;

			if( qtdDown[i][y2 + 1][1] < qtdDown[i][j][0] ) continue;
			if( qtdRight[x2 + 1][j][1] < qtdRight[i][j][0] ) continue;

			ans++;
		}
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 28280 KB Output is correct
2 Correct 24 ms 27260 KB Output is correct
3 Correct 6 ms 608 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 23 ms 27128 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 144 ms 106488 KB Output is correct
3 Correct 314 ms 236556 KB Output is correct
4 Correct 322 ms 237768 KB Output is correct
5 Correct 302 ms 237820 KB Output is correct
6 Correct 129 ms 117496 KB Output is correct
7 Correct 254 ms 228476 KB Output is correct
8 Correct 261 ms 237736 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 888 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -