Submission #1290948

#TimeUsernameProblemLanguageResultExecution timeMemory
1290948gustavo_dRectangles (IOI19_rect)C++20
0 / 100
1 ms340 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; #define sz(v) (int)(v).size() typedef long long ll; const int MAXN = 2500; ll sum(ll x) { return x * (x+1) / 2; } ll count_rectangles(vector<vector<int>> mat) { ios_base::sync_with_stdio(false); cin.tie(NULL); int n = sz(mat); int m = sz(mat[0]); ll ans = 0; for (int i1=1; i1<n-1; i1++) { for (int j1=1; j1<m-1; j1++) { if (mat[i1-1][j1] != 0 or mat[i1][j1-1] != 0 or mat[i1][j1] != 1) continue; // cerr << i1 << ' ' << j1 << '\n'; // cerr << mat[i1][j1] int i2=i1, j2=j1; bool can = true; for (int j=j1+1; j<m-1; j++) { if (mat[i1][j] == 0) break; j2++; if (mat[i1-1][j] == 1) { can = false; break; } } if (!can) break; for (int i=i1+1; i<n-1; i++) { if (mat[i][j1] == 0) { for (int j=j1-1; j<=j2+1; j++) { if (mat[i][j] == 1) { can = false; break; } } break; } if (mat[i][j1-1] == 1 or mat[i][j2+1] == 1) { can = false; break; } for (int j=j1; j<=j2; j++) { if (mat[i][j] == 0) { can = false; break; } } if (!can) break; i2++; } if (!can) break; ans += sum(j2-j1+1) * sum(i2-i1+1); } } 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...