Codeforces 1359B - New Theatre Square solution
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int m,n,x,y,i,j,r,mn,t;
- string s;
- cin>>t;
- while(t--)
- {
- r=0;
- cin>>m>>n>>x>>y;
- mn=min(2*x,y);
- for(i=0; i<m; i++)
- {
- cin>>s;
- for(j=0; j<n; j++)
- {
- if(s[j]=='.')
- {
- if(j+1<n&&s[j+1]=='.')
- {
- r+=mn;
- j++;
- }
- else
- r+=x;
- }
- }
- }
- cout<<r<<endl;
- }
- }
No comments