Submission #152998

# Submission time Handle Problem Language Result Execution time Memory
152998 2019-09-11T07:33:44 Z tinjyu Rectangles (IOI19_rect) C++14
0 / 100
536 ms 67548 KB
#include "rect.h"
#include <iostream>
using namespace std;
long long int sx,sy,n,m,ans=0,map[1005][1005];
int find(int x,int y)
{
	if(x==n-1 || y==m-1)return 0;
	int can1=1,can2=1;
	for(int i=sx;i<=x;i++)
	{
		long long int ma=0;
		for(int j=sy;j<=y;j++)
		{
			ma=max(map[i][j],ma);
		}
		if(ma>=map[i][sy-1] || ma>=map[i][y+1])
		{
			can1=0;
			break;
		}
	}
	for(int j=sy;j<=y;j++)
	{
		long long int ma=0;
		for(int i=sx;i<=x;i++)
		{
			ma=max(map[i][j],ma);
		}
		if(ma>=map[sx-1][j] || ma>=map[x+1][j])
		{
			can2=0;
			break;
		}
	}
	if(can1==1 && can2==1)
	{
		ans++;
	}
	if(can1==1)find(x+1,y);
	if(can2==1)find(x,y+1);
}
long long count_rectangles(std::vector<std::vector<int> > a) {
	n=a.size();
	m=a[0].size();
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)map[i][j]=a[i][j];
	}
	for(int i=1;i<n-1;i++)
	{
		for(int j=1;j<m-1;j++)
		{
			sx=i,sy=j;
			find(i,j);
		}
	}
	return ans;
}

Compilation message

rect.cpp: In function 'int find(int, int)':
rect.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 536 ms 516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 94 ms 67548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -