Submission #730642

#TimeUsernameProblemLanguageResultExecution timeMemory
730642danikoynovRectangles (IOI19_rect)C++14
8 / 100
58 ms51596 KiB
#include "rect.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;


const int maxn = 31;

int n, m;
int h[maxn][maxn];
long long count_rectangles(vector<vector<int> > a)
{
    n = a.size();
    m = a[0].size();
    for (int i = 0; i < n; i ++)
        for (int j = 0; j < m; j ++)
            h[i][j] = a[i][j];

    /**cout << "-----------" << endl;
    for (int i = 0; i < n; i ++, cout << endl)
        for (int j = 0; j < m; j ++)
        cout << h[i][j] << " ";
    cout << "-----------" << endl;*/
    int ans = 0;
    for (int i = 1; i < n - 1; i ++)
        for (int j = 1; j < m - 1; j ++)
            for (int x = i; x < n - 1; x ++)
                for (int y = j; y < m - 1; y ++)
                {
                    bool tf = true;
                    for (int dx = 0; dx <= x - i && tf; dx ++)
                        for (int dy = 0; dy <= y - j && tf; dy ++)
                        {
                            int cx = i + dx, cy = j + dy;

                            if (h[cx][cy] >= h[cx][j - 1] || h[cx][cy] >= h[cx][y + 1])
                                tf = false;
                            if (i == 1 && j == 1 && x == 2 && y == 1)
                            {
                                //cout << dx << " : " << dy << " : " << tf << endl;
                                ///cout << h[cx][cy] << " -- " << h[cx][j - 1] << " -- " << h[cx][y + 1] << endl;
                            }
                            if (h[cx][cy] >= h[i - 1][cy] || h[cx][cy] >= h[x + 1][cy])
                                tf = false;

                        }
                    if (tf)
                    {
                        //cout << i << " " << j << " " << x << " " << y << endl;
                        ans ++;
                    }
                }

    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...