/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 720.0 KiB
#2 Accepted 2ms 328.0 KiB
#3 Accepted 116ms 1.902 MiB
#4 Accepted 193ms 4.676 MiB
#5 Accepted 139ms 3.789 MiB
#6 Accepted 105ms 1.602 MiB
#7 Accepted 2ms 332.0 KiB
#8 Accepted 2ms 520.0 KiB
#9 Accepted 200ms 5.0 MiB
#10 Accepted 274ms 6.188 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-10-03 13:21:23
Judged By
Score
100
Total Time
274ms
Peak Memory
6.188 MiB