/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 1ms 536.0 KiB
#3 Wrong Answer 69ms 2.816 MiB

Code

/*
    BISMILLAHIR RAHMANIR RAHIM
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
vector<int> prefix;
#define dbg(x) cout<<#x<<" "<<x<<endl;
void p(int n,vector<int> v)
{ 
    prefix.resize(n + 1, 0);
    prefix[0] = 1;
    for (int i = 1; i < n; ++i) {
        if (v[i] >= v[i - 1]) {
            prefix[i] = prefix[i - 1] + 1;
        } else {
            prefix[i] = 1;
        }
    }
}
void solve()
{
    int n;cin>>n;
    vector<int> v(n);
    for(auto &it:v)
    {
        cin>>it;
    }
     p(n,v);
    int q;cin>>q;
    // dbg(q);
    // cout<<q<<endl;
    while(q--){
        int t;cin>>t;
        if(t==1)
        {
            int i, x;
            cin >> i >> x;
            --i; 
            v[i] = x;
            if (i > 0) {
                if (v[i] >= v[i - 1]) {
                    prefix[i] = prefix[i - 1] + 1;
                } else {
                    prefix[i] = 1;
                }
            }
            if (i < n - 1) {
                if (v[i + 1] >= v[i]) {
                    prefix[i + 1] = prefix[i] + 1;
                } else {
                    prefix[i + 1] = 1;
                }
            }
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--;r--;
            
            if (prefix[r] == (r - l + 1)) {
                cout << "YES" << endl;
            } else {
                cout << "NO" << endl;
            }
        }
    }
    prefix.clear();
    v.clear();
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int 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 17:40:17
Judged At
2024-11-11 03:11:08
Judged By
Score
10
Total Time
69ms
Peak Memory
2.816 MiB