Submission #145026

#TimeUsernameProblemLanguageResultExecution timeMemory
145026alexandra_udristoiuDeda (COCI17_deda)C++14
140 / 140
843 ms8032 KiB
#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 (stderr)

deda.cpp: In function 'int main()':
deda.cpp:40:19: warning: overflow in implicit constant conversion [-Woverflow]
         aint[i] = 10001000000;
                   ^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...