/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 328.0 KiB
#2 Wrong Answer 3ms 540.0 KiB
#3 Accepted 475ms 15.0 MiB
#4 Accepted 443ms 14.594 MiB
#5 Accepted 332ms 14.582 MiB
#6 Accepted 328ms 14.566 MiB
#7 Accepted 2ms 332.0 KiB
#8 Wrong Answer 2ms 500.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll md = 1e9+7;
void fxd(int i,int j,int l,int r,ll ara[],ll seg[],ll dp[],int node){
    if(i>r||j<l)return;
if(i==j){
    seg[node]=ara[i];
    dp[i]=1;
    return;
}
int mid=(i+j)/2;
fxd(i,mid,l,r,ara,seg,dp,node*2);
fxd(mid+1,j,l,r,ara,seg,dp,node*2+1);
if(!dp[node*2]||!dp[node*2+1]||seg[node*2]>seg[node*2+1])dp[node]=0;
seg[node]=max(seg[node*2],seg[node*2+1]);

}
int fnd(int i,int j,int l,int r,ll seg[],ll dp[],ll node){
    if(i>r||j<l)return 1;
    if(i>=l&&j<=r)return dp[node];
    int mid=(i+j)/2;
    int x=fnd(i,mid,l,r,seg,dp,node*2);
     int y=fnd(mid+1,j,l,r,seg,dp,node*2+1);
     if(!x||!y)return 0;
     else return 1;
}
void solve() {
   int n;
   cin>>n;
   ll ara[n+1];
   for(int i=1;i<=n;i++)cin>>ara[i];
   ll seg[4*n+10];
   ll dp[4*n+10];
   for(int i=1;i<4*n+10;i++)dp[i]=1;
   fxd(1,n,1,n,ara,seg,dp,1);
   int q;
   cin>>q;
   while(q--){
    int a;
    cin>>a;
    if(a==1){
        int i;ll x;
        cin>>i>>x;
        ara[i]=x;
        fxd(1,n,i,i,ara,seg,dp,1);
    }
    else{
        int l,r;
        cin>>l>>r;
        int ans=fnd(1,n,l,r,seg,dp,1);
        if(ans)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
   }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
     T=1;//cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 16:44:54
Judged At
2024-11-11 03:14:05
Judged By
Score
60
Total Time
475ms
Peak Memory
15.0 MiB