답안 #48854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48854 2018-05-19T10:29:32 Z model_code 원 고르기 (APIO18_circle_selection) C++17
7 / 100
3000 ms 13792 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]
     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]
     for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&x[i],&y[i],&r[i]);
                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 2 ms 620 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 4 ms 740 KB Output is correct
18 Correct 3 ms 740 KB Output is correct
19 Correct 5 ms 748 KB Output is correct
20 Correct 5 ms 748 KB Output is correct
21 Correct 6 ms 764 KB Output is correct
22 Correct 78 ms 1036 KB Output is correct
23 Correct 80 ms 1036 KB Output is correct
24 Correct 72 ms 1036 KB Output is correct
25 Correct 79 ms 1036 KB Output is correct
26 Correct 84 ms 1036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 213 ms 11100 KB Output is correct
2 Correct 186 ms 11100 KB Output is correct
3 Correct 181 ms 11100 KB Output is correct
4 Correct 163 ms 11100 KB Output is correct
5 Correct 2606 ms 13792 KB Output is correct
6 Execution timed out 3040 ms 13792 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 13792 KB Output is correct
2 Execution timed out 3023 ms 13792 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3023 ms 13792 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 2 ms 620 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 4 ms 740 KB Output is correct
18 Correct 3 ms 740 KB Output is correct
19 Correct 5 ms 748 KB Output is correct
20 Correct 5 ms 748 KB Output is correct
21 Correct 6 ms 764 KB Output is correct
22 Correct 78 ms 1036 KB Output is correct
23 Correct 80 ms 1036 KB Output is correct
24 Correct 72 ms 1036 KB Output is correct
25 Correct 79 ms 1036 KB Output is correct
26 Correct 84 ms 1036 KB Output is correct
27 Correct 9 ms 13792 KB Output is correct
28 Correct 8 ms 13792 KB Output is correct
29 Correct 9 ms 13792 KB Output is correct
30 Correct 301 ms 13792 KB Output is correct
31 Correct 304 ms 13792 KB Output is correct
32 Correct 299 ms 13792 KB Output is correct
33 Correct 71 ms 13792 KB Output is correct
34 Correct 73 ms 13792 KB Output is correct
35 Correct 75 ms 13792 KB Output is correct
36 Execution timed out 3027 ms 13792 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 536 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 2 ms 620 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 4 ms 740 KB Output is correct
18 Correct 3 ms 740 KB Output is correct
19 Correct 5 ms 748 KB Output is correct
20 Correct 5 ms 748 KB Output is correct
21 Correct 6 ms 764 KB Output is correct
22 Correct 78 ms 1036 KB Output is correct
23 Correct 80 ms 1036 KB Output is correct
24 Correct 72 ms 1036 KB Output is correct
25 Correct 79 ms 1036 KB Output is correct
26 Correct 84 ms 1036 KB Output is correct
27 Correct 213 ms 11100 KB Output is correct
28 Correct 186 ms 11100 KB Output is correct
29 Correct 181 ms 11100 KB Output is correct
30 Correct 163 ms 11100 KB Output is correct
31 Correct 2606 ms 13792 KB Output is correct
32 Execution timed out 3040 ms 13792 KB Time limit exceeded
33 Halted 0 ms 0 KB -