Submission #44806

# Submission time Handle Problem Language Result Execution time Memory
44806 2018-04-07T04:06:31 Z leehosu01 None (KOI16_dist) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F(X) (X<0?-1:X>0)
ll T,MT,N,tms,bst=1ll<<62ll;
struct A{
int x,y,dx,dy;void SC(){cin>>x>>y>>dx>>dy;}
ll lcx(){return T*dx+x;}
ll lcy(){return T*dy+y;}
bool operator<(const A&X)const{return T*dx+x<T*X.dx+X.x;}
ll Ds(A&X){return (lcx()-X.lcx())*(lcx()-X.lcx())+(lcy()-X.lcy())*(lcy()-X.lcy());}
}S[30000];
int cp(ll*X,ll*Y)
{
    ll T=0;
    for(int i=0;i<2;i++)
        T+=X[i]*Y[i+1]-X[i+1]*Y[i];
    return F(T);
}
int ccw(A&x0,A&x1,A&x2)
{
    A XA[3]={x0,x1,x2};
    ll XX[3],YY[3];
    for(int i=0;i<3;i++)
    {
        XX[i]=XA[i].lcx();
        YY[i]=XA[i].lcy();
    }
    return cp(XX,YY);
}
bool used[30000];
#define nxt(X,Xp) Xp=X;if(++Xp==cov.end())Xp=cov.begin()
inline ld slop(A&d1,A&d2)
{
    return ((ld)d1.lcx()-d2.lcx())/(d1.lcy()-d2.lcy());
}
const ld RAD=180/(ld)3.14159265358979646323;
inline slopRNG(ld x1,ld x2,ld x3)//각도상[0]<=[1]<=[2]에서 1반환
{
    ld AT[3],SP[3]={x1,x2,x3};
    for(int i=0;i<3;i++)AT[i]=atan(SP[i]);
    return (AT[0]<=AT[1]&&AT[1]<=AT[2]);
}
ll pro(int Ts)
{
    memset(used,0,sizeof(used));
    list<int>cov;
    T=Ts;
    sort(S,S+N);
    int K=1;
    for(int i=0;i>=0;i+=K)
    {
        if(i==N)K=-1;
        if(i!=0&&used[i])continue;
        while(cov.size()>=2&&ccw(S[--cov.back()],S[cov.back()],S[i])==1){used[cov.back()]=0;cov.pop_back();}
        used[i]=1;cov.push_back(i);
    }
    list<int>::iterator I,Ip,J=cov.begin(),Jp,Jpp;
    ll MX=0;
    for(I=cov.begin();I!=cov.end();I++)
    {
        nxt(I,Ip);
        ld SPI=slop(S[*I],S[*Ip]);
        nxt(J,Jp);
        nxt(Jp,Jpp);
        while(!slopRNG(slop(S[*J],S[*Jp]),SPI,slop(S[*Jp],S[*Jpp]))){J=Jp;Jp=Jpp;nxt(Jp,Jpp);}
        MX=max(MX,S[*I].Ds(S[*Jp]));
    }
    if(MX<bst)bst=MX,tms=Ts;
    return MX;
}

void rnd(ll&X)
{
    ull T=rand();
    for(int i=0;i<=10;i++)T^=((ull)rand()<<(rand()%64));
    X=(T>>1)%(MT+1);
}
int main()
{int i;
    cin>>N>>MT;
    for(i=0;i<N;i++)S[i].SC();
    ll l=0,r=MT,m,PS[3],minl,minI;
    while(l<r)
    {
        m=l+r>>1;
        minl=1ll<<62ll;
        for(i=-1;i<2;i++)
        {
            if(m+i>=0&&m+i<=MT)
            {
                PS[i+1]=pro(m+i);
                if(PS[i+1]<minl)
                {
                    minl=PS[i+1];
                    minI=i;
                }
            }
        }
        if(minI==-1)r=m-1;
        else if(minI==0)l=r=m;
        else l=m+1;
    }
    cout<<tms<<'\n'<<bst;
}

Compilation message

dist.cpp:40:33: error: ISO C++ forbids declaration of 'slopRNG' with no type [-fpermissive]
 inline slopRNG(ld x1,ld x2,ld x3)//각도상[0]<=[1]<=[2]에서 1반환
                                 ^
dist.cpp: In function 'int main()':
dist.cpp:88:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         m=l+r>>1;
           ~^~