답안 #368145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
368145 2021-02-19T16:18:12 Z YJU 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 19748 KB
//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename A,typename B>
ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It>
ostream& _OUTC(ostream &_s,It _b,It _e)//container
{
    _s<<"{";
    for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
    _s<<"}";
    return _s;
}
template<typename A,typename B>
ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename I>
void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
{
    int _c=0;
    static const char _bra[]="({[";
    static const char _ket[]=")}]";
    while(*_s!=',' || _c!=0)//eg. mkp(a,b)
    {
        if(strchr(_bra,*_s)) _c++;
        if(strchr(_ket,*_s)) _c--;
        cerr<<*_s++;
    }
    cerr<<"="<<_x<<", ";
    _DOING(_s+1,_tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0)
#else
#define debug(...)
#endif
//}}}
const int maxn=5e5+5;
ll x[maxn],y[maxn],r[maxn];
int n;
void read()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&x[i],&y[i],&r[i]);
}
bool inter(int i,int j)
{
    ll dx=x[i]-x[j],dy=y[i]-y[j];
    ll dd=dx*dx+dy*dy,rr=(r[i]+r[j])*(r[i]+r[j]);
    return dd<=rr;
}
void build(){}
int ans[maxn];
void sol()
{
    vector<int> cir(n);iota(ALL(cir),1);
    while(SZ(cir))
    {
        int i=cir[0];
        for(int j:cir) if(tie(r[j],i)>tie(r[i],j))
            i=j;

        vector<int> nxt;
        for(int j:cir)
        {
            if(!inter(i,j)) nxt.pb(j);
            else ans[j]=i;
        }
        nxt.swap(cir);
    }
    REP1(i,1,n) printf("%d%c",ans[i]," \n"[i==n]);
}
int main()
{
    read();
    build();
    sol();
    return 0;
}

Compilation message

circle_selection.cpp: In function 'void read()':
circle_selection.cpp:76:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   76 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
circle_selection.cpp:77:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   77 |     for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&x[i],&y[i],&r[i]);
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 380 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 748 KB Output is correct
20 Correct 3 ms 748 KB Output is correct
21 Correct 3 ms 748 KB Output is correct
22 Correct 75 ms 748 KB Output is correct
23 Correct 66 ms 748 KB Output is correct
24 Correct 74 ms 816 KB Output is correct
25 Correct 66 ms 748 KB Output is correct
26 Correct 85 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 201 ms 17532 KB Output is correct
2 Correct 155 ms 17532 KB Output is correct
3 Correct 155 ms 17176 KB Output is correct
4 Correct 162 ms 17532 KB Output is correct
5 Correct 2633 ms 18236 KB Output is correct
6 Execution timed out 3041 ms 17752 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 3090 ms 7244 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3060 ms 19748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 380 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 748 KB Output is correct
20 Correct 3 ms 748 KB Output is correct
21 Correct 3 ms 748 KB Output is correct
22 Correct 75 ms 748 KB Output is correct
23 Correct 66 ms 748 KB Output is correct
24 Correct 74 ms 816 KB Output is correct
25 Correct 66 ms 748 KB Output is correct
26 Correct 85 ms 876 KB Output is correct
27 Correct 6 ms 1004 KB Output is correct
28 Correct 8 ms 1004 KB Output is correct
29 Correct 9 ms 1004 KB Output is correct
30 Correct 268 ms 1132 KB Output is correct
31 Correct 254 ms 1132 KB Output is correct
32 Correct 262 ms 1172 KB Output is correct
33 Correct 76 ms 6756 KB Output is correct
34 Correct 62 ms 6868 KB Output is correct
35 Correct 79 ms 6756 KB Output is correct
36 Execution timed out 3036 ms 6988 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 380 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 3 ms 748 KB Output is correct
20 Correct 3 ms 748 KB Output is correct
21 Correct 3 ms 748 KB Output is correct
22 Correct 75 ms 748 KB Output is correct
23 Correct 66 ms 748 KB Output is correct
24 Correct 74 ms 816 KB Output is correct
25 Correct 66 ms 748 KB Output is correct
26 Correct 85 ms 876 KB Output is correct
27 Correct 201 ms 17532 KB Output is correct
28 Correct 155 ms 17532 KB Output is correct
29 Correct 155 ms 17176 KB Output is correct
30 Correct 162 ms 17532 KB Output is correct
31 Correct 2633 ms 18236 KB Output is correct
32 Execution timed out 3041 ms 17752 KB Time limit exceeded
33 Halted 0 ms 0 KB -