QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#121584 | #4778. Tracking RFIDs | momoyuu | WA | 2ms | 4560kb | C++17 | 2.7kb | 2023-07-08 15:00:16 | 2023-07-08 15:00:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll ccw(pair<ll,ll> a,pair<ll,ll> b,pair<ll,ll> c){
ll na = b.first - a.first;
ll nb = b.second - a.second;
ll ma = c.first - a.first;
ll mb = c.second - a.second;
if(na*mb-nb*ma>0) return 1;
if(na*mb-nb*ma<0) return -1;
if(na*ma+nb*mb<0) return 2;
if(na*na+nb*nb<ma*ma+mb*mb) return -2;
return 0;
}
bool ch(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3,ll x4,ll y4){
ll tc = (x1-x2)*(y3-y1) + (y1-y2)*(x1-x3);
ll td = (x1-x2)*(y4-y1) + (y1-y2)*(x1-x4);
return tc*td<0;
}
void solve(){
ll s,r,w,p;
cin>>s>>r>>w>>p;
ll mask = 10040 + 100;
vector<set<ll>> d(30000);
for(int i = 0;i<s;i++){
ll x,y;
cin>>x>>y;
d[x+mask].insert(y);
}
vector<ll> bx(w),by(w),ex(w),ey(w);
for(int i = 0;i<w;i++) cin>>bx[i]>>by[i]>>ex[i]>>ey[i];
for(int i = 0;i<p;i++){
set<pair<ll,ll>> ans;
ll px,py;
cin>>px>>py;
for(ll xx = px - r;xx <= px + r;xx++){
ll nx = xx + mask;
auto itr = d[nx].lower_bound(py-r);
while(itr!=d[nx].end()){
pair<ll,ll> now = make_pair(xx,*itr);
ll dx = px - now.first;
ll dy = py - now.second;
if(dx*dx+dy*dy>r*r) break;
if(px==xx&&py==*itr){
ans.insert(now);
itr++;
continue;
}
int cnt = 0;
for(int j = 0;j<w;j++){
if(ch(px,py,now.first,now.second,bx[j],by[j],ex[j],ey[j])) cnt++;
//if(ch(make_pair(px,py),make_pair(bx[j],by[j]),now)) continue;
//if(ch(make_pair(px,py),make_pair(ex[j],ey[j]),now)) continue;
//if(ch(make_pair(px,py),make_pair(bx[j],by[j]),make_pair(ex[j],ey[j]))&&ch(now,make_pair(bx[j],by[j]),make_pair(ex[j],ey[j]))) continue;
//if(ccw(make_pair(px,py),now,make_pair(bx[j],by[j]))*ccw(make_pair(px,py),now,make_pair(ex[j],ey[j]))<0&&ccw(make_pair(bx[j],by[j]),make_pair(ex[j],ey[j]),make_pair(px,py))*ccw(make_pair(bx[j],by[j]),make_pair(ex[j],ey[j]),now)<0) cnt++;
}
//cout<<cnt<<" "<<xx<<" "<<*itr<<endl;
if(r-cnt>=0&&dx*dx+dy*dy<(r-cnt)*(r-cnt)) ans.insert(now);
itr++;
}
}
cout<<ans.size();
for(auto&itr:ans) cout<<" ("<<itr.first<<","<<itr.second<<")";
cout<<endl;
}
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 4560kb
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:
0 0 0 0 1 (11,5) 0 0
result:
wrong answer 1st lines differ - expected: '3 (-1,3) (0,0) (2,3)', found: '0'