QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#650599#4778. Tracking RFIDsSGColin#AC ✓63ms7064kbC++203.6kb2024-10-18 15:47:022024-10-18 15:47:03

Judging History

你现在查看的是最新测评结果

  • [2024-10-18 15:47:03]
  • 评测
  • 测评结果:AC
  • 用时:63ms
  • 内存:7064kb
  • [2024-10-18 15:47:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

inline int rd() {
    int x = 0;
    bool f = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) f |= (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    return f ? -x : x;
}

#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

typedef int T;
#define let const auto
#define lett const T
#define letp const Point
#define lets const Segment
#define letl const Line

const T eps=0;

struct Point {
    T x,y;
    Point (T x=0,T y=0):x(x),y(y){}
    Point operator + (letp &p) const {return {x+p.x,y+p.y};}
    Point operator - (letp &p) const {return {x-p.x,y-p.y};}
    Point operator * (lett &d) const {return {x*d,y*d};}
    Point operator / (lett &d) const {return {x/d,y/d};}
    Point operator - () const {return {-x,-y};}

    T operator | (letp &p) const {return x*p.x+y*p.y;}
    T operator ^ (letp &p) const {return x*p.y-y*p.x;}

    bool operator == (letp &p) const {return x==p.x&&y==p.y;}
    bool operator != (letp &p) const {return ! operator == (p);}
    bool operator < (letp &p) const {return x==p.x?y<p.y:x<p.x;}
    bool operator > (letp &p) const {return !(*this<p||*this==p);}

    int ori(letp &p) const {T t = (*this)^p; return (t > eps) - (t < -eps);}

    T norm() const {return x*x+y*y;}
    T dis_sqrt(letp &p) const {return ((*this)-p).norm();}
};

struct Line {
    Point p,v;
    int ori(letp &a) const {return v.ori(a-p);}
};

struct Segment {
    Point a,b;
    T norm() const {return (a - b).norm();}
    int is_on(letp &p) const {
        if(p==a||p==b) return -1;
        return (p-a).ori(p-b)==0&&((p-a)|(p-b))<-eps;
    }

    int is_inter(lets &s) const {
        if(is_on(s.a)||is_on(s.b)||s.is_on(a)||s.is_on(b)) return -1;
        letl &l{a,b-a}, ls{s.a,s.b-s.a};
        return l.ori(s.a)*l.ori(s.b)==-1&&ls.ori(a)*ls.ori(b)==-1;
    }
};

vector<int> circ[20007];

inline void work() {
    int s = rd(), r = rd(), w = rd(), p = rd();
    vector<int> lim;
    rep(i, 0, 20000) circ[i].clear();
    rep(i, 0, r) {
        int j = r;
        while (i * i + j * j > r * r) --j;
        lim.eb(j);
    }
    rep(i, 1, s) {
        int x = rd(), y = rd();
        circ[x + 10000].eb(y);
    }
    rep(i, 0, 20000) sort(all(circ[i]));
    vector<Segment> wall;
    rep(i, 1, w) {
        int x = rd(), y = rd();
        Point bg{x, y};
        x = rd(); y = rd();
        Point ed{x, y};
        wall.eb(bg, ed);
    }
    auto check = [&](Segment s) {
        int cnt = 0;
        for (auto segw : wall) cnt += abs(segw.is_inter(s));
        return (r >= cnt && s.norm() <= (r - cnt) * (r - cnt));
    };
    rep(i, 1, p) {
        int x = rd(), y = rd();
        Point pt{x, y};
        vector<pii> ans;
        rep(dx, -r, r) {
            int tx = x + dx;
            if (tx < -10000) continue;
            if (tx > 10000) continue;
            int id = tx + 10000;
            int maxy = lim[abs(dx)];
            auto it = lower_bound(all(circ[id]), y - maxy);
            while (it != circ[id].end() && (*it) <= y + maxy) {
                int ty = *it;
                if (check({Point{tx, ty}, pt})) ans.eb(tx, ty);
                ++it;
            }
        }
        printf("%d", (int)ans.size());
        for (auto [x, y] : ans) printf(" (%d,%d)", x, y);
        puts("");
    }
}

int main() {
    per(t, rd(), 1) work();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3756kb

input:

1
4 3 4 7
0 0
-1 3
2 3
11 5
-4 -1 5 -1
3 5 6 1
11 4 11 3
12 5 12 8
1 1
0 -2
4 4
11 2
13 5
13 7
14 5

output:

3 (-1,3) (0,0) (2,3)
1 (0,0)
0
0
1 (11,5)
0
0

result:

ok 7 lines

Test #2:

score: 0
Accepted
time: 63ms
memory: 7064kb

input:

62
4 3 4 7
0 0
-1 3
2 3
11 5
-4 -1 5 -1
3 5 6 1
11 4 11 3
12 5 12 8
1 1
0 -2
4 4
11 2
13 5
13 7
14 5
3 5 0 5
0 0
5 0
8 4
0 5
2 3
2 4
3 4
5 0
3 1 0 15
-10 -42
-9 -42
-8 -42
-11 -41
-11 -42
-11 -43
-10 -41
-10 -42
-10 -43
-9 -41
-9 -42
-9 -43
-8 -41
-8 -42
-8 -43
-7 -41
-7 -42
-7 -43
5 3 0 7
0 0
-1 -3...

output:

3 (-1,3) (0,0) (2,3)
1 (0,0)
0
0
1 (11,5)
0
0
1 (0,0)
2 (0,0) (5,0)
2 (0,0) (5,0)
3 (0,0) (5,0) (8,4)
3 (0,0) (5,0) (8,4)
0
1 (-10,-42)
0
1 (-10,-42)
2 (-10,-42) (-9,-42)
1 (-10,-42)
1 (-9,-42)
3 (-10,-42) (-9,-42) (-8,-42)
1 (-9,-42)
1 (-8,-42)
2 (-9,-42) (-8,-42)
1 (-8,-42)
0
1 (-8,-42)
0
3 (-1,-3...

result:

ok 31312 lines