답안 #996859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996859 2024-06-11T10:52:45 Z modwwe Team Contest (JOI22_team) C++17
100 / 100
474 ms 25632 KB
#include<bits/stdc++.h>
//#define int long long
//#define ll long long
#define down cout<<'\n';
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
const int inf=1e9;
void phongbeo();
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    int a,b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c, d,e,f;

};
int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int  i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
    //fin(task),fou(task);
#endif
    NHP
    /// cin>>s1;
    // modwwe
    phongbeo(),down
    checktime
}
int bit[450001];
void reset()
{
    for(int i=1; i<=n*3; i++) bit[i]=3*n+1;
}
void upd(int x,int y)
{
    for(x; x; x-=x&-x) bit[x]=min(bit[x],y);
}
int get(int x)
{
    int ss=3*n+1;
    for(x; x<=n*3; x+=x&-x)ss=min(ss,bit[x]);
    return ss;
}
bool cmp(id a,id b)
{
    if(a.a==b.a)return a.c>b.c;
    return a.a<b.a;
}
int d[150001];
id a[150001];
id b[150001];
vector<int> v;
vector<int> v2[450001];
bool cmp2(id a,id b)
{
    if(a.c==b.c)return a.a<b.a;
    return a.c>b.c;
}
void solve()
{
    /// muc dich ham solve :
    /// sort theo ac
    /// aa dung cuoi
    /// ab dung giua
    /// ta co goi b1 b2 b3 la thu tu
    /// b1.a<b2.a<b3.a
///b1.c>b2.c>b3.c
///b1.b<b2.b>b3.b
    sort(a+1,a+1+n,cmp);
     for(int i=1;i<=n;i++)
    v2[a[i].c].clear();
    reset();
    for(int i=1; i<=n; i++)
    {
        l=a[i].c+1;
        r=n*3;
        s2=-1;
        while(l<=r)
        {
            int mid=l+r>>1;
            if(get(mid)<a[i].b)l=mid+1,s2=mid;
            else r=mid-1;
        }
        if(s2!=-1)d[a[i].d]=v[s2-1]+v[a[i].b-1],
        v2[s2].pb({a[i].d});
                else  d[a[i].d]=-1e9,upd(a[i].c,a[i].b);
    }
    sort(a+1,a+1+n,cmp2);
    reset();
    for(int i=n; i>=1; --i)
    {  //cout<<a[i].c,down
                 upd(a[i].a,a[i].b);

        if(a[i-1].c!=a[i].c)
        for(auto x:v2[a[i-1].c]){
        l=b[x].a+1;
        r=n*3;
        s2=-1;
        while(l<=r)
        {
            int mid=l+r>>1;
            if(get(mid)<b[x].b)
                l=mid+1,s2=mid;
            else r=mid-1;
        }
        if(s2!=-1)
        {
            s3=max(s3,d[x]+v[s2-1]);
        }
        }
    }
/// cot chon thu 2 se la cot 2 va co cot 1 lon thu h2

}
void phongbeo()
{
    cin>>n;
    reset();
    for(int i=1; i<=n; i++)
        cin>>a[i].a>>a[i].b>>a[i].c,a[i].d=i,
                                        v.pb(a[i].a),
                                        v.pb(a[i].b),
                                        v.pb(a[i].c);
    sort(v.begin(),v.end());
    for(int i=1; i<=n; i++)
        a[i].a=lower_bound(v.begin(),v.end(),a[i].a)-v.begin()+1,
            a[i].b=lower_bound(v.begin(),v.end(),a[i].b)-v.begin()+1,
                a[i].c=lower_bound(v.begin(),v.end(),a[i].c)-v.begin()+1;
    s3=-1;
    for(int i=1;i<=n;i++)
 b[i]=a[i];
   solve();
   for(int i=1; i<=n; i++)
        swap(a[i].a,a[i].b),
        swap(b[i].a,b[i].b);
    solve();
    for(int i=1; i<=n; i++)
        swap(a[i].a,a[i].b),
        swap(b[i].a,b[i].b);
    for(int i=1; i<=n; i++)
        swap(a[i].c,a[i].b),
        swap(b[i].c,b[i].b);
    solve();
    cout<<s3;
}

Compilation message

team.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      | ^~~~
team.cpp: In function 'void upd(int, int)':
team.cpp:62:9: warning: statement has no effect [-Wunused-value]
   62 |     for(x; x; x-=x&-x) bit[x]=min(bit[x],y);
      |         ^
team.cpp: In function 'int get(int)':
team.cpp:67:9: warning: statement has no effect [-Wunused-value]
   67 |     for(x; x<=n*3; x+=x&-x)ss=min(ss,bit[x]);
      |         ^
team.cpp: In function 'void solve()':
team.cpp:106:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  106 |             int mid=l+r>>1;
      |                     ~^~
team.cpp:127:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  127 |             int mid=l+r>>1;
      |                     ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16988 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 2 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 2 ms 16988 KB Output is correct
7 Correct 2 ms 16988 KB Output is correct
8 Correct 2 ms 17040 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 3 ms 16988 KB Output is correct
11 Correct 3 ms 16988 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 16988 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 3 ms 17000 KB Output is correct
16 Correct 3 ms 16988 KB Output is correct
17 Correct 2 ms 16988 KB Output is correct
18 Correct 3 ms 17044 KB Output is correct
19 Correct 3 ms 16988 KB Output is correct
20 Correct 3 ms 16988 KB Output is correct
21 Correct 3 ms 16988 KB Output is correct
22 Correct 3 ms 16984 KB Output is correct
23 Correct 2 ms 16988 KB Output is correct
24 Correct 3 ms 16984 KB Output is correct
25 Correct 3 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16988 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 2 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 2 ms 16988 KB Output is correct
7 Correct 2 ms 16988 KB Output is correct
8 Correct 2 ms 17040 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 3 ms 16988 KB Output is correct
11 Correct 3 ms 16988 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 16988 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 3 ms 17000 KB Output is correct
16 Correct 3 ms 16988 KB Output is correct
17 Correct 2 ms 16988 KB Output is correct
18 Correct 3 ms 17044 KB Output is correct
19 Correct 3 ms 16988 KB Output is correct
20 Correct 3 ms 16988 KB Output is correct
21 Correct 3 ms 16988 KB Output is correct
22 Correct 3 ms 16984 KB Output is correct
23 Correct 2 ms 16988 KB Output is correct
24 Correct 3 ms 16984 KB Output is correct
25 Correct 3 ms 16988 KB Output is correct
26 Correct 9 ms 17240 KB Output is correct
27 Correct 12 ms 17244 KB Output is correct
28 Correct 10 ms 17244 KB Output is correct
29 Correct 10 ms 17176 KB Output is correct
30 Correct 7 ms 17160 KB Output is correct
31 Correct 10 ms 17056 KB Output is correct
32 Correct 8 ms 16988 KB Output is correct
33 Correct 6 ms 17060 KB Output is correct
34 Correct 7 ms 17244 KB Output is correct
35 Correct 3 ms 16988 KB Output is correct
36 Correct 4 ms 16988 KB Output is correct
37 Correct 6 ms 17224 KB Output is correct
38 Correct 7 ms 16984 KB Output is correct
39 Correct 4 ms 16988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17500 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 3 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 3 ms 17048 KB Output is correct
7 Correct 3 ms 17052 KB Output is correct
8 Correct 3 ms 16988 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 2 ms 16984 KB Output is correct
11 Correct 214 ms 21472 KB Output is correct
12 Correct 120 ms 20184 KB Output is correct
13 Correct 159 ms 20696 KB Output is correct
14 Correct 178 ms 21188 KB Output is correct
15 Correct 178 ms 21112 KB Output is correct
16 Correct 165 ms 20952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17500 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 3 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 3 ms 17048 KB Output is correct
7 Correct 3 ms 17052 KB Output is correct
8 Correct 3 ms 16988 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 2 ms 16984 KB Output is correct
11 Correct 214 ms 21472 KB Output is correct
12 Correct 120 ms 20184 KB Output is correct
13 Correct 159 ms 20696 KB Output is correct
14 Correct 178 ms 21188 KB Output is correct
15 Correct 178 ms 21112 KB Output is correct
16 Correct 165 ms 20952 KB Output is correct
17 Correct 2 ms 16984 KB Output is correct
18 Correct 2 ms 16988 KB Output is correct
19 Correct 2 ms 16988 KB Output is correct
20 Correct 3 ms 16988 KB Output is correct
21 Correct 4 ms 16988 KB Output is correct
22 Correct 237 ms 22392 KB Output is correct
23 Correct 220 ms 21452 KB Output is correct
24 Correct 147 ms 20440 KB Output is correct
25 Correct 199 ms 21760 KB Output is correct
26 Correct 173 ms 21188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17500 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 3 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 3 ms 17048 KB Output is correct
7 Correct 3 ms 17052 KB Output is correct
8 Correct 3 ms 16988 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 2 ms 16984 KB Output is correct
11 Correct 214 ms 21472 KB Output is correct
12 Correct 120 ms 20184 KB Output is correct
13 Correct 159 ms 20696 KB Output is correct
14 Correct 178 ms 21188 KB Output is correct
15 Correct 178 ms 21112 KB Output is correct
16 Correct 165 ms 20952 KB Output is correct
17 Correct 2 ms 16984 KB Output is correct
18 Correct 2 ms 16988 KB Output is correct
19 Correct 2 ms 16988 KB Output is correct
20 Correct 3 ms 16988 KB Output is correct
21 Correct 4 ms 16988 KB Output is correct
22 Correct 237 ms 22392 KB Output is correct
23 Correct 220 ms 21452 KB Output is correct
24 Correct 147 ms 20440 KB Output is correct
25 Correct 199 ms 21760 KB Output is correct
26 Correct 173 ms 21188 KB Output is correct
27 Correct 3 ms 16988 KB Output is correct
28 Correct 2 ms 16988 KB Output is correct
29 Correct 2 ms 16988 KB Output is correct
30 Correct 3 ms 16988 KB Output is correct
31 Correct 8 ms 16988 KB Output is correct
32 Correct 3 ms 16988 KB Output is correct
33 Correct 3 ms 16984 KB Output is correct
34 Correct 286 ms 22864 KB Output is correct
35 Correct 298 ms 22216 KB Output is correct
36 Correct 318 ms 22728 KB Output is correct
37 Correct 276 ms 22112 KB Output is correct
38 Correct 184 ms 21704 KB Output is correct
39 Correct 141 ms 20440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 17500 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 3 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 3 ms 17048 KB Output is correct
7 Correct 3 ms 17052 KB Output is correct
8 Correct 3 ms 16988 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 2 ms 16984 KB Output is correct
11 Correct 214 ms 21472 KB Output is correct
12 Correct 120 ms 20184 KB Output is correct
13 Correct 159 ms 20696 KB Output is correct
14 Correct 178 ms 21188 KB Output is correct
15 Correct 178 ms 21112 KB Output is correct
16 Correct 165 ms 20952 KB Output is correct
17 Correct 2 ms 16984 KB Output is correct
18 Correct 2 ms 16988 KB Output is correct
19 Correct 2 ms 16988 KB Output is correct
20 Correct 3 ms 16988 KB Output is correct
21 Correct 4 ms 16988 KB Output is correct
22 Correct 237 ms 22392 KB Output is correct
23 Correct 220 ms 21452 KB Output is correct
24 Correct 147 ms 20440 KB Output is correct
25 Correct 199 ms 21760 KB Output is correct
26 Correct 173 ms 21188 KB Output is correct
27 Correct 3 ms 16988 KB Output is correct
28 Correct 2 ms 16988 KB Output is correct
29 Correct 2 ms 16988 KB Output is correct
30 Correct 3 ms 16988 KB Output is correct
31 Correct 8 ms 16988 KB Output is correct
32 Correct 3 ms 16988 KB Output is correct
33 Correct 3 ms 16984 KB Output is correct
34 Correct 286 ms 22864 KB Output is correct
35 Correct 298 ms 22216 KB Output is correct
36 Correct 318 ms 22728 KB Output is correct
37 Correct 276 ms 22112 KB Output is correct
38 Correct 184 ms 21704 KB Output is correct
39 Correct 141 ms 20440 KB Output is correct
40 Correct 7 ms 17064 KB Output is correct
41 Correct 12 ms 17216 KB Output is correct
42 Correct 7 ms 17056 KB Output is correct
43 Correct 7 ms 16992 KB Output is correct
44 Correct 358 ms 23376 KB Output is correct
45 Correct 392 ms 22728 KB Output is correct
46 Correct 402 ms 22724 KB Output is correct
47 Correct 402 ms 22724 KB Output is correct
48 Correct 195 ms 22216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16988 KB Output is correct
2 Correct 2 ms 16988 KB Output is correct
3 Correct 2 ms 16988 KB Output is correct
4 Correct 2 ms 16988 KB Output is correct
5 Correct 2 ms 16988 KB Output is correct
6 Correct 2 ms 16988 KB Output is correct
7 Correct 2 ms 16988 KB Output is correct
8 Correct 2 ms 17040 KB Output is correct
9 Correct 3 ms 16988 KB Output is correct
10 Correct 3 ms 16988 KB Output is correct
11 Correct 3 ms 16988 KB Output is correct
12 Correct 2 ms 16988 KB Output is correct
13 Correct 2 ms 16988 KB Output is correct
14 Correct 4 ms 16984 KB Output is correct
15 Correct 3 ms 17000 KB Output is correct
16 Correct 3 ms 16988 KB Output is correct
17 Correct 2 ms 16988 KB Output is correct
18 Correct 3 ms 17044 KB Output is correct
19 Correct 3 ms 16988 KB Output is correct
20 Correct 3 ms 16988 KB Output is correct
21 Correct 3 ms 16988 KB Output is correct
22 Correct 3 ms 16984 KB Output is correct
23 Correct 2 ms 16988 KB Output is correct
24 Correct 3 ms 16984 KB Output is correct
25 Correct 3 ms 16988 KB Output is correct
26 Correct 9 ms 17240 KB Output is correct
27 Correct 12 ms 17244 KB Output is correct
28 Correct 10 ms 17244 KB Output is correct
29 Correct 10 ms 17176 KB Output is correct
30 Correct 7 ms 17160 KB Output is correct
31 Correct 10 ms 17056 KB Output is correct
32 Correct 8 ms 16988 KB Output is correct
33 Correct 6 ms 17060 KB Output is correct
34 Correct 7 ms 17244 KB Output is correct
35 Correct 3 ms 16988 KB Output is correct
36 Correct 4 ms 16988 KB Output is correct
37 Correct 6 ms 17224 KB Output is correct
38 Correct 7 ms 16984 KB Output is correct
39 Correct 4 ms 16988 KB Output is correct
40 Correct 4 ms 17500 KB Output is correct
41 Correct 2 ms 16988 KB Output is correct
42 Correct 3 ms 16988 KB Output is correct
43 Correct 2 ms 16988 KB Output is correct
44 Correct 2 ms 16988 KB Output is correct
45 Correct 3 ms 17048 KB Output is correct
46 Correct 3 ms 17052 KB Output is correct
47 Correct 3 ms 16988 KB Output is correct
48 Correct 3 ms 16988 KB Output is correct
49 Correct 2 ms 16984 KB Output is correct
50 Correct 214 ms 21472 KB Output is correct
51 Correct 120 ms 20184 KB Output is correct
52 Correct 159 ms 20696 KB Output is correct
53 Correct 178 ms 21188 KB Output is correct
54 Correct 178 ms 21112 KB Output is correct
55 Correct 165 ms 20952 KB Output is correct
56 Correct 2 ms 16984 KB Output is correct
57 Correct 2 ms 16988 KB Output is correct
58 Correct 2 ms 16988 KB Output is correct
59 Correct 3 ms 16988 KB Output is correct
60 Correct 4 ms 16988 KB Output is correct
61 Correct 237 ms 22392 KB Output is correct
62 Correct 220 ms 21452 KB Output is correct
63 Correct 147 ms 20440 KB Output is correct
64 Correct 199 ms 21760 KB Output is correct
65 Correct 173 ms 21188 KB Output is correct
66 Correct 3 ms 16988 KB Output is correct
67 Correct 2 ms 16988 KB Output is correct
68 Correct 2 ms 16988 KB Output is correct
69 Correct 3 ms 16988 KB Output is correct
70 Correct 8 ms 16988 KB Output is correct
71 Correct 3 ms 16988 KB Output is correct
72 Correct 3 ms 16984 KB Output is correct
73 Correct 286 ms 22864 KB Output is correct
74 Correct 298 ms 22216 KB Output is correct
75 Correct 318 ms 22728 KB Output is correct
76 Correct 276 ms 22112 KB Output is correct
77 Correct 184 ms 21704 KB Output is correct
78 Correct 141 ms 20440 KB Output is correct
79 Correct 7 ms 17064 KB Output is correct
80 Correct 12 ms 17216 KB Output is correct
81 Correct 7 ms 17056 KB Output is correct
82 Correct 7 ms 16992 KB Output is correct
83 Correct 358 ms 23376 KB Output is correct
84 Correct 392 ms 22728 KB Output is correct
85 Correct 402 ms 22724 KB Output is correct
86 Correct 402 ms 22724 KB Output is correct
87 Correct 195 ms 22216 KB Output is correct
88 Correct 404 ms 25372 KB Output is correct
89 Correct 466 ms 25420 KB Output is correct
90 Correct 474 ms 25288 KB Output is correct
91 Correct 415 ms 25632 KB Output is correct
92 Correct 463 ms 23748 KB Output is correct
93 Correct 466 ms 24260 KB Output is correct
94 Correct 411 ms 23496 KB Output is correct
95 Correct 229 ms 24008 KB Output is correct
96 Correct 297 ms 23752 KB Output is correct
97 Correct 159 ms 23756 KB Output is correct
98 Correct 219 ms 22384 KB Output is correct
99 Correct 255 ms 22472 KB Output is correct