-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmario3.cpp
More file actions
60 lines (57 loc) · 1.42 KB
/
mario3.cpp
File metadata and controls
60 lines (57 loc) · 1.42 KB
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
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll coins = 0, ene = 0;
int main()
{
ll m, n, i, j;
cin >> m >> n;
string s;
vector<string>v(m);
vector<vector<ll>>v1(m, vector<ll>(n, 0));
for (i = 0; i < m; i++) {
cin >> v[i];
}
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++) {
if (i == 0) {
if (v[i][j] == 'C') {
coins++;
v1[i][j] = m - i - 1;
}
}
else {
if (v[i][j] == 'C') {
coins++;
ll a = m - i - 1;
v1[i][j] = min(v1[i - 1][j], -a);
}
else if (v[i][j] == 'H') {
if (v[i - 1][j] == 'H') {
v1[i][j] = v1[i - 1][j];
}
else {
v1[i][j] = m - i;
}
}
else if (v1[i - 1][j] < 0) {
v1[i][j] = v1[i - 1][j];
}
}
}
}
for (i = 0; i < n; i++) {
if (v1[m - 1][i] < 0) {
ll a = v1[m - 1][i];
ene += -a;
}
else {
ene += v1[m - 1][i];
}
//cout<<v1[m-1][i]<<" ";
}//cout<<"\n";
// cout<<ene<<"\n";
ene = 2 * ene;
cout << coins << " " << ene;
return 0;
}