답안 #123924

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123924 2019-07-02T09:44:26 Z amiratou 원 고르기 (APIO18_circle_selection) C++14
7 / 100
3000 ms 16188 KB
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
ii point[300005];
int r[300005];
struct node
{
    int idx;
    node *l,*r;
};
typedef node* pnode;
pnode root = NULL;
bool inter(int i,int j){
    return ((point[i].fi-point[j].fi)*(point[i].fi-point[j].fi)+(point[i].se-point[j].se)*(point[i].se-point[j].se))<=((r[i]+r[j])*(r[i]+r[j]));
}
void insert(pnode &t, pnode it){
    if(!t)
        t=it;
    //debugs(t->idx,it->idx);
    //debug(inter(t->idx,it->idx));
    else if(inter(t->idx,it->idx))
        insert(t->r,it);
    else
        insert(t->l,it);
}
vii vec;
bool mycomparer(std::pair<int, int> lhs, std::pair<int, int> rhs) {
    if (lhs.first > rhs.first) {
        return true;
    }
    else if (lhs.first == rhs.first && lhs.second < rhs.second) {
        return true;
    }
    return false;
}
int ans[300005];
void righty(pnode t,int id){
    if(!t)
        return ;
    ans[t->idx]=id;
    righty(t->r,id);
    righty(t->l,id);
}
void solve(pnode t){
    if(!t)
        return ;
    ans[t->idx]=t->idx;
    righty(t->r,t->idx);
    solve(t->l);
}
main(){
    //boost;
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i){
        cin>>point[i].fi>>point[i].se>>r[i];
        vec.pb({r[i],i});
    }
    sort(all(vec),mycomparer);
    for (int i = 0; i < n; ++i){
        pnode curr = new node;
        curr->idx=vec[i].se;
        curr->l=curr->r=NULL;
        insert(root,curr);
    }
    solve(root);
    for (int i = 0; i < n; ++i)
        cout<<ans[i]+1<<" ";
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Compilation message

circle_selection.cpp:70:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 6 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 9 ms 504 KB Output is correct
19 Correct 202 ms 988 KB Output is correct
20 Correct 211 ms 1032 KB Output is correct
21 Correct 74 ms 1016 KB Output is correct
22 Correct 209 ms 1012 KB Output is correct
23 Correct 220 ms 888 KB Output is correct
24 Correct 216 ms 940 KB Output is correct
25 Correct 212 ms 880 KB Output is correct
26 Correct 217 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3042 ms 16188 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 3039 ms 7632 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3043 ms 16068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 6 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 9 ms 504 KB Output is correct
19 Correct 202 ms 988 KB Output is correct
20 Correct 211 ms 1032 KB Output is correct
21 Correct 74 ms 1016 KB Output is correct
22 Correct 209 ms 1012 KB Output is correct
23 Correct 220 ms 888 KB Output is correct
24 Correct 216 ms 940 KB Output is correct
25 Correct 212 ms 880 KB Output is correct
26 Correct 217 ms 888 KB Output is correct
27 Correct 361 ms 1776 KB Output is correct
28 Correct 913 ms 1728 KB Output is correct
29 Correct 737 ms 1768 KB Output is correct
30 Correct 1147 ms 1656 KB Output is correct
31 Correct 1140 ms 1652 KB Output is correct
32 Correct 1155 ms 1656 KB Output is correct
33 Execution timed out 3055 ms 7972 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 6 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 9 ms 504 KB Output is correct
19 Correct 202 ms 988 KB Output is correct
20 Correct 211 ms 1032 KB Output is correct
21 Correct 74 ms 1016 KB Output is correct
22 Correct 209 ms 1012 KB Output is correct
23 Correct 220 ms 888 KB Output is correct
24 Correct 216 ms 940 KB Output is correct
25 Correct 212 ms 880 KB Output is correct
26 Correct 217 ms 888 KB Output is correct
27 Execution timed out 3042 ms 16188 KB Time limit exceeded
28 Halted 0 ms 0 KB -