Submission #950387

# Submission time Handle Problem Language Result Execution time Memory
950387 2024-03-20T09:12:15 Z ezzzay Magic Tree (CEOI19_magictree) C++14
0 / 100
42 ms 13340 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define inf LLONG_MAX
#define ff first
#define ss second
const int N=1e6+5;
int a[N];
int dp[N];
vector<int>ans;
int par[N];
int n,m,k;
int fun(int l, int r, int x){
    
    for(int i=0;i<N;i++){
        dp[i]=0;
    }
    int b[N];
    for(int i=1;i<=n;i++){
        if(l<=i and i<=r)b[i]=a[i]-x;
        else b[i]=a[i];
    }
    int s=0;
    for(int i=1;i<=n;i++)dp[i]=1;
    for(int i=2;i<=n;i++){
        for(int j=i-1;j>=1;j--){
            if(b[i]>b[j])dp[i]=max(dp[i],dp[j]+1);
            s=max(s,dp[i]);
        }
    }
    return s;
}
int st[4*N];
void update(int node, int L, int R, int idx, int val){
    if(L==R){
        st[node]=val;
        return ;
    }
    int mid=(L+R)/2;
    if(L<=idx and idx<=mid){
        update(node*2,L,mid,idx,val);
    }
    else {
        update(node*2+1,mid+1,R,idx,val);
    }
    st[node]=max(st[node*2],st[node*2+1]);
}
int find(int node, int L , int R, int l, int r){
    if(l>R or L>r)return 0;
    if(l<=L and R<=r)return st[node];
    int mid=(L+R)/2;
    return max( find(node*2,L,mid,l,r) , find(node*2+1,mid+1,R,l,r)) ;
}
void sbtsk4(){
    map<int,int>mp;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]];
    }
    int ans=0;
    int idx=1;
    for(auto it=mp.begin();it!=mp.end();it++){
        it->ss = idx++;
    }
    for(int i=1;i<=n;i++)a[i]=mp[a[i]];
    for(int i=1;i<=n;i++){
        dp[i]= find(1,1,n,1,a[i]-1)+1;
        dp[i]=max(dp[i],1LL);
        ans=max(dp[i],ans);
        update(1,1,n,a[i],dp[i]);
    }
    cout<<ans;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    for(int i=2;i<=n;i++){
        cin>>par[i];
    }
    int s=0;
    for(int i=1;i<=m;i++){
        int v,w,d;
        cin>>v>>d>>w;
        a[n-v+1]=d;
    }
    sbtsk4();
    
    
}

Compilation message

magictree.cpp: In function 'int main()':
magictree.cpp:83:9: warning: unused variable 's' [-Wunused-variable]
   83 |     int s=0;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 13340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 12016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -