#include 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; }