Submission #929037

# Submission time Handle Problem Language Result Execution time Memory
929037 2024-02-17T14:24:22 Z NourWael Deda (COCI17_deda) C++17
0 / 140
77 ms 19748 KB
#include <bits/stdc++.h>
#define int long long
using namespace std; 
int const mxN = 2e5+5;
int n,q, seg[8*mxN], a[8*mxN];

int get ( int node, int l_n, int r_n, int l, int r, int v) {
   if(l_n>=r || r_n<=l) return 1e17;
   if(l_n==r_n-1) return l_n;
   int m = (l_n+r_n)/2;
   if(seg[node*2+1]<=v && m>l) return get(node*2+1, l_n, m, l, r, v );
   else return get(node*2+2, m, r_n, l, r, v );
}

void update(int node, int l, int r, int x, int v ) {
   if(l==r-1) { seg[node] = v; return; }
   int m = (l+r)/2;
   if(x<m) update(node*2+1, l, m, x, v);
   else update(node*2+2, m, r, x, v);
   seg[node] = min(seg[node*2+1], seg[node*2+2]);
}

signed main() {
  
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);

  cin>>n>>q;
  int pw = (1<<(__lg(n-1)+1));
  for(int i=0; i<8*mxN; i++) seg[i] = 1e17;
  for(int i=1; i<=n; i++) a[i] = 1e17;
  
  for(int i=0; i<q; i++) {
   char c; cin>>c;
   if(c=='M') {
       int x,a; cin>>x>>a;
       update(0,0,pw,a,x);
   }
   else  {
      int rides,b; cin>>rides>>b;
      int ans = get(0,0,pw,b,n+1, rides);
      cout<<(ans==1e17? -1:ans)<<'\n';
   }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 12888 KB Output isn't correct
2 Incorrect 3 ms 12892 KB Output isn't correct
3 Incorrect 4 ms 13020 KB Output isn't correct
4 Incorrect 57 ms 19748 KB Output isn't correct
5 Incorrect 72 ms 19280 KB Output isn't correct
6 Incorrect 68 ms 19536 KB Output isn't correct
7 Incorrect 77 ms 19636 KB Output isn't correct