# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
987804 |
2024-05-23T15:38:32 Z |
alexdd |
Park (BOI16_park) |
C++17 |
|
505 ms |
1976 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 2e9;
int n,m,h,w;
pair<int,int> t[2005];
int tr[2005];
bool visited[2005];
bool atinge(pair<int,int> p, int r, int margine)
{
if(margine==1)
{
return (h-p.second)<r;
}
else if(margine==2)
{
return (w-p.first)<r;
}
else if(margine==3)
{
return p.second<r;
}
else
{
return p.first<r;
}
}
int calc_dist(pair<int,int> x, pair<int,int> y)
{
return (x.first-y.first)*(x.first-y.first) + (x.second-y.second)*(x.second-y.second);
}
void dfs(int x, int r)
{
visited[x]=1;
for(int i=1;i<=n;i++)
if(!visited[i] && calc_dist(t[x],t[i]) < (tr[x]+tr[i]+2*r)*(tr[x]+tr[i]+2*r))
dfs(i,r);
}
bool verif(int from, int to, int r)
{
for(int i=1;i<=n;i++)
visited[i]=0;
for(int i=1;i<=n;i++)
if(!visited[i] && atinge(t[i],2*r+tr[i],from))
dfs(i,r);
for(int i=1;i<=n;i++)
if(visited[i] && atinge(t[i],2*r+tr[i],to))
return 1;
return 0;
}
int lim[5][5],rez[5][5];
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m>>w>>h;
for(int i=1;i<=n;i++)
{
cin>>t[i].first>>t[i].second>>tr[i];
}
for(int from=1;from<=4;from++)
{
for(int to=from+1;to<=4;to++)
{
if(verif(from,to,0))
{
lim[from][to]=-1;
continue;
}
int st,dr,ans;
st=0;
dr=INF;
ans=0;
while(st<=dr)
{
int mij=(st+dr)/2;
if(!verif(from,to,mij))
{
ans=mij;
st=mij+1;
}
else
dr=mij-1;
}
lim[from][to] = lim[to][from] = ans;
//cout<<from<<" "<<to<<" "<<lim[from][to]<<" lim\n";
}
}
rez[1][2] = rez[2][1] = min({lim[1][3],lim[4][3],lim[2][3]});
rez[1][3] = rez[3][1] = min({lim[3][4],lim[1][3],lim[1][2],lim[2][4]});
rez[1][4] = rez[4][1] = min({lim[2][4],lim[4][1],lim[4][3]});
rez[2][3] = rez[3][2] = min({lim[2][4],lim[3][2],lim[1][2]});
rez[2][4] = rez[4][2] = min({lim[1][3],lim[2][4],lim[1][4],lim[2][3]});
rez[3][4] = rez[4][3] = min({lim[1][3],lim[4][1],lim[1][2]});
int qe,qr;
while(m--)
{
cin>>qr>>qe;
for(int i=1;i<=4;i++)
if(i==qe || rez[qe][i]>=qr)
cout<<i;
cout<<"\n";
}
return 0;
}
/**
5 3
16 11
11 8 1
6 10 1
7 3 2
10 4 1
15 5 1
1 1
2 2
2 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
462 ms |
604 KB |
Output is correct |
2 |
Correct |
505 ms |
688 KB |
Output is correct |
3 |
Correct |
376 ms |
688 KB |
Output is correct |
4 |
Correct |
486 ms |
692 KB |
Output is correct |
5 |
Correct |
434 ms |
848 KB |
Output is correct |
6 |
Correct |
355 ms |
692 KB |
Output is correct |
7 |
Correct |
308 ms |
684 KB |
Output is correct |
8 |
Correct |
258 ms |
472 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1364 KB |
Output is correct |
2 |
Correct |
34 ms |
1608 KB |
Output is correct |
3 |
Correct |
29 ms |
1364 KB |
Output is correct |
4 |
Correct |
29 ms |
1476 KB |
Output is correct |
5 |
Correct |
29 ms |
1508 KB |
Output is correct |
6 |
Correct |
29 ms |
1392 KB |
Output is correct |
7 |
Correct |
23 ms |
1880 KB |
Output is correct |
8 |
Correct |
29 ms |
1688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
462 ms |
604 KB |
Output is correct |
2 |
Correct |
505 ms |
688 KB |
Output is correct |
3 |
Correct |
376 ms |
688 KB |
Output is correct |
4 |
Correct |
486 ms |
692 KB |
Output is correct |
5 |
Correct |
434 ms |
848 KB |
Output is correct |
6 |
Correct |
355 ms |
692 KB |
Output is correct |
7 |
Correct |
308 ms |
684 KB |
Output is correct |
8 |
Correct |
258 ms |
472 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
456 KB |
Output is correct |
11 |
Correct |
31 ms |
1364 KB |
Output is correct |
12 |
Correct |
34 ms |
1608 KB |
Output is correct |
13 |
Correct |
29 ms |
1364 KB |
Output is correct |
14 |
Correct |
29 ms |
1476 KB |
Output is correct |
15 |
Correct |
29 ms |
1508 KB |
Output is correct |
16 |
Correct |
29 ms |
1392 KB |
Output is correct |
17 |
Correct |
23 ms |
1880 KB |
Output is correct |
18 |
Correct |
29 ms |
1688 KB |
Output is correct |
19 |
Correct |
424 ms |
1872 KB |
Output is correct |
20 |
Correct |
392 ms |
1920 KB |
Output is correct |
21 |
Correct |
401 ms |
1824 KB |
Output is correct |
22 |
Correct |
451 ms |
1976 KB |
Output is correct |
23 |
Correct |
433 ms |
1900 KB |
Output is correct |
24 |
Correct |
306 ms |
1900 KB |
Output is correct |