#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pli pair<ll, int>
#define fi first
#define se second
const int mxN=2e3, mxM=1e5;
int n, m;
ll w, h, x[mxN], y[mxN], r[mxN], ans[4][4], dist[mxN];
bool vis[mxN];
__attribute__((always_inline)) ll c0(ll a, ll b) {
ll lb=1, rb=1e9;
while(lb<=rb) {
ll mb=(lb+rb)/2;
if((mb+b)*(mb+b)<=a)
lb=mb+1;
else
rb=mb-1;
}
return rb;
}
ll c1(int a) {
ll b=LLONG_MAX;
memset(dist, 0x3F, 8*n);
for(int i=0; i<n; ++i) {
dist[i]=min(x[i]-r[i], dist[i]);
dist[i]=min(h-y[i]-r[i], dist[i]);
if(a==0)
dist[i]=min(w-x[i]-r[i], dist[i]);
}
memset(vis, 0, n);
for(int it=0; it<n; ++it) {
int mi=-1;
for(int i=0; i<n; ++i)
if(!vis[i]&&(mi==-1||dist[i]<dist[mi]))
mi=i;
vis[mi]=1;
for(int i=0; i<n; ++i)
if(!vis[i])
dist[i]=min(max(c0((x[i]-x[mi])*(x[i]-x[mi])+(y[i]-y[mi])*(y[i]-y[mi]), r[i]+r[mi]), dist[mi]), dist[i]);
b=min(max(y[mi]-r[mi], dist[mi]), b);
if(a==1)
b=min(max(w-x[mi]-r[mi], dist[mi]), b);
}
return b;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> w >> h;
for(int i=0; i<n; ++i)
cin >> x[i] >> y[i] >> r[i];
for(int i=0, j=0, k=1; i<4; ++i, j^=2) {
ans[i][i]=LLONG_MAX;
ans[j][j^k]=ans[j^k][j]=c1(0);
for(int l=0; l<n; ++l)
y[l]=h-y[l];
if(i==1) {
ans[0][2]=ans[2][0]=c1(1);
for(int l=0; l<n; ++l)
swap(x[l], y[l]);
k^=2;
} else if(i==0)
ans[1][3]=ans[3][1]=c1(1);
}
// for(int i=0; i<4; ++i)
// for(int j=i; j<4; ++j)
// cout << i+1 << " " << j+1 << " " << ans[i][j] << endl;
while(m--) {
int ri, ei;
cin >> ri >> ei, --ei;
for(int i=0; i<4; ++i)
if(2*ri<=ans[ei][i])
cout << i+1;
cout << "\n";
}
}
Compilation message
park.cpp:14:35: warning: always_inline function might not be inlinable [-Wattributes]
__attribute__((always_inline)) ll c0(ll a, ll b) {
^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2462 ms |
496 KB |
Output is correct |
2 |
Incorrect |
2475 ms |
684 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
68 ms |
2084 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2462 ms |
496 KB |
Output is correct |
2 |
Incorrect |
2475 ms |
684 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |