省选测试10

这个难度…… 我无了

A 鱼死网破

题目大意 : 直角坐标系x轴上方有n个点,k道与x轴平行的墙,m个询问点,问从每个点可以打到上面的几个点,强制在线

  • 边界一定是在墙的两端,所以就把墙的一段与所有点连线,按极角排序,查询的时候二分就好了

Code

Show Code
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
const int N = 1e5 + 5;

int read(int x = 0, int f = 1, char c = getchar()) {
    for (; c < '0' || c > '9'; c = getchar())
        if (c == '-') f = -1;
    for (; c >='0' && c <='9'; c = getchar())
        x = x * 10 + c - '0';
    return x * f;
}

struct Node {
    int x, y;
}a[N], l[55], r[55];

bool operator < (const Node &a, const Node &b) {
    return 1ll * a.x * b.y - 1ll * a.y * b.x > 0;
}

Node operator - (const Node &a, const Node &b) {
    return (Node) {a.x - b.x, a.y - b.y};
}

struct Line {
    Node x; int id, op;
    bool operator < (const Line &b) const {
        return x < b.x;
    }
}b[105];

int n, m, q, op, ans;
vector<Node> A[55], D[55];

int main() {
    n = read(); m = read(); q = read(); op = read();
    for (int i = 1; i <= n; ++i) 
        a[i] = (Node) {read(), read()};
    for (int i = 1; i <= m; ++i) 
        l[i].x = read(), r[i].x = read(), l[i].y = r[i].y = read();
    for (int i = 1; i <= n; ++i) {
        int tot = 0, sum = 0;
        for (int j = 1; j <= m; ++j) {
            if (l[j].y >= a[i].y) continue;
            b[++tot] = (Line) {a[i] - l[j], j, 1};
            b[++tot] = (Line) {a[i] - r[j], j, -1};
        }
        sort(b + 1, b + tot + 1);
        for (int j = 1; j <= tot; ++j) {
            sum += b[j].op;
            if (sum == 1 && b[j].op == 1) A[b[j].id].push_back(b[j].x);
            else if (!sum && b[j].op == -1) D[b[j].id].push_back(b[j].x);
        }
    }
    for (int i = 1; i <= m; ++i) {
        sort(A[i].begin(), A[i].end());
        sort(D[i].begin(), D[i].end());
    }
    while (q--) {
        Node x = (Node) {read() ^ ans, read() ^ ans}; ans = 0;
        for (int i = 1; i <= m; ++i) {
            ans += upper_bound(A[i].begin(), A[i].end(), l[i] - x) - A[i].begin();
            ans -= lower_bound(D[i].begin(), D[i].end(), r[i] - x) - D[i].begin();
        }
        printf("%d\n", ans = n - ans); ans *= op;
    }
    return 0;
}

B 漏网之鱼 (Unaccepted)

题目大意 :

  • 咕咕

Code

Show Code

C 浑水摸鱼 (Unaccepted)

题目大意 :

  • 咕咕

Code

Show Code
posted @ 2021-02-09 13:34  Shawk  阅读(44)  评论(0编辑  收藏  举报