Submission #1004026

# Submission time Handle Problem Language Result Execution time Memory
1004026 2024-06-21T02:22:22 Z edogawa_something Team Contest (JOI22_team) C++17
37 / 100
2000 ms 195804 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first 
#define S second 
#define all(v) v.begin(),v.end()
#define pb push_back
#define pow poww
const int M=5100;
const ll mod=998244353;
const ll inf=2e18;
const ll dx[]={1,-1,0,0};
const ll dy[]={0,0,1,-1};
ll pow(ll x,ll y){
  ll res=1;
  x%=mod;
  while(y>0){
    if(y%2==1){
      res*=x,res%=mod;
    }
    x*=x,x%=mod;
    y/=2;
  }
  return res;
}
ll n,ma[M][M],a[M],b[M],c[M],rv1[M],rv2[M],rv3[M];
int main(){
  ios_base::sync_with_stdio(0),cin.tie(0);
  ll TC=1;
  //cin>>TC;
  while(TC--){
    cin>>n;
    set<ll>s1,s2,s3;
    map<ll,ll>mp;
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i]>>c[i];
      s1.insert(a[i]),s2.insert(b[i]),s3.insert(c[i]);
    }
    ll t=0;
    for(auto it:s1)
    mp[it]=++t,rv1[t]=it;
    for(int i=0;i<n;i++)
    a[i]=mp[a[i]];
    t=0,mp.clear();
    for(auto it:s2)
    mp[it]=++t,rv2[t]=it;
    for(int i=0;i<n;i++)
    b[i]=mp[b[i]];
    mp.clear(),t=0;
    for(auto it:s3)
    mp[it]=++t,rv3[t]=it;
    for(int i=0;i<n;i++)
    c[i]=mp[c[i]];
    mp.clear(),t=0;
    for(int i=0;i<n;i++)
    ma[a[i]][b[i]]=max(ma[a[i]][b[i]],c[i]);
    for(int i=0;i<=n;i++){
      for(int j=1;j<=n;j++)
      ma[i][j]=max(ma[i][j-1],ma[i][j]);
    }
    for(int j=0;j<=n;j++){
      for(int i=1;i<=n;i++)
      ma[i][j]=max(ma[i][j],ma[i-1][j]);
    }
    ll ans=-1;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i==j)
        continue;
        if(a[i]==a[j]||b[i]==b[j])
        continue;
        if(((a[i]>a[j])^(b[i]>b[j]))==0)
        continue;
        if(ma[max(a[i],a[j])-1][max(b[i],b[j])-1]<=max(c[i],c[j]))
        continue;
        ans=max(ans,rv1[max(a[i],a[j])]+rv2[max(b[i],b[j])]+rv3[ma[max(a[i],a[j])-1][max(b[i],b[j])-1]]);
      }
    }
    cout<<ans;
  }
  return 0;
}
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2512 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 2 ms 4188 KB Output is correct
15 Correct 1 ms 3492 KB Output is correct
16 Correct 2 ms 3932 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 2 ms 3932 KB Output is correct
19 Correct 2 ms 4060 KB Output is correct
20 Correct 2 ms 3932 KB Output is correct
21 Correct 1 ms 4060 KB Output is correct
22 Correct 2 ms 3932 KB Output is correct
23 Correct 2 ms 3932 KB Output is correct
24 Correct 1 ms 3932 KB Output is correct
25 Correct 1 ms 4048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2512 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 2 ms 4188 KB Output is correct
15 Correct 1 ms 3492 KB Output is correct
16 Correct 2 ms 3932 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 2 ms 3932 KB Output is correct
19 Correct 2 ms 4060 KB Output is correct
20 Correct 2 ms 3932 KB Output is correct
21 Correct 1 ms 4060 KB Output is correct
22 Correct 2 ms 3932 KB Output is correct
23 Correct 2 ms 3932 KB Output is correct
24 Correct 1 ms 3932 KB Output is correct
25 Correct 1 ms 4048 KB Output is correct
26 Correct 476 ms 143148 KB Output is correct
27 Correct 368 ms 141196 KB Output is correct
28 Correct 320 ms 142416 KB Output is correct
29 Correct 299 ms 141404 KB Output is correct
30 Correct 141 ms 68180 KB Output is correct
31 Correct 290 ms 142024 KB Output is correct
32 Correct 267 ms 142108 KB Output is correct
33 Correct 211 ms 131152 KB Output is correct
34 Correct 242 ms 142540 KB Output is correct
35 Correct 10 ms 11868 KB Output is correct
36 Correct 9 ms 11868 KB Output is correct
37 Correct 238 ms 142408 KB Output is correct
38 Correct 231 ms 142416 KB Output is correct
39 Correct 75 ms 40796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Execution timed out 2101 ms 195804 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Execution timed out 2101 ms 195804 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Execution timed out 2101 ms 195804 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Execution timed out 2101 ms 195804 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2512 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2512 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 2 ms 4188 KB Output is correct
15 Correct 1 ms 3492 KB Output is correct
16 Correct 2 ms 3932 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 2 ms 3932 KB Output is correct
19 Correct 2 ms 4060 KB Output is correct
20 Correct 2 ms 3932 KB Output is correct
21 Correct 1 ms 4060 KB Output is correct
22 Correct 2 ms 3932 KB Output is correct
23 Correct 2 ms 3932 KB Output is correct
24 Correct 1 ms 3932 KB Output is correct
25 Correct 1 ms 4048 KB Output is correct
26 Correct 476 ms 143148 KB Output is correct
27 Correct 368 ms 141196 KB Output is correct
28 Correct 320 ms 142416 KB Output is correct
29 Correct 299 ms 141404 KB Output is correct
30 Correct 141 ms 68180 KB Output is correct
31 Correct 290 ms 142024 KB Output is correct
32 Correct 267 ms 142108 KB Output is correct
33 Correct 211 ms 131152 KB Output is correct
34 Correct 242 ms 142540 KB Output is correct
35 Correct 10 ms 11868 KB Output is correct
36 Correct 9 ms 11868 KB Output is correct
37 Correct 238 ms 142408 KB Output is correct
38 Correct 231 ms 142416 KB Output is correct
39 Correct 75 ms 40796 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Execution timed out 2101 ms 195804 KB Time limit exceeded
51 Halted 0 ms 0 KB -