Submission #423898

#TimeUsernameProblemLanguageResultExecution timeMemory
423898schseRectangles (IOI19_rect)C++17
37 / 100
5038 ms28356 KiB
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif

bool check(int r1, int r2, int c1, int c2, std::vector<std::vector<int>> &a)
{
	for (int e = c1 + 1; e < c2; e++)
	{
		for (int i = r1 + 1; i < r2; i++)
		{
			if (a[i][e] >= a[r1][e] || a[i][e] >= a[r2][e])
				return false;
			if (a[i][e] >= a[i][c1] || a[i][e] >= a[i][c2])
				return false;
		}
	}
	return true;
}

long long count_rectangles(std::vector<std::vector<int>> a)
{
	long long count = 0;
	for (int r1 = 0; r1 < a.size(); r1++)
	{
		for (int c1 = 0; c1 < a[0].size(); c1++)
		{
			for (int r2 = r1 + 2; r2 < a.size(); r2++)
			{
				for (int c2 = c1 + 2; c2 < a[0].size(); c2++)
				{
					if (check(r1, r2, c1, c2, a))
						count++;
				}
			}
		}
	}

	return count;
}

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (int r1 = 0; r1 < a.size(); r1++)
      |                   ~~~^~~~~~~~~~
rect.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for (int c1 = 0; c1 < a[0].size(); c1++)
      |                    ~~~^~~~~~~~~~~~~
rect.cpp:30:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |    for (int r2 = r1 + 2; r2 < a.size(); r2++)
      |                          ~~~^~~~~~~~~~
rect.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int c2 = c1 + 2; c2 < a[0].size(); c2++)
      |                           ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...