/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 560.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 59ms 2.742 MiB
#4 Accepted 213ms 8.129 MiB
#5 Accepted 141ms 6.953 MiB
#6 Wrong Answer 79ms 2.379 MiB
#7 Accepted 1ms 320.0 KiB
#8 Wrong Answer 1ms 532.0 KiB
#9 Wrong Answer 188ms 8.355 MiB
#10 Wrong Answer 285ms 9.992 MiB

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-10-03 13:26:28
Judged By
Score
60
Total Time
285ms
Peak Memory
9.992 MiB