답안 #22285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22285 2017-04-30T03:33:13 Z ↓우리보다잘하는팀(#947, ainta, gs12117, gs13068) Donut-shaped Enclosure (KRIII5_DE) C++
7 / 7
1159 ms 33148 KB
#include<cstdio>
#include<algorithm>
#define SZ 1048576
using namespace std;
int n, L, R;
struct Seg{
    int x, y1, y2, s;
    bool operator <(const Seg &p)const{
        return x<p.x;
    }
}w[801000];
int Y[801000], Res;
struct Tree{
    int Mx, K;
}IT[SZ+SZ];
int cnt;
void Add(int nd, int x){
    IT[nd].Mx += x;
    IT[nd].K += x;
}
void Spread(int nd){
    Add(nd+nd, IT[nd].K);
    Add(nd+nd+1, IT[nd].K);
    IT[nd].K = 0;
}
void Ins(int nd, int b, int e, int s, int l, int x){
    if(b==s&&e==l){
        Add(nd, x);
        return;
    }
    Spread(nd);
    int m = (b+e)>>1;
    if(s<=m)Ins(nd+nd, b, m, s, min(m,l),x);
    if(l>m)Ins(nd+nd+1, m+1, e, max(m+1,s), l,x);
    IT[nd].Mx = max(IT[nd+nd].Mx, IT[nd+nd+1].Mx);
}
int main(){
    scanf("%d%d%d",&n,&L,&R);
    int i, x, y, c;
    for(i=1;i<=n;i++){
        scanf("%d%d%d",&x,&y,&c);
        w[cnt++] = {x-R,y-R,y+R,c};
        w[cnt++] = {x-L+1,y-R,y+R,-c};
        
        w[cnt++] = {x-L+1,y-R,y-L,c};
        w[cnt++] = {x+L,y-R,y-L,-c};
        
        w[cnt++] = {x-L+1,y+L,y+R,c};
        w[cnt++] = {x+L,y+L,y+R,-c};
        
        w[cnt++] = {x+L,y-R,y+R,c};
        w[cnt++] = {x+R+1,y-R,y+R,-c};
    }
    for(i=0;i<cnt;i+=2){
        Y[i]=w[i].y1;
        Y[i^1]=w[i].y2;
    }
    sort(Y,Y+cnt);
    for(i=0;i<cnt;i++){
        w[i].y1 = lower_bound(Y, Y+cnt, w[i].y1) - Y + 1;
        w[i].y2 = lower_bound(Y, Y+cnt, w[i].y2) - Y + 1;
    }
    sort(w,w+cnt);
    for(i=0;i<cnt;i++){
        Ins(1, 1, SZ, w[i].y1, w[i].y2, w[i].s);
        if(w[i].x!=w[i+1].x){
            Res = max(Res, IT[1].Mx);
        }
    }
    printf("%d\n",Res);
}

Compilation message

DE.cpp: In function 'int main()':
DE.cpp:42:34: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-R,y-R,y+R,c};
                                  ^
DE.cpp:42:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-R,y-R,y+R,c};
                  ^
DE.cpp:43:37: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-L+1,y-R,y+R,-c};
                                     ^
DE.cpp:43:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-L+1,y-R,y+R,-c};
                  ^
DE.cpp:45:36: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-L+1,y-R,y-L,c};
                                    ^
DE.cpp:45:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-L+1,y-R,y-L,c};
                  ^
DE.cpp:46:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+L,y-R,y-L,-c};
                                   ^
DE.cpp:46:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+L,y-R,y-L,-c};
                  ^
DE.cpp:48:36: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-L+1,y+L,y+R,c};
                                    ^
DE.cpp:48:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x-L+1,y+L,y+R,c};
                  ^
DE.cpp:49:35: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+L,y+L,y+R,-c};
                                   ^
DE.cpp:49:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+L,y+L,y+R,-c};
                  ^
DE.cpp:51:34: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+L,y-R,y+R,c};
                                  ^
DE.cpp:51:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+L,y-R,y+R,c};
                  ^
DE.cpp:52:37: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+R+1,y-R,y+R,-c};
                                     ^
DE.cpp:52:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         w[cnt++] = {x+R+1,y-R,y+R,-c};
                  ^
DE.cpp:38:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&L,&R);
                             ^
DE.cpp:41:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&x,&y,&c);
                                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33148 KB Output is correct
2 Correct 0 ms 33148 KB Output is correct
3 Correct 0 ms 33148 KB Output is correct
4 Correct 0 ms 33148 KB Output is correct
5 Correct 0 ms 33148 KB Output is correct
6 Correct 0 ms 33148 KB Output is correct
7 Correct 0 ms 33148 KB Output is correct
8 Correct 3 ms 33148 KB Output is correct
9 Correct 3 ms 33148 KB Output is correct
10 Correct 3 ms 33148 KB Output is correct
11 Correct 6 ms 33148 KB Output is correct
12 Correct 9 ms 33148 KB Output is correct
13 Correct 3 ms 33148 KB Output is correct
14 Correct 6 ms 33148 KB Output is correct
15 Correct 6 ms 33148 KB Output is correct
16 Correct 9 ms 33148 KB Output is correct
17 Correct 6 ms 33148 KB Output is correct
18 Correct 3 ms 33148 KB Output is correct
19 Correct 3 ms 33148 KB Output is correct
20 Correct 9 ms 33148 KB Output is correct
21 Correct 3 ms 33148 KB Output is correct
22 Correct 3 ms 33148 KB Output is correct
23 Correct 3 ms 33148 KB Output is correct
24 Correct 6 ms 33148 KB Output is correct
25 Correct 3 ms 33148 KB Output is correct
26 Correct 3 ms 33148 KB Output is correct
27 Correct 3 ms 33148 KB Output is correct
28 Correct 3 ms 33148 KB Output is correct
29 Correct 3 ms 33148 KB Output is correct
30 Correct 6 ms 33148 KB Output is correct
31 Correct 3 ms 33148 KB Output is correct
32 Correct 3 ms 33148 KB Output is correct
33 Correct 3 ms 33148 KB Output is correct
34 Correct 3 ms 33148 KB Output is correct
35 Correct 3 ms 33148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 33148 KB Output is correct
2 Correct 0 ms 33148 KB Output is correct
3 Correct 0 ms 33148 KB Output is correct
4 Correct 0 ms 33148 KB Output is correct
5 Correct 0 ms 33148 KB Output is correct
6 Correct 0 ms 33148 KB Output is correct
7 Correct 0 ms 33148 KB Output is correct
8 Correct 3 ms 33148 KB Output is correct
9 Correct 3 ms 33148 KB Output is correct
10 Correct 3 ms 33148 KB Output is correct
11 Correct 6 ms 33148 KB Output is correct
12 Correct 9 ms 33148 KB Output is correct
13 Correct 3 ms 33148 KB Output is correct
14 Correct 6 ms 33148 KB Output is correct
15 Correct 6 ms 33148 KB Output is correct
16 Correct 9 ms 33148 KB Output is correct
17 Correct 6 ms 33148 KB Output is correct
18 Correct 3 ms 33148 KB Output is correct
19 Correct 3 ms 33148 KB Output is correct
20 Correct 9 ms 33148 KB Output is correct
21 Correct 3 ms 33148 KB Output is correct
22 Correct 3 ms 33148 KB Output is correct
23 Correct 3 ms 33148 KB Output is correct
24 Correct 6 ms 33148 KB Output is correct
25 Correct 3 ms 33148 KB Output is correct
26 Correct 3 ms 33148 KB Output is correct
27 Correct 3 ms 33148 KB Output is correct
28 Correct 3 ms 33148 KB Output is correct
29 Correct 3 ms 33148 KB Output is correct
30 Correct 6 ms 33148 KB Output is correct
31 Correct 3 ms 33148 KB Output is correct
32 Correct 3 ms 33148 KB Output is correct
33 Correct 3 ms 33148 KB Output is correct
34 Correct 3 ms 33148 KB Output is correct
35 Correct 3 ms 33148 KB Output is correct
36 Correct 0 ms 33148 KB Output is correct
37 Correct 3 ms 33148 KB Output is correct
38 Correct 6 ms 33148 KB Output is correct
39 Correct 13 ms 33148 KB Output is correct
40 Correct 16 ms 33148 KB Output is correct
41 Correct 29 ms 33148 KB Output is correct
42 Correct 43 ms 33148 KB Output is correct
43 Correct 59 ms 33148 KB Output is correct
44 Correct 73 ms 33148 KB Output is correct
45 Correct 116 ms 33148 KB Output is correct
46 Correct 126 ms 33148 KB Output is correct
47 Correct 149 ms 33148 KB Output is correct
48 Correct 169 ms 33148 KB Output is correct
49 Correct 483 ms 33148 KB Output is correct
50 Correct 523 ms 33148 KB Output is correct
51 Correct 1039 ms 33148 KB Output is correct
52 Correct 1049 ms 33148 KB Output is correct
53 Correct 1008 ms 33148 KB Output is correct
54 Correct 1106 ms 33148 KB Output is correct
55 Correct 1059 ms 33148 KB Output is correct
56 Correct 983 ms 33148 KB Output is correct
57 Correct 1159 ms 33148 KB Output is correct
58 Correct 1026 ms 33148 KB Output is correct
59 Correct 776 ms 33148 KB Output is correct
60 Correct 1049 ms 33148 KB Output is correct
61 Correct 13 ms 33148 KB Output is correct
62 Correct 93 ms 33148 KB Output is correct
63 Correct 219 ms 33148 KB Output is correct
64 Correct 489 ms 33148 KB Output is correct
65 Correct 1139 ms 33148 KB Output is correct
66 Correct 639 ms 33148 KB Output is correct
67 Correct 609 ms 33148 KB Output is correct
68 Correct 636 ms 33148 KB Output is correct
69 Correct 623 ms 33148 KB Output is correct
70 Correct 676 ms 33148 KB Output is correct
71 Correct 706 ms 33148 KB Output is correct
72 Correct 749 ms 33148 KB Output is correct
73 Correct 799 ms 33148 KB Output is correct
74 Correct 759 ms 33148 KB Output is correct
75 Correct 773 ms 33148 KB Output is correct
76 Correct 829 ms 33148 KB Output is correct
77 Correct 896 ms 33148 KB Output is correct
78 Correct 909 ms 33148 KB Output is correct
79 Correct 889 ms 33148 KB Output is correct
80 Correct 869 ms 33148 KB Output is correct