Educational Codeforces Round 88 (Rated for Div. 2) B. New Theatre Square

Posted kanoon

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 88 (Rated for Div. 2) B. New Theatre Square相关的知识,希望对你有一定的参考价值。

题目链接:https://codeforces.com/contest/1359/problem/B

题解

因为 $1 imes 2$ 的瓷砖不能旋转,所以每次逐行考虑即可,注意 $y$ 取 $min(2x, y)$ 。

代码

#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n, m, x, y; cin >> n >> m >> x >> y;
    y = min(2 * x, y);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        for (int j = 0; j < m; j++) {
            if (s[j] == .) {
                if (j + 1 < m and s[j + 1] == .)
                    ans += y, ++j;
                else 
                    ans += x;
            }
        }
    }
    cout << ans << "
";
}

int main() {
    int t; cin >> t;
    while (t--) solve();
}

 

以上是关于Educational Codeforces Round 88 (Rated for Div. 2) B. New Theatre Square的主要内容,如果未能解决你的问题,请参考以下文章

Educational Codeforces Round 7 A

Educational Codeforces Round 7

Educational Codeforces Round 90

Educational Codeforces Round 33

Codeforces Educational Codeforces Round 54 题解

Educational Codeforces Round 27