码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-05-29 19:26:11      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:else   name   col   ORC   test   ace   注意   oid   clu   

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

题解

因为 $1 \times 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 << "\n";
}

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

 

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

标签:else   name   col   ORC   test   ace   注意   oid   clu   

原文地址:https://www.cnblogs.com/Kanoon/p/12989137.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!