답안 #68949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68949 2018-08-19T10:59:06 Z Vahan Park (BOI16_park) C++17
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,m,k[6][6],u[3000],w,h,x[4000],y[4000],r[4000];
vector<pair<double,int> > g[4000];
void stug(int a,int b)
{
    if(a==n+1)
    {
        if(b==n+2)
        {
            k[4][3]=1;
            k[4][2]=1;
            k[4][1]=1;
        }
        if(b==n+3)
        {
            k[4][1]=1;
            k[4][2]=1;
            k[3][1]=1;
            k[3][2]=1;
        }
        if(b==n+4)
        {
            k[1][4]=1;
            k[1][3]=1;
            k[1][2]=1;
        }
    }
    if(a==n+2)
    {
        if(b==n+3)
        {
            k[3][1]=1;
            k[3][2]=1;
            k[3][4]=1;
        }
        if(b==n+4)
        {
            k[3][1]=1;
            k[3][4]=1;
            k[2][1]=1;
            k[2][4]=1;
        }
    }
    if(a==n+3)
    {
        if(b==n+4)
        {
            k[2][1]=1;
            k[2][3]=1;
            k[2][4]=1;
        }
    }
}
double dis(int a,int b)
{
    return (double)sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]))-r[a]-r[b];
}
void dfs(int v,int a,int q)
{
    u[v]=1;
    if(v>q)
        stug(q,v);
    for(int i=0;i<g[v].size();i++)
    {
        int to=g[v][i].second;
        double her=g[v][i].first;
        if(her>(double)a)
            break;
        if(u[to]==0)
            dfs(to,a,q);
    }
}
int main()
{
    cin>>n>>m;
    cin>>w>>h;
    for(int i=1;i<=n;i++)
        cin>>x[i]>>y[i]>>r[i];
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            double e=dis(i,j);
            g[i].push_back({e,j});
            g[j].push_back({e,i});
        }
    }
    for(int i=1;i<=n;i++)
    {
        g[n+1].push_back({x[i]-r[i],i});
        g[n+2].push_back({h-y[i]-r[i],i});
        g[n+3].push_back({w-x[i]-r[i],i});
        g[n+4].push_back({y[i]-r[i],i});
        g[i].push_back({x[i]-r[i],n+1});
        g[i].push_back({h-y[i]-r[i],n+2});
        g[i].push_back({w-x[i]-r[i],n+3});
        g[i].push_back({y[i]-r[i],n+4});
    }
    for(int i=1;i<=n+4;i++)
        sort(g[i].begin(),g[i].end());
    for(int i=1;i<=m;i++)
    {
        int a,an;
        cin>>a>>an;
        a*=2;
        dfs(n+1,a,n+1);
        for(int j=1;j<=n+4;j++)
            u[j]=0;
        dfs(n+2,a,n+2);
        for(int j=1;j<=n+4;j++)
            u[j]=0;
        dfs(n+3,a,n+3);
        for(int j=1;j<=n+4;j++)
            u[j]=0;
        for(int j=1;j<=4;j++)
        {
            if(k[an][j]==0 && k[j][an]==0)
                cout<<j;
        }
        for(int j=1;j<=4;j++)
        {
            for(int e=1;e<=4;e++)
                k[j][e]=0;
        }
        cout<<endl;
    }
    return 0;
}
/*
5 3
16 11
11 8 1
6 10 1
7 3 2
10 4 1
15 5 1
1 1
2 2
2 1
*/

Compilation message

park.cpp: In function 'double dis(int, int)':
park.cpp:59:20: error: 'sqrt' was not declared in this scope
     return (double)sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]))-r[a]-r[b];
                    ^~~~
park.cpp:59:20: note: suggested alternative: 'qsort'
     return (double)sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]))-r[a]-r[b];
                    ^~~~
                    qsort
park.cpp: In function 'void dfs(int, int, int)':
park.cpp:66:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g[v].size();i++)
                 ~^~~~~~~~~~~~