思路简单,记得特判重复的以及要加上重复删除的。
#include<iostream>
using namespace std;
const int N=1e5+10;
int n,m,q;
int st0[N];
int st1[N];
int main(){
cin>>n>>m>>q;
int res=n*m;
int ch=0,cl=0;
while(q--){
int t,c;
cin>>t>>c;
if(t==0){
if(st0[c]!=0)continue;
ch++;
res-=m;
st0[c]++;
}else{
if(st1[c]!=0)continue;
cl++;
res-=n;
st1[c]++;
}
}
res+=cl*ch;//一开始这句话放在while里了,眼瞎了!
cout<<res;
}