/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 432.0 KiB
#2 Wrong Answer 1ms 332.0 KiB
#3 Accepted 62ms 1.906 MiB
#4 Accepted 174ms 7.145 MiB
#5 Accepted 114ms 6.023 MiB
#6 Accepted 66ms 1.363 MiB
#7 Accepted 2ms 320.0 KiB
#8 Wrong Answer 1ms 324.0 KiB
#9 Wrong Answer 201ms 7.57 MiB
#10 Wrong Answer 266ms 9.242 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 - 1] <= v[i] && v[i] <= v[i + 1]) continue;
    st.insert(i);
  }
  
  int q;
  cin >> q;
  while(q--) {
    int type, a, b;
    cin >> type >> a >> b;
    
    if(type == 1) {
      v[a - 1] = b;
      for(int i = max(1, a - 1); i < min(n - 1, a + 1); i++) {
        if(v[i - 1] <= v[i] && v[i] <= v[i + 1]) {
          if(st.find(i) != st.end()) st.erase(i);
        }
        else st.insert(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:25:45
Judged At
2024-10-03 13:16:30
Judged By
Score
60
Total Time
266ms
Peak Memory
9.242 MiB