Submission #1153915

#TimeUsernameProblemLanguageResultExecution timeMemory
1153915dzuizzSelotejp (COCI20_selotejp)C++20
0 / 110
0 ms328 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int h,w; cin>>h>>w; bool a[h+1][w+1]; memset(a,0,sizeof a); bool b[h+1][w+1]; memset(b,0,sizeof b); for(int i=1;i<=h;++i) for(int j=1;j<=w;++j){ char c; cin>>c; a[i][j]=(c=='#'); b[i][j]=(c=='#'); } // Subtask 1 int ans=0; int ans1=0; for(int i=1;i<=h;++i){ int cnt=0; for(int j=1;j<=w;++j){ if(a[i][j]){ if(cnt) a[i][j-1]=0,a[i][j]=0; ++cnt; }else{ ans1+=(cnt>1); cnt=0; } } ans1+=(cnt>1); } for(int j=1;j<=w;++j){ bool p=1; for(int i=1;i<=h;++i){ if(a[i][j]){ if(p) ++ans1; p=0; }else{ p=1; } } } int ans2=0; for(int j=1;j<=w;++j){ int cnt=0; for(int i=1;i<=h;++i){ if(b[i][j]){ if(cnt) b[i-1][j]=0,b[i][j]=0; ++cnt; }else{ ans2+=(cnt>1); cnt=0; } } ans2+=(cnt>1); } for(int i=1;i<=h;++i){ bool p=1; for(int j=1;j<=w;++j){ if(b[i][j]){ if(p) ++ans2; p=0; }else{ p=1; } } } cout<<min(ans1,ans2)<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...