You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
826 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
LL n; //棋盘长、宽
int K; //注意这里要使用LL使用int会有部分测试点WA
// 原因是后面的去重返回的是LL如果这里有int,应该是会自动降为int导致出问题。
//行数组与列数组
int r[N], c[N];
int main() {
//加快读取速度
ios::sync_with_stdio(false);
cin.tie();
//棋盘的长宽和车的个数
cin >> n >> k;
//读入车的位置
for (int i = 1; i <= k; i++) cin >> r[i] >> c[i];
//排序
sort(r + 1, r + k + 1);
sort(c + 1, c + k + 1);
//去重
LL x = unique(r + 1, r + k + 1) - r - 1;
LL y = unique(c + 1, c + k + 1) - c - 1;
printf("%lld", n * n - (n - x) * (n - y));
return 0;
}