# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
701290 |
2023-02-20T18:29:01 Z |
Hanksburger |
Park (BOI16_park) |
C++17 |
|
261 ms |
33332 KB |
#include <bits/stdc++.h>
using namespace std;
vector<pair<double, pair<int, int> > > vec;
int x[2005], y[2005], r[2005], par[4005];
pair<pair<int, int>, int> a[100005];
bool ans[100005][5];
int p(int u)
{
return par[u]==u?u:(par[u]=p(par[u]));
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, w, h, ind=0;
cin >> n >> m >> w >> h;
for (int i=1; i<=n; i++)
{
cin >> x[i] >> y[i] >> r[i];
for (int 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 (int 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 (int i=1; i<=n+3; i++)
par[i]=i;
for (int 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++;
}
int 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 (int i=1; i<=m; i++)
{
for (int j=0; j<=3; j++)
if (ans[i][j])
cout << j+1;
cout << '\n';
}
}
Compilation message
park.cpp: In function 'int main()':
park.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | while (ind<vec.size() && vec[ind].first<a[i].first.first*2)
| ~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
261 ms |
33288 KB |
Output is correct |
2 |
Incorrect |
251 ms |
33332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
2636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
261 ms |
33288 KB |
Output is correct |
2 |
Incorrect |
251 ms |
33332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |