[Algo Beat Contest 004 B] Buying Lotteries 官方题解
tanghaocheng · · 个人记录
简单的模拟题。
只需要记录 L 字符的同时,依次判断
注意:
- 当有
t_{i,j,1} 为L时要注意每一个格子不要获得超过1 次。 - 由于
t_{i,j,2} 的最大值可以达到10^9 ,所以要使用\text{long long} 。
#include<bits/stdc++.h>
#define int long long
#define ll unsigned long long
#define off ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N=2005;
string x,a[N][N];
int n,m,b[N][N];
signed main()
{
off;
cin>>n>>m;
cin>>x;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
}
}
bool All=0;
int ans=0,sum=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>b[i][j];
if(a[i][j]=="L")
{
All=1;
}
else if(a[i][j]==x)
{
ans+=b[i][j];
}
sum+=b[i][j];
}
}
if(All)
{
cout<<sum;
}
else
{
cout<<ans;
}
return 0;
}