Codeforces Round #703 (Div. 2) B. Eastern Exhibition 思维

Codeforces Round #703 (Div. 2) B. Eastern Exhibition

在这里插入图片描述

input

6
3
0 0
2 0
1 2
4
1 0
0 2
2 3
3 1
4
0 0
0 1
1 0
1 1
2
0 0
1 1
2
0 0
2 0
2
0 0
0 0

output

1
4
4
4
3
1

solution

分 别 找 x , y 方 向 上 的 中 位 数 分别找x,y方向上的中位数 xy

code

//Siberian Squirrel
//#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<set>
#include<string>

#define ACM_LOCAL

using namespace std;
typedef long long ll;

const double PI = acos(-1);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 3e3 + 10;
const int UP = 1e2 + 10;

int a[N], b[N];

inline ll solve(int n, ll res = 0) {
    
    
    for(int i = 1; i <= n; ++ i) {
    
    
        scanf("%d%d", &a[i], &b[i]);
    }
    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);
    ll x = a[n / 2 + 1] - a[n / 2] + 1;
    ll y = b[n / 2 + 1] - b[n / 2] + 1;
    if(n & 1) return 1;
    else return x * y;
}

int main() {
    
    
#ifdef ACM_LOCAL
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
#endif
    int o = 1, n, m, k;
    scanf("%d", &o);
    while(o --) {
    
    
        scanf("%d", &n);
        printf("%lld\n", solve(n));
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_46173805/article/details/113886537