Problem 330A - Cakeminator (思维)

330A. Cakeminator

https://codeforces.com/problemset/problem/330/A

题意很容易理解:给定一块蛋糕区域,但蛋糕上有几个不能吃的草莓,大胃王一次能吃一整列、行

求在不吃到草莓的情况下能迟到的最多的蛋糕数

//cpp
#include<bits/stdc++.h>
using namespace std;
int main() {
   //freopen("in.txt", "r", stdin);
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n, m; set<int>a, b; char c;
   cin >> n >> m;
   for (int i = 1; i <= n; ++i)
   	for (int j = 1; j <= m; ++j) { cin >> c; if (c == 'S') a.insert(i), b.insert(j); }
   cout << m * n - a.size() * b.size();
}
#python
S=input
n,m=map(int,S().split())
g=[S() for i in range(n)]
print(n*m-len([1 for i in g if i.count('S')])*len([1 for i in zip(*g) if i.count('S')]))
posted @ 2020-09-23 19:45  RioTian  阅读(141)  评论(0编辑  收藏  举报