Submission #42330

#TimeUsernameProblemLanguageResultExecution timeMemory
42330milmillinDeda (COCI17_deda)C++14
20 / 140
139 ms3808 KiB
#include <cstdio> #include <vector> #include <cstring> using namespace std; int seg[600100]; void update(int idx,int l,int r,int k,int val) { if (k<l||k>=r) return; if (l+1==r) { seg[idx]=val; return; } int m = (l+r)>>1; update(idx*2,l,m,k,val); update(idx*2+1,m,r,k,val); seg[idx]=min(seg[idx*2],seg[idx*2+1]); //printf("++ %d %d %d\n",l,r,seg[idx]); } int get(int idx,int l,int r,int ll,int rr,int k) { //printf("gg %d %d %d %d %d %d\n",l,r,ll,rr,k,seg[idx]); if (ll>=r||rr<=l) return 2e9; if (l+1==r) return (seg[idx]<=k)?l:2e9; int m = (l+r)>>1; if (ll>=m) { return get(idx*2+1,m,r,ll,rr,k); } else if (rr<=m) { return get(idx*2,l,m,ll,rr,k); } else { if (seg[idx*2]<=k) return get(idx*2,l,m,ll,rr,k); else if (seg[idx*2+1]<=k) return get(idx*2+1,m,r,ll,rr,k); else return 2e9; } } int main () { int n,q; scanf("%d%d",&n,&q); memset(seg,63,sizeof(seg)); char x; int a,b; for (int i=0;i<q;i++) { scanf(" %c%d%d",&x,&a,&b); if (x=='M') { update(1,1,n+1,b,a); } else { int tmp = get(1,1,n+1,b,n+1,a); printf("%d\n",(tmp==2e9)?-1:tmp); } } return 0; }

Compilation message (stderr)

deda.cpp: In function 'int main()':
deda.cpp:40:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&q);
                     ^
deda.cpp:45:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c%d%d",&x,&a,&b);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...