# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472878 |
2021-09-14T12:37:30 Z |
MamdouhN |
Deda (COCI17_deda) |
C++14 |
|
1000 ms |
3972 KB |
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
int ar [200005],seg[800005];
int uwu = 927168292;
void update(int idx,int st,int en,int i,int value)
{
if(en<i||st>i)return;
if(st==en)
{
seg[idx] = ar[i] = value;
return;
}
int mid = (st+en)/2;
update(idx*2,st,mid,i,value);
update(idx*2+1,mid+1,en,i,value);
seg[idx]=min(seg[idx*2],seg[idx*2+1]);
}
int query(int idx,int st,int en,int qs,int qe,int y)
{
if(en<qs||st>qe)return uwu;
if(seg[idx]>y)return uwu;
if(st==en)return (seg[idx]==-1?uwu:st);
int mid = (st+en)/2;
int left = query(idx*2,st,mid,qs,qe,y);
int right = query(idx*2+1,mid+1,en,qs,qe,y);
return min(left,right);
}
main()
{
memset(seg,-1,sizeof seg);
int n,q;
cin>>n>>q;
while(q--)
{
char c;
int a,b;
cin>>c>>a>>b;
if(c=='M')
{
update(1,0,n,b,a);
}
else
{
int ans = query(1,0,n,b,n,a);
cout<<(ans==uwu ? -1:ans)<<endl;
}
}
}
Compilation message
deda.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
33 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3404 KB |
Output is correct |
2 |
Correct |
5 ms |
3404 KB |
Output is correct |
3 |
Correct |
34 ms |
3440 KB |
Output is correct |
4 |
Execution timed out |
1090 ms |
3424 KB |
Time limit exceeded |
5 |
Execution timed out |
1073 ms |
3808 KB |
Time limit exceeded |
6 |
Execution timed out |
1098 ms |
3944 KB |
Time limit exceeded |
7 |
Execution timed out |
1091 ms |
3972 KB |
Time limit exceeded |