/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 764.0 KiB
#2 Accepted 2ms 320.0 KiB
#3 Accepted 534ms 2.75 MiB
#4 Accepted 443ms 5.402 MiB
#5 Accepted 364ms 4.641 MiB
#6 Wrong Answer 331ms 2.328 MiB
#7 Accepted 1ms 524.0 KiB
#8 Wrong Answer 1ms 320.0 KiB
#9 Wrong Answer 660ms 5.695 MiB
#10 Wrong Answer 561ms 6.914 MiB

Code

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

void sol(){
    int n;
    cin >> n;
    int a[n];
    for(int &i:a) cin >> i;
    set<int>s;
    for(int i = 0; i < n; i++){
        if(i and a[i] < a[i - 1]) s.insert(i);
    }
    int q;
    cin >> q;
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;
        l--, r--;
        if(t == 2){
            auto it = s.lower_bound(l + 1);
            if(it == s.end() or r - l == 1) cout << "YES" << endl;
            else if(*it > r) cout << "YES" << endl;
            else cout << "NO" << endl;
        }
        else{
            a[l] = r;
            if(n == 1) continue;
            if(l){
                s.erase(l);
               // a[l] = r;
                if(a[l] < a[l - 1]) s.insert(l);
            }
            if(l < n - 1){
                s.erase(l + 1);
                //a[l] = r;
                if(a[l + 1] < a[l]) s.insert(l + 1);
            }
        }
    }
}
signed main(){
    int t = 1;
    //cin >> t;
    while(t--){
        sol();
    }
    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:27:46
Judged At
2024-10-03 13:22:00
Judged By
Score
60
Total Time
660ms
Peak Memory
6.914 MiB