/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Runtime Error free(): invalid pointer 2ms 580.0 KiB
#3 Runtime Error free(): invalid pointer 66ms 2.316 MiB
#4 Runtime Error free(): invalid pointer 25ms 4.52 MiB
#5 Runtime Error free(): invalid pointer 22ms 3.77 MiB
#6 Time Exceeded ≥2095ms ≥1.277 MiB
#7 Accepted 2ms 492.0 KiB
#8 Accepted 1ms 540.0 KiB
#9 Accepted 137ms 4.836 MiB
#10 Runtime Error free(): invalid pointer 43ms 6.062 MiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
const ll MOD = 1e9 + 7;

void solve()
{
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  set<int>st;
  for(int i = 1; i < n - 1; i++) {
    if(v[i] < v[i - 1]) {
      st.insert(i);
    }
  }
  
  int q;
  cin >> q;
  while(q--) {
    int type, a, b;
    cin >> type >> a >> b;
    a--;

    if(type == 1) {
      v[a] = b;
      for(int i = max(1, a); i < min(n - 1, a + 2); i++) {
        if(v[i] < v[i - 1]) st.insert(i);
        else {
          st.erase(st.find(i));
        }
      }
    }
    else {
      a++;
      b--;
      auto it = st.lower_bound(a);
      if(it != st.end() and *it <= b) cout << "NO" << "\n";
      else cout << "YES" << "\n";
    }
  }
}

int main()
{
  ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  solve();
}

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-18 10:50:15
Judged At
2024-08-20 16:38:31
Judged By
Score
40
Total Time
2095ms
Peak Memory
6.062 MiB