Submission #1059876

#TimeUsernameProblemLanguageResultExecution timeMemory
1059876UnforgettableplRectangles (IOI19_rect)C++17
13 / 100
479 ms523844 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; long long count_rectangles(vector<vector<int>> a){ int n = a.size(); int m = a[0].size(); long long ans = 0; vector visited = a; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(visited[i][j])continue; int minx = n; int maxx = 0; int miny = m; int maxy = 0; int area = 0; function<void(int,int)> dfs = [&](int x,int y) { if(visited[x][y])return; visited[x][y]=true; area++; minx=min(minx,x); maxx=max(maxx,x); miny=min(miny,y); maxy=max(maxy,y); if(x!=0)dfs(x-1,y); if(y!=0)dfs(x,y-1); if(x!=n-1)dfs(x+1,y); if(y!=m-1)dfs(x,y+1); }; dfs(i,j); if(minx==0)continue; if(miny==0)continue; if(maxx==n-1)continue; if(maxy==m-1)continue; if((maxx-minx+1)*(maxy-miny+1)==area)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...