-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathB - New Theatre Square.cpp
More file actions
50 lines (41 loc) · 863 Bytes
/
B - New Theatre Square.cpp
File metadata and controls
50 lines (41 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
ll T;
cin>>T;
while(T--)
{
int n,m,x,y;
cin>>n>>m>>x>>y;
int i,j;
char ch[n][m];
int single=0,couple=0;
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
cin >> ch[i][j];
if(ch[i][j]=='.')
single++;
}
}
i=0;
while(i<n )
{
for(int j=0;j<m-1;j++){
if(ch[i][j]=='.' && ch[i][j+1]=='.')
{
j++;
couple++;
}
}
i++;
}
int res1 = single*x;
int res2 = couple*y + (single-(couple*2))*x;
cout<<min(res1,res2)<<endl;
}
return 0;
}