답안 #61414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61414 2018-07-25T21:35:46 Z duality 원 고르기 (APIO18_circle_selection) C++11
100 / 100
2083 ms 410368 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 ----------

struct circle { int x,y,r,i; };
bool comp(circle a,circle b) {
    if (a.r == b.r) return a.i < b.i;
    else return a.r > b.r;
}
int x[300000],y[300000],r[300000];
circle c[300000];
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]);
        c[i].x = x[i],c[i].y = y[i],c[i].r = r[i],c[i].i = i;
    }
    sort(c,c+n,comp);

    int j,k,l;
    int bs = 1 << 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[c[i].i] == -1) {
            if (c[i].r <= (bs >> 1)) {
                while (c[i].r <= (bs >> 1)) bs >>= 1;
                v.clear(),v2.clear();
                for (j = i; j < n; j++) {
                    if (ans[c[j].i] == -1) v.pb(mp(c[j].x/bs,c[j].y/bs));
                }
                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[c[j].i] == -1) v2[lower_bound(v.begin(),v.end(),mp(c[j].x/bs,c[j].y/bs))-v.begin()].pb(c[j].i);
                }
            }
            for (j = c[i].x/bs-2; j <= c[i].x/bs+2; j++) {
                for (k = c[i].y/bs-2; k <= c[i].y/bs+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(c[i].i,v2[p][l])) ans[v2[p][l]] = c[i].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:105:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     if ((p < v.size()) && (v[p] == mp(j,k))) {
                          ~~^~~~~~~~~~
circle_selection.cpp:107:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                         for (l = 0; l < v2[p].size(); l++) {
                                     ~~^~~~~~~~~~~~~~
circle_selection.cpp:75: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:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&x[i],&y[i],&r[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 420 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 656 KB Output is correct
6 Correct 3 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 3 ms 768 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 4 ms 768 KB Output is correct
19 Correct 7 ms 916 KB Output is correct
20 Correct 6 ms 916 KB Output is correct
21 Correct 9 ms 916 KB Output is correct
22 Correct 19 ms 1188 KB Output is correct
23 Correct 20 ms 1204 KB Output is correct
24 Correct 22 ms 1204 KB Output is correct
25 Correct 24 ms 1204 KB Output is correct
26 Correct 26 ms 1204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 330 ms 16124 KB Output is correct
2 Correct 361 ms 17028 KB Output is correct
3 Correct 288 ms 17028 KB Output is correct
4 Correct 215 ms 17028 KB Output is correct
5 Correct 316 ms 17028 KB Output is correct
6 Correct 771 ms 20844 KB Output is correct
7 Correct 368 ms 20844 KB Output is correct
8 Correct 466 ms 20844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 20844 KB Output is correct
2 Correct 527 ms 20844 KB Output is correct
3 Correct 1926 ms 30944 KB Output is correct
4 Correct 1742 ms 39180 KB Output is correct
5 Correct 1843 ms 44272 KB Output is correct
6 Correct 678 ms 44272 KB Output is correct
7 Correct 325 ms 44272 KB Output is correct
8 Correct 53 ms 44272 KB Output is correct
9 Correct 2083 ms 61672 KB Output is correct
10 Correct 1484 ms 66232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1339 ms 70604 KB Output is correct
2 Correct 1168 ms 77788 KB Output is correct
3 Correct 584 ms 77788 KB Output is correct
4 Correct 1267 ms 93588 KB Output is correct
5 Correct 1290 ms 101336 KB Output is correct
6 Correct 425 ms 101336 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 3 ms 420 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 656 KB Output is correct
6 Correct 3 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 3 ms 768 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 4 ms 768 KB Output is correct
19 Correct 7 ms 916 KB Output is correct
20 Correct 6 ms 916 KB Output is correct
21 Correct 9 ms 916 KB Output is correct
22 Correct 19 ms 1188 KB Output is correct
23 Correct 20 ms 1204 KB Output is correct
24 Correct 22 ms 1204 KB Output is correct
25 Correct 24 ms 1204 KB Output is correct
26 Correct 26 ms 1204 KB Output is correct
27 Correct 12 ms 101336 KB Output is correct
28 Correct 12 ms 101336 KB Output is correct
29 Correct 14 ms 101336 KB Output is correct
30 Correct 46 ms 101336 KB Output is correct
31 Correct 48 ms 101336 KB Output is correct
32 Correct 36 ms 101336 KB Output is correct
33 Correct 97 ms 101336 KB Output is correct
34 Correct 87 ms 101336 KB Output is correct
35 Correct 102 ms 101336 KB Output is correct
36 Correct 497 ms 101336 KB Output is correct
37 Correct 471 ms 101336 KB Output is correct
38 Correct 481 ms 101336 KB Output is correct
39 Correct 477 ms 101336 KB Output is correct
40 Correct 465 ms 101336 KB Output is correct
41 Correct 465 ms 101336 KB Output is correct
42 Correct 280 ms 101336 KB Output is correct
43 Correct 357 ms 101336 KB Output is correct
44 Correct 387 ms 101336 KB Output is correct
45 Correct 343 ms 101336 KB Output is correct
46 Correct 329 ms 101336 KB Output is correct
47 Correct 329 ms 101336 KB Output is correct
48 Correct 395 ms 101336 KB Output is correct
49 Correct 325 ms 101336 KB Output is correct
50 Correct 405 ms 101336 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 3 ms 420 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 656 KB Output is correct
6 Correct 3 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 3 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 3 ms 768 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 3 ms 768 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 4 ms 768 KB Output is correct
19 Correct 7 ms 916 KB Output is correct
20 Correct 6 ms 916 KB Output is correct
21 Correct 9 ms 916 KB Output is correct
22 Correct 19 ms 1188 KB Output is correct
23 Correct 20 ms 1204 KB Output is correct
24 Correct 22 ms 1204 KB Output is correct
25 Correct 24 ms 1204 KB Output is correct
26 Correct 26 ms 1204 KB Output is correct
27 Correct 330 ms 16124 KB Output is correct
28 Correct 361 ms 17028 KB Output is correct
29 Correct 288 ms 17028 KB Output is correct
30 Correct 215 ms 17028 KB Output is correct
31 Correct 316 ms 17028 KB Output is correct
32 Correct 771 ms 20844 KB Output is correct
33 Correct 368 ms 20844 KB Output is correct
34 Correct 466 ms 20844 KB Output is correct
35 Correct 3 ms 20844 KB Output is correct
36 Correct 527 ms 20844 KB Output is correct
37 Correct 1926 ms 30944 KB Output is correct
38 Correct 1742 ms 39180 KB Output is correct
39 Correct 1843 ms 44272 KB Output is correct
40 Correct 678 ms 44272 KB Output is correct
41 Correct 325 ms 44272 KB Output is correct
42 Correct 53 ms 44272 KB Output is correct
43 Correct 2083 ms 61672 KB Output is correct
44 Correct 1484 ms 66232 KB Output is correct
45 Correct 1339 ms 70604 KB Output is correct
46 Correct 1168 ms 77788 KB Output is correct
47 Correct 584 ms 77788 KB Output is correct
48 Correct 1267 ms 93588 KB Output is correct
49 Correct 1290 ms 101336 KB Output is correct
50 Correct 425 ms 101336 KB Output is correct
51 Correct 12 ms 101336 KB Output is correct
52 Correct 12 ms 101336 KB Output is correct
53 Correct 14 ms 101336 KB Output is correct
54 Correct 46 ms 101336 KB Output is correct
55 Correct 48 ms 101336 KB Output is correct
56 Correct 36 ms 101336 KB Output is correct
57 Correct 97 ms 101336 KB Output is correct
58 Correct 87 ms 101336 KB Output is correct
59 Correct 102 ms 101336 KB Output is correct
60 Correct 497 ms 101336 KB Output is correct
61 Correct 471 ms 101336 KB Output is correct
62 Correct 481 ms 101336 KB Output is correct
63 Correct 477 ms 101336 KB Output is correct
64 Correct 465 ms 101336 KB Output is correct
65 Correct 465 ms 101336 KB Output is correct
66 Correct 280 ms 101336 KB Output is correct
67 Correct 357 ms 101336 KB Output is correct
68 Correct 387 ms 101336 KB Output is correct
69 Correct 343 ms 101336 KB Output is correct
70 Correct 329 ms 101336 KB Output is correct
71 Correct 329 ms 101336 KB Output is correct
72 Correct 395 ms 101336 KB Output is correct
73 Correct 325 ms 101336 KB Output is correct
74 Correct 405 ms 101336 KB Output is correct
75 Correct 340 ms 104456 KB Output is correct
76 Correct 299 ms 114016 KB Output is correct
77 Correct 300 ms 123648 KB Output is correct
78 Correct 309 ms 128148 KB Output is correct
79 Correct 396 ms 140100 KB Output is correct
80 Correct 262 ms 145860 KB Output is correct
81 Correct 1768 ms 171792 KB Output is correct
82 Correct 1791 ms 179420 KB Output is correct
83 Correct 1666 ms 187532 KB Output is correct
84 Correct 1634 ms 195868 KB Output is correct
85 Correct 1514 ms 203708 KB Output is correct
86 Correct 1602 ms 211644 KB Output is correct
87 Correct 1714 ms 219508 KB Output is correct
88 Correct 1569 ms 220520 KB Output is correct
89 Correct 1695 ms 223916 KB Output is correct
90 Correct 1581 ms 227380 KB Output is correct
91 Correct 1678 ms 230712 KB Output is correct
92 Correct 1416 ms 234080 KB Output is correct
93 Correct 1384 ms 243476 KB Output is correct
94 Correct 1518 ms 250788 KB Output is correct
95 Correct 1566 ms 258052 KB Output is correct
96 Correct 1442 ms 264848 KB Output is correct
97 Correct 1850 ms 271824 KB Output is correct
98 Correct 1196 ms 271824 KB Output is correct
99 Correct 1585 ms 286092 KB Output is correct
100 Correct 1363 ms 293076 KB Output is correct
101 Correct 1257 ms 294516 KB Output is correct
102 Correct 1460 ms 307024 KB Output is correct
103 Correct 1788 ms 313736 KB Output is correct
104 Correct 1440 ms 321176 KB Output is correct
105 Correct 977 ms 321176 KB Output is correct
106 Correct 1073 ms 332564 KB Output is correct
107 Correct 1098 ms 340408 KB Output is correct
108 Correct 1078 ms 348316 KB Output is correct
109 Correct 1178 ms 356160 KB Output is correct
110 Correct 1156 ms 363792 KB Output is correct
111 Correct 1111 ms 371600 KB Output is correct
112 Correct 1134 ms 379444 KB Output is correct
113 Correct 1121 ms 387084 KB Output is correct
114 Correct 1112 ms 394892 KB Output is correct
115 Correct 1236 ms 402596 KB Output is correct
116 Correct 1050 ms 410368 KB Output is correct