This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<pair<double, pair<ll, ll> > > vec;
ll x[2005], y[2005], r[2005], par[4005];
pair<pair<ll, ll>, ll> a[100005];
bool ans[100005][5];
ll p(ll u)
{
return par[u]==u?u:(par[u]=p(par[u]));
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n, m, w, h, ind=0;
cin >> n >> m >> w >> h;
for (ll i=1; i<=n; i++)
{
cin >> x[i] >> y[i] >> r[i];
for (ll j=1; j<i; j++)
vec.push_back({sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j], {i, j}});
vec.push_back({x[i]-r[i], {i, n*2}});
vec.push_back({y[i]-r[i], {i, n*2+1}});
vec.push_back({w-x[i]-r[i], {i, n*2+2}});
vec.push_back({h-y[i]-r[i], {i, n*2+3}});
}
for (ll i=1; i<=m; i++)
{
cin >> a[i].first.first >> a[i].first.second;
a[i].second=i;
}
sort(vec.begin(), vec.end());
sort(a+1, a+m+1);
n*=2;
for (ll i=1; i<=n+3; i++)
par[i]=i;
for (ll i=1; i<=m; i++)
{
while (ind<vec.size() && vec[ind].first<a[i].first.first*2)
{
par[p(vec[ind].second.first)]=p(vec[ind].second.second);
ind++;
}
ll b=a[i].first.second-1, c=a[i].second;
ans[c][b]=1;
ans[c][(b+3)%4]=(p(n+b)!=p(n+(b+1)%4) && p(n+b)!=p(n+(b+2)%4) && p(n+b)!=p(n+(b+3)%4));
ans[c][(b+1)%4]=(p(n+(b+1)%4)!=p(n+b) && p(n+(b+1)%4)!=p(n+(b+2)%4) && p(n+(b+1)%4)!=p(n+(b+3)%4));
ans[c][(b+2)%4]=(p(n+(b+1)%4)!=p(n+b) && p(n+(b+1)%4)!=p(n+(b+3)%4) && p(n+(b+2)%4)!=p(n+b) && p(n+(b+2)%4)!=p(n+(b+3)%4));
}
for (ll i=1; i<=m; i++)
{
for (ll j=0; j<=3; j++)
if (ans[i][j])
cout << j+1;
cout << '\n';
}
}
Compilation message (stderr)
park.cpp: In function 'int main()':
park.cpp:41:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | while (ind<vec.size() && vec[ind].first<a[i].first.first*2)
| ~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |