답안 #586242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586242 2022-06-30T05:28:45 Z abcvuitunggio Team Contest (JOI22_team) C++17
100 / 100
1936 ms 96920 KB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
const int mn=-1000000000;
struct point{
    int x,y,val;
}p[150002][2];
int ft[150002][2],n,x[150002],y[150002],z[150002],id[3],val[150002][3],res=-1,szx,szy,idx[150002];
vector <int> v[3],node[150002],bit[150002];
map <int, int> mp[3];
vector <pair <int, point> > pending;
vector <pair <pair <int, int>, int> > f;
inline void update(int x, int val, int idx){
    for (;x<=max(szx,szy);x+=x&(-x))
        ft[x][idx]=max(ft[x][idx],val);
}
inline int get(int i, int idx){
    int res=0;
    for (;i;i-=i&(-i))
        res=max(res,ft[i][idx]);
    return res;
}
inline void fakeUpdate(int x, int y){
    for (;x<=szx;x+=x&-x)
        node[x].push_back(y);
}
inline void fakeGet(int x, int y){
    for (;x;x-=x&-x)
        node[x].push_back(y);
}
inline void update2D(int x, int yy, int val) {
    for (;x<=szx;x+=x&-x)
        for (int y=lower_bound(node[x].begin(),node[x].end(),yy)-node[x].begin()+1;y<=node[x].size();y+=y&-y){
            if (bit[x][y-1]>val)
                break;
            bit[x][y-1]=val;
        }
}
inline int get2D(int x, int yy){
    int res=mn;
    for (;x;x-=x&-x)
        for (int y=lower_bound(node[x].begin(),node[x].end(),yy)-node[x].begin()+1;y;y-=y&-y)
            res=max(res,bit[x][y-1]);
    return res;
}
inline bool cmp(int i, int j){
    return x[i]<x[j];
}
int main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> x[i] >> y[i] >> z[i];
        v[0].push_back(x[i]);
        v[1].push_back(y[i]);
        v[2].push_back(z[i]);
        idx[i]=i;
    }
    sort(idx,idx+n,cmp);
    for (int i=0;i<3;i++){
        sort(v[i].begin(),v[i].end());
        for (int j:v[i])
            if (!mp[i].count(j)){
                mp[i][j]=++id[i];
                val[id[i]][i]=j;
            }
    }
    for (int i=0;i<n;i++){
        x[i]=mp[0][x[i]];
        y[i]=mp[1][y[i]];
        z[i]=mp[2][z[i]];
        szx=max(szx,y[i]+1);
        szy=max(szy,z[i]+1);
    }
    for (int r=0;r<n;r++){
        int i=idx[r];
        p[i][0].x=y[i];
        int mx=get(y[i]-1,0);
        if (mx>z[i]){
            p[i][0].y=mx;
            p[i][0].val=val[y[i]][1]+val[mx][2];
        }
        p[i][1].y=z[i];
        mx=get(z[i]-1,1);
        if (mx>y[i]){
            p[i][1].x=mx;
            p[i][1].val=val[mx][1]+val[z[i]][2];
        }
        update(y[i],z[i],0);
        update(z[i],y[i],1);
    }
    for (int i=0;i<n;i++){
        p[i][0].x=szx-p[i][0].x;
        p[i][0].y=szy-p[i][0].y;
        p[i][1].x=szx-p[i][1].x;
        p[i][1].y=szy-p[i][1].y;
        y[i]=szx-y[i];
        z[i]=szy-z[i];
        if (p[i][0].y!=szy)
            f.push_back(make_pair(make_pair(p[i][0].y,p[i][0].x),0));
        if (p[i][1].x!=szx)
            f.push_back(make_pair(make_pair(p[i][1].y,p[i][1].x),0));
        f.push_back(make_pair(make_pair(z[i]-1,y[i]-1),1));
    }
    sort(f.begin(),f.end());
    for (auto i:f)
        if (i.second)
            fakeGet(i.first.second,i.first.first);
        else
            fakeUpdate(i.first.second,i.first.first);
    for (int i=1;i<=szx;i++)
        bit[i].resize(node[i].size(),mn);
    for (int r=0;r<n;r++){
        int i=idx[r];
        if (!pending.empty()){
            if (x[i]>pending.back().first)
                while (!pending.empty()){
                    update2D(pending.back().second.x,pending.back().second.y,pending.back().second.val);
                    pending.pop_back();
                }
        }
        if (p[i][0].y!=szy)
            pending.push_back(make_pair(x[i],p[i][0]));
        if (p[i][1].x!=szx)
            pending.push_back(make_pair(x[i],p[i][1]));
        res=max(res,val[x[i]][0]+get2D(y[i]-1,z[i]-1));
    }
    cout << res;
}

Compilation message

team.cpp: In function 'void update2D(int, int, int)':
team.cpp:37:85: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for (int y=lower_bound(node[x].begin(),node[x].end(),yy)-node[x].begin()+1;y<=node[x].size();y+=y&-y){
      |                                                                                    ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 5 ms 7296 KB Output is correct
4 Correct 4 ms 7364 KB Output is correct
5 Correct 5 ms 7348 KB Output is correct
6 Correct 5 ms 7380 KB Output is correct
7 Correct 4 ms 7316 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7336 KB Output is correct
11 Correct 4 ms 7380 KB Output is correct
12 Correct 4 ms 7380 KB Output is correct
13 Correct 4 ms 7380 KB Output is correct
14 Correct 5 ms 7544 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7380 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 6 ms 7380 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7508 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7380 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 5 ms 7296 KB Output is correct
4 Correct 4 ms 7364 KB Output is correct
5 Correct 5 ms 7348 KB Output is correct
6 Correct 5 ms 7380 KB Output is correct
7 Correct 4 ms 7316 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7336 KB Output is correct
11 Correct 4 ms 7380 KB Output is correct
12 Correct 4 ms 7380 KB Output is correct
13 Correct 4 ms 7380 KB Output is correct
14 Correct 5 ms 7544 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7380 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 6 ms 7380 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7508 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7380 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct
26 Correct 21 ms 9368 KB Output is correct
27 Correct 17 ms 8780 KB Output is correct
28 Correct 17 ms 8596 KB Output is correct
29 Correct 15 ms 8332 KB Output is correct
30 Correct 11 ms 8148 KB Output is correct
31 Correct 18 ms 8544 KB Output is correct
32 Correct 10 ms 8020 KB Output is correct
33 Correct 8 ms 8020 KB Output is correct
34 Correct 11 ms 8660 KB Output is correct
35 Correct 5 ms 7508 KB Output is correct
36 Correct 5 ms 7508 KB Output is correct
37 Correct 8 ms 8020 KB Output is correct
38 Correct 9 ms 8020 KB Output is correct
39 Correct 7 ms 7764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7388 KB Output is correct
6 Correct 4 ms 7392 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7400 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 177 ms 26192 KB Output is correct
12 Correct 95 ms 17292 KB Output is correct
13 Correct 87 ms 17048 KB Output is correct
14 Correct 155 ms 24040 KB Output is correct
15 Correct 114 ms 23332 KB Output is correct
16 Correct 87 ms 18792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7388 KB Output is correct
6 Correct 4 ms 7392 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7400 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 177 ms 26192 KB Output is correct
12 Correct 95 ms 17292 KB Output is correct
13 Correct 87 ms 17048 KB Output is correct
14 Correct 155 ms 24040 KB Output is correct
15 Correct 114 ms 23332 KB Output is correct
16 Correct 87 ms 18792 KB Output is correct
17 Correct 4 ms 7336 KB Output is correct
18 Correct 4 ms 7400 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 9 ms 7764 KB Output is correct
22 Correct 307 ms 31872 KB Output is correct
23 Correct 208 ms 27392 KB Output is correct
24 Correct 139 ms 21156 KB Output is correct
25 Correct 183 ms 25484 KB Output is correct
26 Correct 117 ms 24088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7388 KB Output is correct
6 Correct 4 ms 7392 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7400 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 177 ms 26192 KB Output is correct
12 Correct 95 ms 17292 KB Output is correct
13 Correct 87 ms 17048 KB Output is correct
14 Correct 155 ms 24040 KB Output is correct
15 Correct 114 ms 23332 KB Output is correct
16 Correct 87 ms 18792 KB Output is correct
17 Correct 4 ms 7336 KB Output is correct
18 Correct 4 ms 7400 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 9 ms 7764 KB Output is correct
22 Correct 307 ms 31872 KB Output is correct
23 Correct 208 ms 27392 KB Output is correct
24 Correct 139 ms 21156 KB Output is correct
25 Correct 183 ms 25484 KB Output is correct
26 Correct 117 ms 24088 KB Output is correct
27 Correct 5 ms 7420 KB Output is correct
28 Correct 5 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 5 ms 7380 KB Output is correct
31 Correct 11 ms 8036 KB Output is correct
32 Correct 5 ms 7508 KB Output is correct
33 Correct 6 ms 7436 KB Output is correct
34 Correct 711 ms 41208 KB Output is correct
35 Correct 429 ms 31776 KB Output is correct
36 Correct 517 ms 36476 KB Output is correct
37 Correct 289 ms 30092 KB Output is correct
38 Correct 136 ms 27348 KB Output is correct
39 Correct 162 ms 34980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7380 KB Output is correct
5 Correct 4 ms 7388 KB Output is correct
6 Correct 4 ms 7392 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7400 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 177 ms 26192 KB Output is correct
12 Correct 95 ms 17292 KB Output is correct
13 Correct 87 ms 17048 KB Output is correct
14 Correct 155 ms 24040 KB Output is correct
15 Correct 114 ms 23332 KB Output is correct
16 Correct 87 ms 18792 KB Output is correct
17 Correct 4 ms 7336 KB Output is correct
18 Correct 4 ms 7400 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 9 ms 7764 KB Output is correct
22 Correct 307 ms 31872 KB Output is correct
23 Correct 208 ms 27392 KB Output is correct
24 Correct 139 ms 21156 KB Output is correct
25 Correct 183 ms 25484 KB Output is correct
26 Correct 117 ms 24088 KB Output is correct
27 Correct 5 ms 7420 KB Output is correct
28 Correct 5 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 5 ms 7380 KB Output is correct
31 Correct 11 ms 8036 KB Output is correct
32 Correct 5 ms 7508 KB Output is correct
33 Correct 6 ms 7436 KB Output is correct
34 Correct 711 ms 41208 KB Output is correct
35 Correct 429 ms 31776 KB Output is correct
36 Correct 517 ms 36476 KB Output is correct
37 Correct 289 ms 30092 KB Output is correct
38 Correct 136 ms 27348 KB Output is correct
39 Correct 162 ms 34980 KB Output is correct
40 Correct 10 ms 8220 KB Output is correct
41 Correct 15 ms 8472 KB Output is correct
42 Correct 8 ms 8020 KB Output is correct
43 Correct 9 ms 8148 KB Output is correct
44 Correct 1169 ms 53696 KB Output is correct
45 Correct 442 ms 35880 KB Output is correct
46 Correct 537 ms 38808 KB Output is correct
47 Correct 397 ms 34460 KB Output is correct
48 Correct 163 ms 31528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 5 ms 7296 KB Output is correct
4 Correct 4 ms 7364 KB Output is correct
5 Correct 5 ms 7348 KB Output is correct
6 Correct 5 ms 7380 KB Output is correct
7 Correct 4 ms 7316 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7336 KB Output is correct
11 Correct 4 ms 7380 KB Output is correct
12 Correct 4 ms 7380 KB Output is correct
13 Correct 4 ms 7380 KB Output is correct
14 Correct 5 ms 7544 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7380 KB Output is correct
18 Correct 5 ms 7380 KB Output is correct
19 Correct 6 ms 7380 KB Output is correct
20 Correct 6 ms 7380 KB Output is correct
21 Correct 5 ms 7380 KB Output is correct
22 Correct 5 ms 7508 KB Output is correct
23 Correct 5 ms 7380 KB Output is correct
24 Correct 5 ms 7380 KB Output is correct
25 Correct 4 ms 7380 KB Output is correct
26 Correct 21 ms 9368 KB Output is correct
27 Correct 17 ms 8780 KB Output is correct
28 Correct 17 ms 8596 KB Output is correct
29 Correct 15 ms 8332 KB Output is correct
30 Correct 11 ms 8148 KB Output is correct
31 Correct 18 ms 8544 KB Output is correct
32 Correct 10 ms 8020 KB Output is correct
33 Correct 8 ms 8020 KB Output is correct
34 Correct 11 ms 8660 KB Output is correct
35 Correct 5 ms 7508 KB Output is correct
36 Correct 5 ms 7508 KB Output is correct
37 Correct 8 ms 8020 KB Output is correct
38 Correct 9 ms 8020 KB Output is correct
39 Correct 7 ms 7764 KB Output is correct
40 Correct 5 ms 7380 KB Output is correct
41 Correct 5 ms 7380 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
43 Correct 4 ms 7380 KB Output is correct
44 Correct 4 ms 7388 KB Output is correct
45 Correct 4 ms 7392 KB Output is correct
46 Correct 4 ms 7380 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7400 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
50 Correct 177 ms 26192 KB Output is correct
51 Correct 95 ms 17292 KB Output is correct
52 Correct 87 ms 17048 KB Output is correct
53 Correct 155 ms 24040 KB Output is correct
54 Correct 114 ms 23332 KB Output is correct
55 Correct 87 ms 18792 KB Output is correct
56 Correct 4 ms 7336 KB Output is correct
57 Correct 4 ms 7400 KB Output is correct
58 Correct 6 ms 7380 KB Output is correct
59 Correct 4 ms 7380 KB Output is correct
60 Correct 9 ms 7764 KB Output is correct
61 Correct 307 ms 31872 KB Output is correct
62 Correct 208 ms 27392 KB Output is correct
63 Correct 139 ms 21156 KB Output is correct
64 Correct 183 ms 25484 KB Output is correct
65 Correct 117 ms 24088 KB Output is correct
66 Correct 5 ms 7420 KB Output is correct
67 Correct 5 ms 7380 KB Output is correct
68 Correct 4 ms 7380 KB Output is correct
69 Correct 5 ms 7380 KB Output is correct
70 Correct 11 ms 8036 KB Output is correct
71 Correct 5 ms 7508 KB Output is correct
72 Correct 6 ms 7436 KB Output is correct
73 Correct 711 ms 41208 KB Output is correct
74 Correct 429 ms 31776 KB Output is correct
75 Correct 517 ms 36476 KB Output is correct
76 Correct 289 ms 30092 KB Output is correct
77 Correct 136 ms 27348 KB Output is correct
78 Correct 162 ms 34980 KB Output is correct
79 Correct 10 ms 8220 KB Output is correct
80 Correct 15 ms 8472 KB Output is correct
81 Correct 8 ms 8020 KB Output is correct
82 Correct 9 ms 8148 KB Output is correct
83 Correct 1169 ms 53696 KB Output is correct
84 Correct 442 ms 35880 KB Output is correct
85 Correct 537 ms 38808 KB Output is correct
86 Correct 397 ms 34460 KB Output is correct
87 Correct 163 ms 31528 KB Output is correct
88 Correct 1936 ms 96920 KB Output is correct
89 Correct 938 ms 58252 KB Output is correct
90 Correct 1493 ms 71676 KB Output is correct
91 Correct 613 ms 47796 KB Output is correct
92 Correct 1055 ms 51532 KB Output is correct
93 Correct 822 ms 57176 KB Output is correct
94 Correct 616 ms 46628 KB Output is correct
95 Correct 292 ms 42088 KB Output is correct
96 Correct 613 ms 57712 KB Output is correct
97 Correct 112 ms 18792 KB Output is correct
98 Correct 234 ms 36780 KB Output is correct
99 Correct 290 ms 36716 KB Output is correct