#include #define endl '\n' using namespace std; struct Group { int x,y,num; }; struct Region { vector ps; vector qs; long long P,Q; }; struct Cmd { int x1,x2,y1,y2,num; Cmd() {} Cmd(int _x1,int _x2,int _y1,int _y2,int _num) { x1=_x1; x2=_x2; y1=_y1; y2=_y2; num=_num; } }; const int offsetX[4]={-1,0,1,0}; const int offsetY[4]={0,1,0,-1}; const int C=1e9+1; const int S=1e9; const int bound[5]={100,360,1300,4690,16900}; const vector sq[5]={ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 50, 100, 500, 1000, 2000, 5000, 10000, 20000, 50000}, {3.6, 5, 6, 7.2, 9, 10, 12, 15, 18, 20, 25, 30, 40, 50, 60, 70, 85, 100, 150, 200, 250, 300, 400, 500, 1000, 2000, 5000, 10000, 20000, 50000}, {13, 15, 17, 20, 25, 30, 35, 40, 45, 50, 70, 80, 90, 100, 200, 300, 500, 1000, 2000, 5000, 10000, 20000, 50000}, {20, 30, 40, 46.9, 48, 50, 52, 55, 58, 60, 65, 70, 75, 80, 90, 100, 110, 150, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000}, {50, 80, 100, 150, 169, 172, 175, 180, 184, 188, 190, 195, 200, 220, 250, 260, 300, 500, 1000, 2000, 5000, 10000, 20000, 50000} }; int n,m; Group p[50005], q[50005]; map forts; long double curr=0,best=1e21; /// vector sol, curr_sol; Region r[300][300]; void init(int T) { for(int i=0;i go_near(int ind) { int x,y; for(int i=0;i<4;i++) { x=q[ind].x+offsetX[i], y=q[ind].y+offsetY[i]; if(x>=0 && x<=1e9 && y>=0 && y<=1e9 && forts[(long long) x*C+y]==0) return {ind,i}; } return {-1,-1}; } void add(long long x1,long long y1,long long x2,long long y2,int num) { curr_sol.push_back(Cmd(x1,x2,y1,y2,num)); curr+=(long double)num*sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); /// return; } long long battle(long long p,long long q) { return (long long) ceil(sqrt(p*p-q*q)); } bool _try(const int side) /// const? { int T=S/side+1; init(T); // clear regions for(int i=0;i aim; for(int k=0;k>n>>m; for(int i=0;i>p[i].x>>p[i].y>>p[i].num; } for(int i=0;i>q[i].x>>q[i].y>>q[i].num; maxv=max(maxv,q[i].num); forts[(long long)q[i].x*C+q[i].y]=1; } sort(q,q+m,cmp); for(int i=0;i<5;i++) { if(maxv<=bound[i]) { solve(i); break; } } //cout<