# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
929137 |
2024-02-17T18:34:26 Z |
sondos225 |
Deda (COCI17_deda) |
C++17 |
|
8 ms |
16476 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define yes "YES"
#define no "NO"
#define bigg INT_MAX
#define debug(x) cout<<(#x)<<" = " <<x<<endl;
#define all(x) x.begin(),x.end()
#define sz size()
#define nn '\n'
#define mms(x,y) memset(x,y,sizeof(x))
#define forr(i,j,n) for (int i=j; i<n; i++)
#define forn(i,j,n) for (int i=j; i>n; i--)
#define fi first
#define se second
#define la "LA"
#define cinn(x,y) for(int i=0; i<y; i++) cin>>x[i];
#define pii pair<int,int>
#define tii tuple<int,int,int>
pii seg[500000];
void edit(int ll, int rr, int i, int idx, int val)
{
if (ll==rr && ll==idx)
{
if (val<seg[i].fi)
{
seg[i]={val,idx};
}
else if (val==seg[i].fi) seg[i].se=min(idx,seg[i].se);
return;
}
int m=(ll+rr)/2;
if (idx<=m)
{
edit(ll,m,(2*i)+1,idx, val);
}
else edit(m+1,rr,(2*i)+2,idx,val);
seg[i]=min(seg[(2*i)+1],seg[(2*i)+2]);
return;
}
int query(int ll, int rr, int i, int l, int val)
{int m=(ll+rr)/2;
int mn=seg[i].fi;
int idx=seg[i].se;
if (mn<=val && idx>=l) return min(idx,min(query(m+1,rr,(i*2)+2,l,val),query(ll,m,(i*2)+1,l,val)));
if (mn>val) return bigg;
if (l>m) return query(m+1,rr,(i*2)+2,l,val);
return min(query(m+1,rr,(i*2)+2,l,val),query(ll,m,(i*2)+1,l,val));
}
signed main()
{
// #ifndef LOCAL
// freopen("helpcross.in","r",stdin);
// freopen("helpcross.out","w", stdout);
// #endif
fast
forr(i,0,500000) seg[i]={bigg,0};
int n,q;
cin>>n >>q;
while(q--)
{
char w;
int x,y;
cin>>w >>x >>y;
if (w=='M')
{
edit(1,n,0,y,x);
}
else
{
int ans=query(1,n,0,y,x);
if (ans==bigg) ans=-1;
cout<<ans<<nn;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8284 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
8 ms |
8284 KB |
Output is correct |
4 |
Runtime error |
8 ms |
16476 KB |
Execution killed with signal 11 |
5 |
Runtime error |
8 ms |
16476 KB |
Execution killed with signal 11 |
6 |
Runtime error |
8 ms |
16392 KB |
Execution killed with signal 11 |
7 |
Runtime error |
8 ms |
16476 KB |
Execution killed with signal 11 |