Codeforces 364 Div2 B. Cells Not Under Attack
問題概要
省略。
解法
行、列、別々に、何個ずつ埋まっているかを見て、それを使い、計算すればいい。行、列が埋まるごとに、小さくなっていく。
ミス
なし
コード
#include <iostream> #include <cstdio> #include <set> typedef long long ll; using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int main(void){ ll n, m; cin >> n >> m; set<ll> x, y; rep(i, m){ ll tx, ty; cin >> tx >> ty; x.insert(tx); y.insert(ty); //行、列が減ると小さくなる printf("%I64d ", (ll)((n - x.size()) * (n - y.size()))); } printf("\n"); return 0; }