QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#650459 | #4778. Tracking RFIDs | SGColin# | TL | 0ms | 3724kb | C++20 | 3.6kb | 2024-10-18 15:17:09 | 2024-10-18 15:17:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
inline ll rd() {
ll 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 ll 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;
}
};
inline void work() {
int s = rd(), r = rd(), w = rd(), p = rd();
map<pii, bool> fl;
rep(i, 1, s) {
int x = rd(), y = rd();
fl[{x, y}] = true;
}
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() <= 1ll * (r - cnt) * (r - cnt));
};
rep(i, 1, p) {
int x = rd(), y = rd();
Point pt{x, y};
vector<pii> ans;
rep(dx, -r, r) {
rep(dy, 0, r) {
if (1ll * dx * dx + 1ll * dy * dy > 1ll * r * r) break;
if (!fl[{x + dx, y + dy}]) continue;
//printf("check (%d, %d), (%d, %d)\n", x, y, x + dx, y + dy);
if (check({Point{x + dx, y + dy}, pt})) ans.eb(x + dx, y + dy);
}
per(dy, -1, -r) {
if (1ll * dx * dx + 1ll * dy * dy > 1ll * r * r) break;
if (!fl[{x + dx, y + dy}]) continue;
//printf("check (%d, %d), (%d, %d)\n", x, y, x + dx, y + dy);
if (check({Point{x + dx, y + dy}, pt})) ans.eb(x + dx, y + dy);
}
}
sort(all(ans));
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: 0ms
memory: 3724kb
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: -100
Time Limit Exceeded
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...