이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
swap(w, h);
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";
}
}
컴파일 시 표준 에러 (stderr) 메시지
park.cpp:14:35: warning: always_inline function might not be inlinable [-Wattributes]
__attribute__((always_inline)) ll c0(ll a, ll b) {
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |