注: 某些行or列可能重复删除,所以需要记录那些已经被删除过了。
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, q;
cin >> n >> m >> q;//行和列数
int ssize = n * m;
set<int> rows, cols;
while (q--) {
int op, t;
cin >> op >> t;
if (op == 0) {//删除行
if (rows.find(t) != rows.end()) {
continue;
}
ssize =ssize - (m - cols.size());
rows.insert(t);
}
else {//删除列
if (cols.find(t) != cols.end()) {
continue;
}
ssize = ssize - (n - rows.size());
cols.insert(t);
}
}
cout << ssize << endl;
return 0;
}
标签:rows,士姆,删除,int,机工,087,cols,ssize,op
From: https://www.cnblogs.com/chengyiyuki/p/18106074