QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#121582 | #4778. Tracking RFIDs | momoyuu | WA | 2ms | 4572kb | C++17 | 2.6kb | 2023-07-08 14:57:26 | 2023-07-08 14:57:28 |
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;
}
int ch(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;
return na * mb == nb * ma;
}
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(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: 4572kb
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 1 (11,5) 1 (11,5) 0 1 (11,5)
result:
wrong answer 4th lines differ - expected: '0', found: '1 (11,5)'