제출 #520709

#제출 시각아이디문제언어결과실행 시간메모리
520709peti1234Rectangles (IOI19_rect)C++17
25 / 100
5072 ms22760 KiB
#include <bits/stdc++.h>

using namespace std;
bool jo(int a, int b, int c, int d, vector<vector<int>> &r) {
    // (a, b) a bal felso, (c, d) a jobb also sarok
    for (int sor=a; sor<=c; sor++) {
        int maxi=0;
        for (int oszlop=b; oszlop<=d; oszlop++) {
            maxi=max(maxi, r[sor][oszlop]);
        }
        if (r[sor][b-1]<=maxi || r[sor][d+1]<=maxi) return 0;
    }
    for (int oszlop=b; oszlop<=d; oszlop++) {
        int maxi=0;
        for (int sor=a; sor<=c; sor++) {
            maxi=max(maxi, r[sor][oszlop]);
        }
        if (r[a-1][oszlop]<=maxi || r[c+1][oszlop]<=maxi) return 0;
    }
    //cout << "jo " << a << " " << b << " " << c << " " << d << "\n";
    return 1;
}
long long count_rectangles(vector<vector<int>> r) {
    // 1, 2, 5-re mukodik
    int n=r.size(), m=r[0].size(), db=0;
    for (int i=1; i<n-1; i++) {
        for (int j=i; j<n-1; j++) {
            for (int k=1; k<m-1; k++) {
                for (int l=k; l<m-1; l++) {
                    if (jo(i, k, j, l, r)) {
                        db++;
                    }
                }
            }
        }
    }

    return db;

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