/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 63ms 2.836 MiB
#4 Accepted 213ms 8.121 MiB
#5 Accepted 147ms 6.957 MiB
#6 Wrong Answer 82ms 2.367 MiB
#7 Accepted 1ms 532.0 KiB
#8 Wrong Answer 1ms 324.0 KiB

Code

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
#define sz(x) (ll)(x).size()
#define rd ({ll x; cin >> x; x; })
#define dbg(x) cerr << "[" #x "]  " << (x) << "\n\n"
// #define errv(x) {cerr << "["#x"]  ["; for (const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
// #define errvn(x, n) {cerr << "["#x"]  ["; for (auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
// #define cerr if(0)cerr
#define xx first
#define yy second
mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
/*_________________________________________________________________________________________________________________________*/

void Solve()
{
    ll n;
    cin >> n;
    vector<ll> arr(n + 2, 0);
    arr[n + 1] = LLONG_MAX;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    set<ll> problems;
    for (int i = 1; i <= n; i++) {
        if (!(arr[i - 1] <= arr[i] && arr[i] <= arr[i + 1]))
            problems.insert(i);
    }
    ll q;
    cin >> q;
    while (q--) {
        ll qr, x, y;
        cin >> qr >> x >> y;
        if (qr == 2) {
            auto it = problems.lower_bound(x + 1);
            if (it == problems.end() || *it >= y)
                cout << "YES\n";
            else
                cout << "NO\n";
        } else {
            problems.erase(x - 1);
            problems.erase(x);
            problems.erase(x + 1);
            arr[x] = y;
            if (x - 1 > 0) {
                if (!(arr[x - 2] <= arr[x - 1] && arr[x - 1] <= arr[x]))
                    problems.insert(x - 1);
            }
            if (x + 1 <= n) {
                if (!(arr[x] <= arr[x + 1] && arr[x + 1] <= arr[x + 2]))
                    problems.insert(x);
            }
            if (!(arr[x - 1] <= arr[x] && arr[x] <= arr[x + 1]))
                problems.insert(x);
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i << ": "; // cout << "Case " << i << ": ";
        Solve();
    }
    return 0;
}
// Coded by Tahsin Arafat (@TahsinArafat)

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 16:37:58
Judged At
2024-11-11 03:14:24
Judged By
Score
60
Total Time
213ms
Peak Memory
8.121 MiB