/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 340.0 KiB
#3 Accepted 64ms 1.875 MiB
#4 Accepted 149ms 4.613 MiB
#5 Accepted 87ms 3.777 MiB
#6 Accepted 62ms 1.516 MiB
#7 Accepted 1ms 444.0 KiB
#8 Accepted 1ms 444.0 KiB
#9 Accepted 146ms 4.988 MiB
#10 Accepted 210ms 6.195 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-11-11 03:11:18
Judged By
Score
100
Total Time
210ms
Peak Memory
6.195 MiB