Submission #85544

# Submission time Handle Problem Language Result Execution time Memory
85544 2018-11-20T21:06:28 Z memetkagan44 Deda (COCI17_deda) C++11
140 / 140
152 ms 18384 KB
#include<bits/stdc++.h>
using namespace std;
int n,q,a,b,ar[800005];
char tur;
void upd(int ara,int x,int i,int l,int r){
    ar[i]=min(ar[i],x);
    if(l==r)
        return;
    int mid=(l+r)/2;
    if(ara<=mid)
        upd(ara,x,2*i,l,mid);
    else
        upd(ara,x,2*i+1,mid+1,r);
}
int qry(int ara,int x,int i,int l,int r){
    if(ar[i]>x)
        return -2;
    if(l==r)
        return l;
    int mid=(l+r)/2;
    int res=-2;
    if(ara<=mid)
        res=qry(ara,x,2*i,l,mid);
    if(res==-2)
        res=qry(ara,x,2*i+1,mid+1,r);
    return res;
}
int main(){
    scanf("%d %d",&n,&q);
    memset(ar,0x3f,sizeof(ar));
    while(q--){
        scanf(" %c %d %d",&tur,&a,&b);
        if(tur=='M')
            upd(b-1,a,1,0,n-1);
        else
            printf("%d\n",qry(b-1,a,1,0,n-1)+1);
    }
    return 0;
}

Compilation message

deda.cpp: In function 'int main()':
deda.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&q);
     ~~~~~^~~~~~~~~~~~~~~
deda.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c %d %d",&tur,&a,&b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 7 ms 3616 KB Output is correct
4 Correct 138 ms 8248 KB Output is correct
5 Correct 140 ms 11304 KB Output is correct
6 Correct 141 ms 14808 KB Output is correct
7 Correct 152 ms 18384 KB Output is correct