Submission #428289

#TimeUsernameProblemLanguageResultExecution timeMemory
428289MOUF_MAHMALATRectangles (IOI19_rect)C++14
0 / 100
5099 ms71832 KiB
#include "rect.h"
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll ans,r[2509][2509][2],c[2509][2509][2],x,y;
long long count_rectangles(vector<vector<int> > v)
{
    for(ll i=1; i<v.size()-1; i++)
        for(ll j=1; j<v[i].size()-1; j++)
        {
            if(v[i][j]<v[i-1][j])
                r[i][j][0]=1;
            if(v[i][j]<v[i+1][j])
                r[i][j][1]=1;
            if(v[i][j]<v[i][j-1])
                c[i][j][0]=1;
            if(v[i][j]<v[i][j+1])
                c[i][j][1]=1;
            r[i][j][0]+=r[i][j-1][0];
            r[i][j][1]+=r[i][j-1][1];
            c[i][j][0]+=c[i-1][j][0];
            c[i][j][1]+=c[i-1][j][1];
        }
    for(ll i=1; i<v.size()-1; i++)
        for(ll j=1; j<v[i].size()-1; j++)
            for(ll o=i; o<v.size()-1; o++)
                for(ll p=j; p<v[i].size()-1;p++)
                {
                  if(c[o][j][0]-c[i-1][j][0]<o-i+1)
                    continue;
                  if(c[o][p][1]-c[i-1][p][1]<o-i+1)
                    continue;
                  if(r[i][p][0]-r[i][j-1][0]<p-j+1)
                    continue;
                  if(r[o][p][1]-r[o][j-1][1]<p-j+1)
                    continue;
                  ans++;
                }
        return ans;
}

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:8:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(ll i=1; i<v.size()-1; i++)
      |                 ~^~~~~~~~~~~
rect.cpp:9:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |         for(ll j=1; j<v[i].size()-1; j++)
      |                     ~^~~~~~~~~~~~~~
rect.cpp:24:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(ll i=1; i<v.size()-1; i++)
      |                 ~^~~~~~~~~~~
rect.cpp:25:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(ll j=1; j<v[i].size()-1; j++)
      |                     ~^~~~~~~~~~~~~~
rect.cpp:26:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             for(ll o=i; o<v.size()-1; o++)
      |                         ~^~~~~~~~~~~
rect.cpp:27:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |                 for(ll p=j; p<v[i].size()-1;p++)
      |                             ~^~~~~~~~~~~~~~
rect.cpp:24:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |     for(ll i=1; i<v.size()-1; i++)
      |     ^~~
rect.cpp:39:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   39 |         return ans;
      |         ^~~~~~
#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...