/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 123ms 6.641 MiB
#4 Accepted 142ms 6.328 MiB
#5 Accepted 115ms 6.336 MiB
#6 Accepted 115ms 6.344 MiB
#7 Wrong Answer 1ms 516.0 KiB
#8 Wrong Answer 1ms 532.0 KiB

Code

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

#define int long long 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
#define PB push_back
#define F first
#define S second
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mx_int_prime 999999937
 
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
  
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

 
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
            return os << "(" << p.first << ", " << p.second << ")";
}
 
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
            os << "{";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "}";
}
 
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
 
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << *it;
                                            }
                    return os << "]";
}
 
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
            os << "[";
                for(auto it = v.begin(); it != v.end(); ++it) {
                                if( it != v.begin() ) os << ", ";
                                        os << it -> first << " = " << it -> second ;
                                            }
                    return os << "]";
}
 
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
 
void faltu () {
            cerr << endl;
}
 
template <typename T>
void faltu( T a[], int n ) {
            for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
                cerr << endl;
}
 
template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) {
            cerr << arg << ' ';
                faltu(rest...);
}
 

const int mx=2e5+1;
int a[mx],t[mx*4];

void update(int v,int tl,int tr,int pos)
{
    if(tl==tr){
        if(a[pos]>=a[pos-1]){
            t[v]=1;
        }else t[v]=0;
    }else{
        int tm=(tl+tr)/2;
        if(pos<=tm) update(v*2,tl,tm,pos);
        else update(v*2+1,tm+1,tr,pos);
        t[v]=t[v*2]+t[v*2+1];
    }
}

int query(int v,int tl,int tr,int l,int r)
{
    if(r<tl || l>tr)    return 0;
    else if(tl>=l and tr<=r)    return t[v];
    else{
        int tm=(tl+tr)/2;
        return query(v*2,tl,tm,l,r)+query(v*2+1,tm+1,tr,l,r);
    }
}

signed main()
{
    optimize();
    int n,q,type,idx,val,l,r;
    cin>>n;
    for(int i=1;i<=n;i++)   cin>>a[i];
    for(int i=1;i<=n;i++)   update(1,1,n,i);

    cin>>q;
    while(q--){
        cin>>type;
        if(type==1){
            cin>>idx>>val;
            a[idx]=val;
            update(1,1,n,idx);
            if((idx+1)<=n)update(1,1,n,idx+1);
        }else{
            cin>>l>>r;
            int ret=query(1,1,n,l,r);
            (ret==(r-l+1))?  cout<<"YES"<<endl : cout<<"NO"<<endl;
        }
    }

    return 0;
}
 

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Contest
Bangladesh 2.0
Language
C++17 (G++ 13.2.0)
Submit At
2024-08-16 17:04:04
Judged At
2024-11-11 03:12:56
Judged By
Score
60
Total Time
142ms
Peak Memory
6.641 MiB