Submission #825958

#TimeUsernameProblemLanguageResultExecution timeMemory
825958vjudge1Dijamant (COCI22_dijamant)C++14
70 / 70
211 ms234616 KiB
#include <bits/stdc++.h> #define el '\n' #define fi first #define sc second #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; using ll=long long; using ull=unsigned long long; using ld=long double; const int mod=1e9+7; const int N=2e3+11; bool a[N][N]; int dx[4] = {1,-1,0,0}; int dy[4] = {0,0,1,-1}; int n, m; bool inbound(int x,int y) { return (x>=0 && y>=0); } int ma1, ma2, mi1, mi2; int cnt = 0; void dfs(int x,int y) { a[x][y]=1; cnt++; ma1 = max(ma1,x+y); mi1 = min(mi1,x+y); ma2 = max(ma2,x-y); mi2 = min(mi2,x-y); for(int i=0; i<4; i++) if(inbound(x+dx[i], y+dy[i])) if(a[x+dx[i]][y+dy[i]]==0) dfs(x+dx[i],y+dy[i]); } void sol() { cin >> m >> n; for(int i=0; i<2005; i++) { a[i][n+4]=1; a[m+4][i]=1; } for(int i=1; i<=m; i++) { for(int j=1; j<=n; j++) { char x; cin >> x; if(x=='#') a[i][j]=1; } } int ans = 0; for(int i=1; i<=m; i++) { for(int j=1; j<=n; j++) { if(!a[i][j]) { ma1=ma2=INT_MIN; mi1=mi2=INT_MAX; cnt=0; dfs(i,j); if(ma1-mi1!=ma2-mi2 || (ma1-mi1)%2) continue; int l = (ma1-mi1)/2+1; int ss = (2*l*l)-(2*l)+1; if(cnt == ss) ans++; } } } cout << ans; } signed main() { // freopen("task.INP", "r", stdin); // freopen("task.OUT", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin >> t; while(t--) { sol(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...