답안 #61416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61416 2018-07-25T21:51:01 Z duality 원 고르기 (APIO18_circle_selection) C++11
100 / 100
2015 ms 27424 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int x[300000],y[300000],r[300000],o[300000];
bool comp(int a,int b) {
    if (r[a] == r[b]) return a < b;
    else return r[a] > r[b];
}
LLI sq(LLI n) { return n*n; }
int inter(int a,int b) {
    return (sq(x[a]-x[b])+sq(y[a]-y[b])) <= sq(r[a]+r[b]);
}
vpii v;
vector<vi> v2;
int ans[300000];
int main() {
    int i;
    int n;
    scanf("%d",&n);
    for (i = 0; i < n; i++) scanf("%d %d %d",&x[i],&y[i],&r[i]),o[i] = i;
    sort(o,o+n,comp);

    int j,k,l;
    int logbs = 30;
    fill(ans,ans+n,-1);
    v.pb(mp(0,0)),v2.pb(vi());
    for (i = 0; i < n; i++) v2[0].pb(i);
    for (i = 0; i < n; i++) {
        if (ans[o[i]] == -1) {
            if (r[o[i]] <= (1 << (logbs-1))) {
                while (r[o[i]] <= (1 << (logbs-1))) logbs--;
                v.clear(),v2.clear();
                for (j = i; j < n; j++) {
                    if (ans[o[j]] == -1) v.pb(mp(x[o[j]] >> logbs,y[o[j]] >> logbs));
                }
                sort(v.begin(),v.end());
                v.resize(unique(v.begin(),v.end())-v.begin());
                v2.resize(v.size());
                for (j = i; j < n; j++) {
                    if (ans[o[j]] == -1) v2[lower_bound(v.begin(),v.end(),mp(x[o[j]] >> logbs,y[o[j]] >> logbs))-v.begin()].pb(o[j]);
                }
            }
            for (j = (x[o[i]] >> logbs)-2; j <= (x[o[i]] >> logbs)+2; j++) {
                for (k = (y[o[i]] >> logbs)-2; k <= (y[o[i]] >> logbs)+2; k++) {
                    int p = lower_bound(v.begin(),v.end(),mp(j,k))-v.begin();
                    if ((p < v.size()) && (v[p] == mp(j,k))) {
                        vi temp;
                        for (l = 0; l < v2[p].size(); l++) {
                            if (inter(o[i],v2[p][l])) ans[v2[p][l]] = o[i];
                            else temp.pb(v2[p][l]);
                        }
                        v2[p] = temp;
                    }
                }
            }
        }
    }
    for (i = 0; i < n; i++) printf("%d ",ans[i]+1);

    return 0;
}

Compilation message

circle_selection.cpp: In function 'int main()':
circle_selection.cpp:100:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     if ((p < v.size()) && (v[p] == mp(j,k))) {
                          ~~^~~~~~~~~~
circle_selection.cpp:102:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                         for (l = 0; l < v2[p].size(); l++) {
                                     ~~^~~~~~~~~~~~~~
circle_selection.cpp:73:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
circle_selection.cpp:74:64: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < n; i++) scanf("%d %d %d",&x[i],&y[i],&r[i]),o[i] = i;
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 4 ms 520 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 3 ms 676 KB Output is correct
8 Correct 3 ms 676 KB Output is correct
9 Correct 3 ms 676 KB Output is correct
10 Correct 2 ms 676 KB Output is correct
11 Correct 3 ms 676 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 3 ms 676 KB Output is correct
14 Correct 3 ms 676 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
17 Correct 4 ms 676 KB Output is correct
18 Correct 3 ms 676 KB Output is correct
19 Correct 6 ms 692 KB Output is correct
20 Correct 7 ms 748 KB Output is correct
21 Correct 7 ms 764 KB Output is correct
22 Correct 18 ms 1088 KB Output is correct
23 Correct 19 ms 1088 KB Output is correct
24 Correct 20 ms 1096 KB Output is correct
25 Correct 17 ms 1096 KB Output is correct
26 Correct 18 ms 1096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 350 ms 13008 KB Output is correct
2 Correct 310 ms 13340 KB Output is correct
3 Correct 308 ms 13340 KB Output is correct
4 Correct 266 ms 13340 KB Output is correct
5 Correct 415 ms 13340 KB Output is correct
6 Correct 944 ms 17468 KB Output is correct
7 Correct 421 ms 17468 KB Output is correct
8 Correct 570 ms 17468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 17468 KB Output is correct
2 Correct 568 ms 17468 KB Output is correct
3 Correct 1820 ms 27192 KB Output is correct
4 Correct 1670 ms 27336 KB Output is correct
5 Correct 1792 ms 27336 KB Output is correct
6 Correct 672 ms 27336 KB Output is correct
7 Correct 277 ms 27336 KB Output is correct
8 Correct 60 ms 27336 KB Output is correct
9 Correct 2015 ms 27336 KB Output is correct
10 Correct 1509 ms 27336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1248 ms 27420 KB Output is correct
2 Correct 1095 ms 27420 KB Output is correct
3 Correct 619 ms 27420 KB Output is correct
4 Correct 1113 ms 27420 KB Output is correct
5 Correct 1008 ms 27420 KB Output is correct
6 Correct 321 ms 27420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 4 ms 520 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 3 ms 676 KB Output is correct
8 Correct 3 ms 676 KB Output is correct
9 Correct 3 ms 676 KB Output is correct
10 Correct 2 ms 676 KB Output is correct
11 Correct 3 ms 676 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 3 ms 676 KB Output is correct
14 Correct 3 ms 676 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
17 Correct 4 ms 676 KB Output is correct
18 Correct 3 ms 676 KB Output is correct
19 Correct 6 ms 692 KB Output is correct
20 Correct 7 ms 748 KB Output is correct
21 Correct 7 ms 764 KB Output is correct
22 Correct 18 ms 1088 KB Output is correct
23 Correct 19 ms 1088 KB Output is correct
24 Correct 20 ms 1096 KB Output is correct
25 Correct 17 ms 1096 KB Output is correct
26 Correct 18 ms 1096 KB Output is correct
27 Correct 10 ms 27420 KB Output is correct
28 Correct 11 ms 27420 KB Output is correct
29 Correct 11 ms 27420 KB Output is correct
30 Correct 37 ms 27420 KB Output is correct
31 Correct 52 ms 27420 KB Output is correct
32 Correct 44 ms 27420 KB Output is correct
33 Correct 103 ms 27420 KB Output is correct
34 Correct 113 ms 27420 KB Output is correct
35 Correct 107 ms 27420 KB Output is correct
36 Correct 475 ms 27420 KB Output is correct
37 Correct 445 ms 27420 KB Output is correct
38 Correct 520 ms 27420 KB Output is correct
39 Correct 505 ms 27420 KB Output is correct
40 Correct 522 ms 27420 KB Output is correct
41 Correct 543 ms 27420 KB Output is correct
42 Correct 305 ms 27420 KB Output is correct
43 Correct 346 ms 27420 KB Output is correct
44 Correct 359 ms 27420 KB Output is correct
45 Correct 346 ms 27420 KB Output is correct
46 Correct 363 ms 27420 KB Output is correct
47 Correct 340 ms 27420 KB Output is correct
48 Correct 336 ms 27420 KB Output is correct
49 Correct 339 ms 27420 KB Output is correct
50 Correct 286 ms 27420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 4 ms 520 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 3 ms 676 KB Output is correct
8 Correct 3 ms 676 KB Output is correct
9 Correct 3 ms 676 KB Output is correct
10 Correct 2 ms 676 KB Output is correct
11 Correct 3 ms 676 KB Output is correct
12 Correct 3 ms 676 KB Output is correct
13 Correct 3 ms 676 KB Output is correct
14 Correct 3 ms 676 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
17 Correct 4 ms 676 KB Output is correct
18 Correct 3 ms 676 KB Output is correct
19 Correct 6 ms 692 KB Output is correct
20 Correct 7 ms 748 KB Output is correct
21 Correct 7 ms 764 KB Output is correct
22 Correct 18 ms 1088 KB Output is correct
23 Correct 19 ms 1088 KB Output is correct
24 Correct 20 ms 1096 KB Output is correct
25 Correct 17 ms 1096 KB Output is correct
26 Correct 18 ms 1096 KB Output is correct
27 Correct 350 ms 13008 KB Output is correct
28 Correct 310 ms 13340 KB Output is correct
29 Correct 308 ms 13340 KB Output is correct
30 Correct 266 ms 13340 KB Output is correct
31 Correct 415 ms 13340 KB Output is correct
32 Correct 944 ms 17468 KB Output is correct
33 Correct 421 ms 17468 KB Output is correct
34 Correct 570 ms 17468 KB Output is correct
35 Correct 2 ms 17468 KB Output is correct
36 Correct 568 ms 17468 KB Output is correct
37 Correct 1820 ms 27192 KB Output is correct
38 Correct 1670 ms 27336 KB Output is correct
39 Correct 1792 ms 27336 KB Output is correct
40 Correct 672 ms 27336 KB Output is correct
41 Correct 277 ms 27336 KB Output is correct
42 Correct 60 ms 27336 KB Output is correct
43 Correct 2015 ms 27336 KB Output is correct
44 Correct 1509 ms 27336 KB Output is correct
45 Correct 1248 ms 27420 KB Output is correct
46 Correct 1095 ms 27420 KB Output is correct
47 Correct 619 ms 27420 KB Output is correct
48 Correct 1113 ms 27420 KB Output is correct
49 Correct 1008 ms 27420 KB Output is correct
50 Correct 321 ms 27420 KB Output is correct
51 Correct 10 ms 27420 KB Output is correct
52 Correct 11 ms 27420 KB Output is correct
53 Correct 11 ms 27420 KB Output is correct
54 Correct 37 ms 27420 KB Output is correct
55 Correct 52 ms 27420 KB Output is correct
56 Correct 44 ms 27420 KB Output is correct
57 Correct 103 ms 27420 KB Output is correct
58 Correct 113 ms 27420 KB Output is correct
59 Correct 107 ms 27420 KB Output is correct
60 Correct 475 ms 27420 KB Output is correct
61 Correct 445 ms 27420 KB Output is correct
62 Correct 520 ms 27420 KB Output is correct
63 Correct 505 ms 27420 KB Output is correct
64 Correct 522 ms 27420 KB Output is correct
65 Correct 543 ms 27420 KB Output is correct
66 Correct 305 ms 27420 KB Output is correct
67 Correct 346 ms 27420 KB Output is correct
68 Correct 359 ms 27420 KB Output is correct
69 Correct 346 ms 27420 KB Output is correct
70 Correct 363 ms 27420 KB Output is correct
71 Correct 340 ms 27420 KB Output is correct
72 Correct 336 ms 27420 KB Output is correct
73 Correct 339 ms 27420 KB Output is correct
74 Correct 286 ms 27420 KB Output is correct
75 Correct 330 ms 27420 KB Output is correct
76 Correct 310 ms 27420 KB Output is correct
77 Correct 308 ms 27420 KB Output is correct
78 Correct 255 ms 27420 KB Output is correct
79 Correct 549 ms 27420 KB Output is correct
80 Correct 293 ms 27420 KB Output is correct
81 Correct 1887 ms 27420 KB Output is correct
82 Correct 1744 ms 27420 KB Output is correct
83 Correct 1797 ms 27420 KB Output is correct
84 Correct 1949 ms 27420 KB Output is correct
85 Correct 1778 ms 27420 KB Output is correct
86 Correct 1585 ms 27420 KB Output is correct
87 Correct 1950 ms 27420 KB Output is correct
88 Correct 1786 ms 27420 KB Output is correct
89 Correct 1822 ms 27420 KB Output is correct
90 Correct 1723 ms 27420 KB Output is correct
91 Correct 1809 ms 27420 KB Output is correct
92 Correct 1707 ms 27420 KB Output is correct
93 Correct 1630 ms 27420 KB Output is correct
94 Correct 1424 ms 27420 KB Output is correct
95 Correct 1651 ms 27424 KB Output is correct
96 Correct 1621 ms 27424 KB Output is correct
97 Correct 1836 ms 27424 KB Output is correct
98 Correct 1044 ms 27424 KB Output is correct
99 Correct 1524 ms 27424 KB Output is correct
100 Correct 1321 ms 27424 KB Output is correct
101 Correct 1575 ms 27424 KB Output is correct
102 Correct 1421 ms 27424 KB Output is correct
103 Correct 2007 ms 27424 KB Output is correct
104 Correct 1456 ms 27424 KB Output is correct
105 Correct 1043 ms 27424 KB Output is correct
106 Correct 962 ms 27424 KB Output is correct
107 Correct 1028 ms 27424 KB Output is correct
108 Correct 1137 ms 27424 KB Output is correct
109 Correct 1122 ms 27424 KB Output is correct
110 Correct 1020 ms 27424 KB Output is correct
111 Correct 1006 ms 27424 KB Output is correct
112 Correct 1032 ms 27424 KB Output is correct
113 Correct 1025 ms 27424 KB Output is correct
114 Correct 1059 ms 27424 KB Output is correct
115 Correct 1057 ms 27424 KB Output is correct
116 Correct 1055 ms 27424 KB Output is correct