Submission #1047719

#TimeUsernameProblemLanguageResultExecution timeMemory
1047719efedmrlrRectangles (IOI19_rect)C++17
0 / 100
517 ms1048576 KiB
#include "rect.h" // #pragma GCC optimize("O3,Ofast,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define lli long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int i = 0; (i) < (n); (i)++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const double EPS = 0.00001; const int INF = 1e9+500; const int N = 3e5+5; const int ALPH = 26; const int LGN = 25; constexpr int MOD = 1e9+7; int n, m; vector<vector<int> > gr, vis; vector<array<int, 2> > dir(4); int x11, x22, y11, y22, cnt; void dfs(int x, int y) { if(vis[x][y] || gr[x][y]) return; cnt++; x11 = min(x11, x); x22 = max(x22, x); y11 = min(y11, y); y22 = min(y22, y); for(auto c : dir) { dfs(x + c[0], y + c[1]); } } long long count_rectangles(std::vector<std::vector<int> > a) { dir.resize(4); dir[0] = {0, 1}; dir[1] = {0, -1}; dir[2] = {1, 0}; dir[3] = {-1, 0}; n = (int)a.size(); m = (int)a[0].size(); gr = a; vis.assign(n, vector<int>(m, 0)); int ans = 0; REP(i, n) { REP(j, m) { x11 = INF; x22 = 0; y11 = INF; y22 = 0; cnt = 0; dfs(i, j); if(cnt == 0) continue; if(x11 == 0 || y11 == 0 || x22 == n - 1 || y22 == n - 1) continue; if((x22 - x11 + 1) * (y22 - y11 + 1) != cnt) continue; ans++; } } 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...