Submission #520706

#TimeUsernameProblemLanguageResultExecution timeMemory
520706peti1234Rectangles (IOI19_rect)C++17
0 / 100
2576 ms352 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) {
    int n=r.size(), m=r[0].size(), db=0;
    for (int i=1; i<n; i++) {
        for (int j=i; j<n-1; j++) {
            for (int k=1; k<m; k++) {
                for (int l=k; l<m; 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...