Submission #145026

# Submission time Handle Problem Language Result Execution time Memory
145026 2019-08-18T12:50:27 Z alexandra_udristoiu Deda (COCI17_deda) C++14
140 / 140
843 ms 8032 KB
#include<iostream>
using namespace std;
int n, q, i, x, p, sol;
char t;
int aint[800005];
void update(int nod, int st, int dr, int p, int val){
    if(st == dr){
        aint[nod] = val;
    }
    else{
        int mid = (st + dr) / 2;
        if(p <= mid){
            update(2 * nod, st, mid, p, val);
        }
        else{
            update(2 * nod + 1, mid + 1, dr, p, val);
        }
        aint[nod] = min(aint[2 * nod], aint[2 * nod + 1]);
    }
}
void query(int nod, int st, int dr, int p, int u, int val){
    if(sol != -1){
        return;
    }
    if(st == dr){
        sol = st;
        return;
    }
    int mid = (st + dr) / 2;
    if(p <= mid && aint[2 * nod] <= val){
        query(2 * nod, st, mid, p, u, val);
    }
    if(u > mid && aint[2 * nod + 1] <= val){
        query(2 * nod + 1, mid + 1, dr, p, u, val);
    }
}
int main(){
    cin>> n >> q;
    for(i = 1; i <= 4 * n; i++){
        aint[i] = 10001000000;
    }
    for(; q; q--){
        cin>> t >> x >> p;
        if(t == 'M'){
            update(1, 1, n, p, x);
        }
        else{
            sol = -1;
            query(1, 1, n, p, n, x);
            cout<< sol <<"\n";
        }
    }
}

Compilation message

deda.cpp: In function 'int main()':
deda.cpp:40:19: warning: overflow in implicit constant conversion [-Woverflow]
         aint[i] = 10001000000;
                   ^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 18 ms 380 KB Output is correct
4 Correct 843 ms 8032 KB Output is correct
5 Correct 679 ms 2660 KB Output is correct
6 Correct 736 ms 7064 KB Output is correct
7 Correct 773 ms 7976 KB Output is correct