/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Accepted 60ms 1.828 MiB
#4 Accepted 142ms 4.574 MiB
#5 Accepted 86ms 3.906 MiB
#6 Accepted 60ms 1.445 MiB
#7 Accepted 1ms 320.0 KiB
#8 Wrong Answer 1ms 352.0 KiB
#9 Wrong Answer 152ms 4.926 MiB
#10 Wrong Answer 203ms 6.039 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);
        }
    }
    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:34:01
Judged At
2024-10-03 13:21:31
Judged By
Score
60
Total Time
203ms
Peak Memory
6.039 MiB