problem nowcoder
思路
把点按照奇偶分为4类,一个三角形的面积是整数当且仅当构成它的三个点中至少2个是同一类的,用总共的三角形减去这类即可。
一开始并没有发现这个性质。
// Decline is inevitable,
// Romance will last forever.
#include <bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define ll long long
#define LL long long
#define ld long double
#define endl '\n'
#define RE0 return 0
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define int long long
const int maxn = 1e3 + 10;
const int P = 1e9 + 7; //998244353
const int INF = 0x3f3f3f3f;
int n, k;
int f[2][2];
void solve() {
cin >> n;
for(int i = 1;i <= n; i++) {
int x, y;
cin >> x >> y;
x &= 1;
y &= 1;
f[x][y]++;
}
int cnt = 0;
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 2; j++) {
int t = f[i][j];
cnt += t * (t-1)*(t-2)/6;
for(int k = 0; k < 2; k++)
for(int l = 0; l < 2; l++) {
if(i == k && j == l) continue;
int tt = f[k][l];
cnt = cnt + t * (tt*(tt-1)/2);
}
}
}
cnt = (n-1)*(n-2)*n/6-cnt;
cout << cnt << endl;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// int T; scanf("%d", &T); while(T--)
// freopen("1channel00.txt","r",stdin);
// freopen("2.txt","w",stdout);
// int T; cin >> T; while(T--)
solve();
RE0;
}