/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 63ms 2.82 MiB
#4 Accepted 63ms 2.809 MiB
#5 Accepted 55ms 2.82 MiB
#6 Wrong Answer 56ms 2.82 MiB
#7 Wrong Answer 2ms 496.0 KiB
#8 Wrong Answer 1ms 320.0 KiB
#9 Wrong Answer 74ms 2.812 MiB
#10 Wrong Answer 77ms 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-10-03 13:21:11
Judged By
Score
30
Total Time
77ms
Peak Memory
2.82 MiB