Submission #1030926

#TimeUsernameProblemLanguageResultExecution timeMemory
1030926ZicrusRectangles (IOI19_rect)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
#include "rect.h"
using namespace std;

typedef long long ll;

ll n, m;

ll count_rectangles(vector<vector<int>> a) {
    if (a.size() <= 2) return 0;
    n = a.size(); m = a[0].size();

    vector<vector<bool>> vst(n, vector<bool>(m));
    ll res = 0;
    for (int i = 1; i < n-1; i++) {
        for (int j = 1; j < m-1; j++) {
            if (a[i][j] || vst[i][j]) continue;
            
            ll ptrN = i, ptrM = j;
            while (!a[ptrN][ptrM]) ptrM++;
            ptrM--;
            while (!a[ptrN][ptrM]) ptrN++;
            ptrN--;

            bool poss = true;
            for (int x = i; x <= ptrN && poss; x++) {
                for (int y = j; y <= ptrM && poss; y++) {
                    vst[x][y] = true;
                    if (a[x][y]) poss = false;
                }
            }
            for (int x = i; x <= ptrN && poss; x++) {
                if (!a[x][j-1]) poss = false;
                if (!a[x][ptrM+1]) poss = false;
            }
            for (int y = j; y <= ptrM && poss; y++) {
                if (!a[i-1][y]) poss = false;
                if (!a[ptrN+1][y]) poss = false;
            }
            res += poss;
        }
    }
    return res;
}
#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...