///GAGO_O
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define for0(i,n) for(int i=0;i<=(int)n;i++)
#define forn(i,n) for(int i=n;i>=1;i--)
#define fo(i,x,y) for(int i=x;i<=(int)y;i++)
#define fr(i,x,y) for(int i=x;i>=(int)y;i--)
#define pb push_back
#define mp make_pair
#define LL long long
const LL Mod=1000*1000*1000+7;
int n,m;
int w,h;
LL x[20002],y[2002],r[2002];
int jan[2002][2002];
int ka[2002][2002];
int used[2002];
int MY[10][10];
int X;
int K;
LL hat(LL x1,LL y1,LL r1,LL x2,LL y2,LL r2)
{
LL dist=(LL)(x1-x2)*(LL)(x1-x2)+(LL)(y1-y2)*(LL)(y1-y2);
LL R=(LL)(r1+r2)*(LL)(r1+r2);
if(R>dist)
return 1;
return 0;
}
void dfs(int v)
{
jan[X][v]=1;
jan[v][X]=1;
used[v]=1;
for1(i,n)
{
if(used[i]==0 && hat(x[v],y[v],r[v]+K,x[i],y[i],r[i]+K)==1)
dfs(i);
}
}
vector<int> uxhat(int x,int y,int r)
{
r+=K;
vector<int> ans;
if((x-r)<K)
ans.push_back(1);
if((y+r)>h-K)
ans.push_back(2);
if((x+r)>w-K)
ans.push_back(3);
if((y-r)<K)
ans.push_back(4);
return ans;
}
void f(int k)
{
for1(i,5)
for1(j,5)
MY[i][j]=1;
K=k;
for1(i,n)
if(hat(k,k,0,x[i],y[i],r[i]+K)==1)
for1(z,5)
{
MY[1][z]=0;
MY[z][1]=0;
}
for1(i,n)
if(hat(k,h-k,0,x[i],y[i],r[i]+K)==1)
for1(z,5)
{
MY[4][z]=0;
MY[z][4]=0;
}
for1(i,n)
if(hat(w-k,h-k,0,x[i],y[i],r[i]+K)==1)
for1(z,5)
{
MY[3][z]=0;
MY[z][3]=0;
}
for1(i,n)
if(hat(w-k,k,0,x[i],y[i],r[i]+K)==1)
for1(z,5)
{
MY[2][z]=0;
MY[z][2]=0;
}
K=k;
for1(i,n)
used[i]=0;
for1(i,n)
for1(j,n)
jan[i][j]=0;
for1(i,n)
{
if(used[i]==0)
{
X=i;
dfs(X);
}
}
for1(i,n)
{
for1(j,n)
{
if(i!=j && jan[i][j]==1)
{
int AA[10];
int BB[10];
for1(z,5)
{
AA[z]=0;
BB[z]=0;
}
vector<int> A=uxhat(x[i],y[i],r[i]);
vector<int> B=uxhat(x[j],y[j],r[j]);
for0(z,A.size()-1)
AA[A[z]]=1;
for0(z,B.size()-1)
BB[B[z]]=1;
if(AA[1]==1 && BB[4]==1)
{
MY[1][4]=0;
MY[1][3]=0;
MY[1][2]=0;
}
if(AA[1]==1 && BB[3]==1)
{
MY[1][3]=0;
MY[1][4]=0;
MY[2][3]=0;
MY[2][4]=0;
}
if(AA[1]==1 && BB[2]==1)
{
MY[1][4]=0;
MY[2][4]=0;
MY[3][4]=0;
}
if(AA[2]==1 && BB[3]==1)
{
MY[4][3]=0;
MY[1][3]=0;
MY[2][3]=0;
}
if(AA[2]==1 && BB[4]==1)
{
MY[4][3]=0;
MY[4][2]=0;
MY[1][3]=0;
MY[1][2]=0;
}
if(AA[3]==1 && BB[4]==1)
{
MY[1][2]=0;
MY[4][2]=0;
MY[3][2]=0;
}
}
}
}
}
int main()
{
cin>>n>>m;
cin>>w>>h;
for1(i,n)
cin>>x[i]>>y[i]>>r[i];
for1(i,n)
{
int r,e;
cin>>r>>e;
f(r);
for1(j,4)
if(MY[e][j]==1 && MY[j][e]==1)
cout<<j;
cout<<endl;
}
return 0;
}
/*5 3
16 11
11 8 1
6 10 1
7 3 2
10 4 1
15 5 1
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2564 ms |
15992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
15992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2564 ms |
15992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |