/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 61ms 1.832 MiB
#4 Accepted 130ms 4.566 MiB
#5 Accepted 81ms 3.816 MiB
#6 Accepted 60ms 1.559 MiB
#7 Accepted 1ms 536.0 KiB
#8 Accepted 1ms 324.0 KiB
#9 Accepted 131ms 4.852 MiB
#10 Accepted 170ms 5.98 MiB

Code

#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long

void solve() {
    int n,q;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    set<int> st;
    for(int i = 2; i <= n; i++) {
        if(a[i] < a[i-1]) {
            st.insert(i-1);
        }
    }
    cin >> q;
    while(q--) {
        int op,l,r;
        cin >> op >> l >> r;
        if(op == 1) {
            a[l] = r;
            if(a[l-1] > a[l]) {
                st.insert(l-1);
            } else if(st.find(l-1) != st.end()){
                st.erase(l-1);
            }
            if(l+1 <= n) {
                if(a[l] > a[l+1]) {
                    st.insert(l);
                } else if(st.find(l) != st.end()){
                    st.erase(l);
                }
            }
        } else {
            auto it = st.lower_bound(l);
            if(it == st.end() or *it >= r) cout << "YES\n";
            else cout << "NO\n";
        }
    }
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    // cin >> tc;
    for(int kase = 1; kase <= tc; kase++) {
        //cout << "Case " << kase << ": ";
        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:35:29
Judged At
2024-08-16 17:35:29
Judged By
Score
100
Total Time
170ms
Peak Memory
5.98 MiB