2018 AICCSA Programming Contest
思路:如果存在大于0的交面积的话, 那么肯定能找到一条水平的直线 和 一条垂直的直线,
使得水平直线的左右两边点的个数相等且为n, 垂直直线的左右两边点的个数相等且为n
也就是说不能有点在这两条线上, 否则交面积为0
然后左上角的点和右下角的点配对, 左下角的点和右上角的点配对
代码:
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair #define pb push_back #define ls rt<<1, l, m #define rs rt<<1|1, m+1, r #define ULL unsigned LL #define pll pair<LL, LL> #define pli pair<LL, int> #define pii pair<int, int> #define piii pair<pii, int> #define mem(a, b) memset(a, b, sizeof(a)) #define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout); //head const int N = 2e5 + 5, M = 1e5 + 5; const int MOD = 1e9 + 7; pii a[N]; int fac[M]; bool cmp(pii a, pii b) { return a.se < b.se; } void init() { fac[0] = 1; for (int i = 1; i < M; i++) fac[i] = (1LL * fac[i-1] * i) % MOD; } int main() { int T, n; init(); scanf("%d", &T); while(T--) { scanf("%d", &n); for (int i = 1; i <= 2*n; i++) scanf("%d %d", &a[i].fi, &a[i].se); bool f = false; sort(a+1, a+1+2*n); double x = 0, y = 0; if(a[n].fi != a[n+1].fi) x = (a[n].fi + a[n+1].fi) / 2.0; else f = true; sort(a+1, a+1+2*n, cmp); if(a[n].se != a[n+1].se) y = (a[n].se + a[n+1].se) / 2.0; else f = true; int cnt = 0; for (int i = 1; i <= 2*n; i++) if(a[i].fi > x && a[i].se > y) cnt++; if(f) printf("0\n"); else printf("%lld\n", (1LL * fac[cnt] * fac[n-cnt]) % MOD); } return 0; }