Submission #296735

#TimeUsernameProblemLanguageResultExecution timeMemory
296735Dremix10Rectangles (IOI19_rect)C++17
37 / 100
5043 ms28408 KiB
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 2e5+1;

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

    int i,j,ii,jj;

    ll ans = 0;

    for(i=1;i<n-1;i++)
        for(j=1;j<m-1;j++){
            int cols[m]={};
            bool rows[m];
            for(ii=j;ii<m-1;ii++)rows[ii] = true;

            for(ii=i;ii<n-1;ii++){
                bool flagCol = true;
                int maxi = 0;
                for(jj=j;jj<m-1;jj++){
                    if(i==4 && j==2){
                        pv(rows)
                        pv(cols)
                        p2(flagCol,maxi)
                    }
                    /// check validity
                    cols[jj] = max(cols[jj],a[ii][jj]);
                    if(cols[jj]>=a[i-1][jj] || cols[jj]>=a[ii+1][jj])
                        flagCol = false;
                    maxi = max(maxi,a[ii][jj]);
                    if(maxi>=a[ii][j-1] || maxi>=a[ii][jj+1])
                        rows[jj] = false;
                    if(flagCol && rows[jj]){
                        ans++;
                        ///p2(i,j)
                        ///p2(ii,jj)
                    }
                }

            }

        }

    return ans;
    /// g++ grader.cpp rect.cpp -Ddremix
}
#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...