Submission #287333

#TimeUsernameProblemLanguageResultExecution timeMemory
287333Haunted_CppRectangles (IOI19_rect)C++17
0 / 100
5074 ms384 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; long long count_rectangles(vector<vector<int> > mat) { const int r = mat.size(); const int c = mat[0].size(); if (r <= 2) { return 0; } if (c <= 2) { return 0; } // Subtask #1 && Subtask #2 long long res = 0; for (int i = 1; i < c - 1; i++) { for (int j = i; j < c - 1; j++) { vector<int> valid_linha(r); for (int x = 1; x < r - 1; x++) { int mx = 0; for (int z = i; z <= j; z++) { mx = max(mx, mat[x][z]); } valid_linha[x] = (mx < mat[x][i - 1] && mx < mat[x][j + 1]); } vector<int> valid_up(r); vector<int> valid_down(r); for (int x = 1; x < r - 1; x++) { bool up = true, down = true; for (int z = i; z <= j; z++) { up &= (mat[x][z] < mat[x - 1][z]); down &= (mat[x][z] < mat[x + 1][z]); } valid_up[x] = up; valid_down[x] = down; } for (int x = 1; x < r - 1; x++) { if (!valid_up[x]) continue; if (!valid_linha[x]) break; for (int z = x; z < r - 1; z++) { if (!valid_down[z]) continue; if (!valid_linha[z]) break; ++res; } } } } 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...