# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
941658 |
2024-03-09T09:02:39 Z |
blacktulip |
Deda (COCI17_deda) |
C++17 |
|
93 ms |
6348 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
//~ #define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
#define _ << " " <<
const lo inf = 1000000001;
const lo li = 200005;
const lo mod = 1000000007;
int n,m,k,flag,t,x[li],y[li],tree[li*4];
int cev;
char c[li];
string s;
vector<int> vec;
//~ set<int> st[li*2];
inline void update(int node,int start,int end,int l,int r,int x){
if(start>end || start>r || end<l)return ;
if(start>=l && end<=r){tree[node]=x;return ;}
update(node*2,start,mid,l,r,x),update(node*2+1,mid+1,end,l,r,x);
tree[node]=min(tree[node*2],tree[node*2+1]);
}
inline void query(int node,int start,int end,int b,int y){
if(end<b)return ;
if(tree[node]>y)return ;
if(cev!=inf)return ;
if(start==end){cev=start;return ;}
query(node*2,start,mid,b,y),query(node*2+1,mid+1,end,b,y);
}
int main(void){
fio();
cin>>n>>t;
for(int i=1;i<=t;i++){
cin>>c[i]>>x[i]>>y[i];
}
FOR update(1,1,n,i,i,inf);
for(int i=1;i<=t;i++){
if(c[i]=='M'){
update(1,1,n,y[i],y[i],x[i]);
}
else{
cev=inf;
query(1,1,n,y[i],x[i]);
if(cev==inf)cev=-1;
cout<<cev<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Correct |
3 ms |
4444 KB |
Output is correct |
4 |
Correct |
85 ms |
6348 KB |
Output is correct |
5 |
Correct |
83 ms |
6232 KB |
Output is correct |
6 |
Correct |
87 ms |
6228 KB |
Output is correct |
7 |
Correct |
93 ms |
6228 KB |
Output is correct |