#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
struct node
{
string s;
int x;
string op;
} a[maxn];
bool visr[maxn], visc[maxn];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int i, j, n, m, q;
long long res = 0;
cin >> n >> m >> q;
for (i = 1; i <= q; i++)
{
cin >> a[i].s >> a[i].x >> a[i].op;
}
for (i = q; i >= 1; i--)//每盏灯的状态只与对它的最后一次操作有关,所以倒序操作
{
if (a[i].s == "row")
{
if (visr[a[i].x])
continue;
visr[a[i].x] = 1;
if (a[i].op == "on")
res += m;
n--;
}
else
{
if (visc[a[i].x])
continue;
visc[a[i].x] = 1;
if (a[i].op == "on")
res += n;
m--;
}
}
cout << res;
return 0;
}
q次开关灯操作(每次对一行或一列操作),问最后几盏灯亮
最新推荐文章于 2024-04-30 20:06:58 发布