HNACM(八)F-Distribution

传送门

这道题可以算是最水的一道题了,直接读入n个坐标,在读入每个交点的时候,判断横纵坐标都比这个交点的横纵坐标大和都比这个小的点的个数就行了

#include <bits/stdc++.h> 
#define N 110
#define ll long long
#define MAX 111111
using namespace std;
struct node{
    int x, y;
}p[N];
int main(){
//#ifndef ONLINE_JUDGE
//  freopen("1.txt", "r", stdin);
//#endif 
    int i, j, n, m;
    while(~scanf("%d%d", &n, &m)){
        for (i = 0; i < n; i++){
            scanf("%d%d", &p[i].x, &p[i].y);
        }
        int ans = 0, a, b;
        for (i = 0; i < m; i++){
            scanf("%d%d", &a, &b);
            ans = 0;
            for (j = 0; j < n; j++){
                if ((a < p[j].x && b < p[j].y) || (a > p[j].x && b > p[j].y)){
                    ans++;
                }
            }
            printf("%d\n", 2*ans-n);
        }
    }
    return 0;
}

你可能感兴趣的:(HNACM(八)F-Distribution)