#include #include #include #include #include #include #include #include #define ll long long using namespace std; // link : https://yukicoder.me/problems/no/2094 // category : grpha, symmetry int main() { int n,k,cnt=0; cin>>n>>k; for(int i=0;i<2*n;i++){ string s; cin>>s; for(int j=0;j<2*n;j++){ if(s[j]=='#') cnt++; } } int C[n*2][n*2]={}; vector Cline; for(int i=0;i Pline; for(int i=0;i csum(Cline.size()), psum(Pline.size()); partial_sum(Cline.begin(),Cline.end(),csum.begin()); partial_sum(Pline.begin(),Pline.end(),psum.begin()); ans = (cnt%2==0) ? max(csum[cnt-1],psum[cnt/2-1]+k) : csum[cnt-1]; cout<< ans; return 0; }