Submission #618577

#TimeUsernameProblemLanguageResultExecution timeMemory
618577chirathnirodhaRectangles (IOI19_rect)C++17
Compilation error
0 ms0 KiB
#include "rect.h"
#include<bits/stdc++.h>
using namespace std;

long long count_rectangles(vector<vector<int> > a) {
	int n=a.size();
	int m=a[0].size();
	ll ans=0;

	int invalrow[n][m][m];
	for(int i=0;i<m;i++)for(int j=0;j<m;j++)invalrow[0][i][j]=0;

	for(int i=0;i<n;i++){
		int colmax[m];memset(colmax,-1,sizeof(colmax));
		bool colvalid[m];memset(colvalid,false,sizeof(colvalid));
		for(int j=i+2;j<n;j++){
			for(int k=0;k<m;k++){
				colmax[k]=max(colmax[k],a[j-1][k]);
				if(colmax[k]>=a[i][k] || colmax[k]>=a[j][k])colvalid[k]=false;
				else colvalid[k]=true;
			}
			for(int k=0;k<m;k++){
				int rowmax[n];memset(rowmax,-1,sizeof(rowmax));
				for(int l=k+2;l<n;l++){
					if(colvalid[l-1]==false)break;
					if(invalrow[j-2][k][l]-invalrow[i][k][l]>0)continue;
					bool ok=true;
					for(int p=i+1;p<=j-1;p++){
						rowmax[p]=max(rowmax[p],a[p][l-1]);
						if(rowmax[p]>=a[p][k] || rowmax[p]>=a[p][l]){ok=false;break;}
					}
					invalrow[j-1][k][l]=invalrow[j-2][k][l];
					if(ok)ans++;
					else invalrow[j-1][k][l]++;
				}
			}
		}
	}
	return ans;
}

Compilation message (stderr)

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:8:2: error: 'll' was not declared in this scope
    8 |  ll ans=0;
      |  ^~
rect.cpp:33:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |      if(ok)ans++;
      |            ^~~
      |            abs
rect.cpp:39:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |  return ans;
      |         ^~~
      |         abs