# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
918911 |
2024-01-30T18:00:40 Z |
mychecksedad |
Deda (COCI17_deda) |
C++17 |
|
49 ms |
3156 KB |
/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
int n, q, T[N];
void build(int l, int r, int k){
if(l == r){
T[k] = MOD;
return;
}
int m = l+r>>1;
build(l, m, k<<1);
build(m+1, r, k<<1|1);
T[k] = 0;
}
void upd(int l, int r, int p, int k, int val){
if(l == r){
T[k] = val;
return;
}
int m = l+r>>1;
if(p <= m) upd(l, m, p, k<<1, val);
else upd(m+1, r, p, k<<1|1, val);
T[k] = min(T[k<<1], T[k<<1|1]);
}
int get(int l, int r, int p, int k, int val){
if(l == r){
return l;
}
int m = l+r>>1;
int v = -1;
if(m >= p && T[k<<1] <= val)
v = get(l, m, p, k<<1, val);
// if(v != -1)
return v;
// if(T[k<<1|1] > val) return -1;
// return get(m+1, r, p, k<<1|1, val);
}
void solve(){
cin >> n >> q;
build(1, n, 1);
for(int i = 0; i < q; ++i){
char c; cin >> c;
if(c == 'M'){
int X, A; cin >> X >> A;
upd(1, n, A, 1, X);
}else{
int B, Y; cin >> Y >> B;
cout << get(1, n, B, 1, Y) << '\n';
}
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(tt--){
solve();
en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
deda.cpp: In function 'void build(int, int, int)':
deda.cpp:18:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
18 | int m = l+r>>1;
| ~^~
deda.cpp: In function 'void upd(int, int, int, int, int)':
deda.cpp:28:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
28 | int m = l+r>>1;
| ~^~
deda.cpp: In function 'int get(int, int, int, int, int)':
deda.cpp:37:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
37 | int m = l+r>>1;
| ~^~
deda.cpp: In function 'int main()':
deda.cpp:65:15: warning: unused variable 'aa' [-Wunused-variable]
65 | int tt = 1, aa;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
48 ms |
3156 KB |
Output isn't correct |
5 |
Incorrect |
49 ms |
2896 KB |
Output isn't correct |
6 |
Incorrect |
49 ms |
2932 KB |
Output isn't correct |
7 |
Incorrect |
49 ms |
3152 KB |
Output isn't correct |