该题分值20具有一定难度
但是了解了该游戏机制,我们不难发现这就是一道涂颜色的题
我们可以想象一个n * m的地图,每次boos完成打击后会涂黑一行或者一列
若涂黑一行之后,未来每次再涂一列时会少涂一格(因为在涂一行时已经涂黑了)
使用判断数列st防止重复填图
反之亦然
请看代码
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
bool st[2][N];
int main()
{
int ans = 0;
int n, m, q;cin >> n >> m >> q;
ans = n * m;
while(q --)
{
int t, c; cin >> t >> c;
if(!st[t][c])
{
if(t == 0)
{
ans -= m;
n --;
}else{
ans -= n;
m --;
}
}
st[t][c] = true;
}
cout << ans;
return 0;
}