Submission #123947

# Submission time Handle Problem Language Result Execution time Memory
123947 2019-07-02T09:59:20 Z hani Circle selection (APIO18_circle_selection) C++14
0 / 100
1557 ms 9544 KB
#include <bits/stdc++.h>
using namespace std;
struct cir
{
    int x,y,r,in;
    bool eliminated;
};
bool comp(cir a,cir b)
{
    if(a.r==b.r) return a.in<b.in;
     return a.r>b.r;
}
bool inter(cir a,cir b)
{
    double d=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
    if   (a.r+b.r >=d) return true;
    return false;
}
int main()
{
    int n; cin>>n;
    cir t[n];
    for(int i=0;i<n;i++)
    {
        int x,y,r;
        scanf("%d%d%d",&x,&y,&r );
        t[i].x=x; t[i].y=y; t[i].r=r; t[i].in=i+1; t[i].eliminated=0;
    }
    sort(t,t+n,comp);
    //for(int i=0;i<n;i++){printf("%d %d %d %d \n",t[i].x,t[i].y,t[i].r,t[i].in);}
    int eliminations[n+1];
    for (int i=0;i<n;i++)
    {
        if(!t[i].eliminated)
        {
            eliminations[t[i].in]=t[i].in;
            for(int j=i+1;j<n;j++)
            {
                if(inter(t[i],t[j]) && !t[j].eliminated)
                {
                    eliminations[t[j].in]=t[i].in;
                    t[j].eliminated=true;
                }
            }
            t[i].eliminated=true;
        }
    }
    for(int i=1;i<=n;i++) cout<<eliminations[i]<<" ";
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&x,&y,&r );
         ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 286 ms 9544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1557 ms 8292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -