-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path1359_B.cpp
More file actions
48 lines (42 loc) · 841 Bytes
/
Copy path1359_B.cpp
File metadata and controls
48 lines (42 loc) · 841 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
/* https://codeforces.com/contest/1359/problem/B*/
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<math.h>
#include<climits>
using namespace std;
#define pb pushback
#define tc testcase
#define mp make pair
#define x first
#define y second
const long long int MOD = 1e9+7;
const long long int INF = 1e9+5;
char a[105][1005];
int main() {
int t;
cin >> t;
while (t--) {
int n, m, x, y;
cin >> n >> m >> x >>y;
for (int i=0 ; i<n ; i++) {
for (int j=0 ; j<m ; j++) {
cin >>a[i][j];
}
}
int sol = 0;
for (int i=0 ; i<n ; i++) {
for (int j=0 ; j<m ; j++) {
if (j<m-1 && a[i][j] == '.' && a[i][j+1] == '.' && y<x*2) {
a[i][j] = a[i][j+1] = '*';
sol += y;
} else if (a[i][j] == '.') {
sol += x;
}
}
}
cout << sol << endl;
}
return 0;
}