//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2")
#include<bits/stdc++.h>
//#define int long long
//#define ll long long
#define down cout<<'\n';
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
void phongbeo();
const int mod2=1e9+7;
const int mod1=998244353;
struct icd
{
int a,b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a,b;
long long c;
};
struct id
{
int a,b,c,d;
};
struct ie
{
int a,b,c, d,e,f;
};
int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
// fin(task),fou(task);
#endif
NHP;
/// cin>>s1;
// modwwe
phongbeo();
}
ic t[400001];
int a[100001];
void build(int node,int l,int r)
{
if(l==r) {t[node].a=a[l],t[node].b=l;t[node].c=a[l];return;}
int mid=l+r>>1;
build(node<<1,l,mid);
build(node<<1|1,mid+1,r);
t[node]=t[node<<1|1];
if(t[node<<1].a>=t[node<<1|1].a)
t[node]=t[node<<1];
t[node].c=t[node<<1].c+t[node<<1|1].c;
}
void upd(int node,int l,int r,int l1,int r1,int c)
{
if(l>r1||r<l1) return;
if(l>=l1&&r<=r1) {t[node].a=c,t[node].c=c; return;}
int mid=l+r>>1;
upd(node<<1,l,mid,l1,r1,c);
upd(node<<1|1,mid+1,r,l1,r1,c);
t[node]=t[node<<1|1];
if(t[node<<1].a>=t[node<<1|1].a)
t[node]=t[node<<1];
t[node].c=t[node<<1].c+t[node<<1|1].c;
}
ib get(int node,int l,int r,int l1,int r1)
{
if(l>r1||r<l1) return{0,0};
if(l>=l1&&r<=r1) return {t[node].a,t[node].b};
int mid=l+r>>1;
ib ss3=get(node<<1,l,mid,l1,r1);
ib ss4=get(node<<1|1,mid+1,r,l1,r1);
if(ss3.a>=ss4.a) return ss3;
else return ss4;
}
long long get_c(int node,int l,int r,int l1,int r1)
{
if(l>r1||r<l1) return 0;
if(l>=l1&&r<=r1) return t[node].c;
int mid=l+r>>1;
return get_c(node<<1,l,mid,l1,r1)+get_c(node<<1|1,mid+1,r,l1,r1);
}
void calc(int l,int r)
{ s4++;
if(l>=r) return ;
ib sx=get(1,1,n,l,r);
if(sx.b!=l)
{
long long s3=get_c(1,1,n,l,sx.b-1);
if(s3>=sx.a) calc(l,sx.b-1);
}
if(sx.b!=r)
{
long long s3=get_c(1,1,n,sx.b+1,r);
if(s3>=sx.a) calc(sx.b+1,r);
}
return;
}
void phongbeo()
{
cin>> n;
for(int i=1;i<=n;i++)
cin>>a[i];
build(1,1,n);
cin>>m;
for(int i=1;i<=m;i++)
{
cin>>l;
if(l==1)
{
cin>>l>>r;
upd(1,1,n,l,l,r);
}
else { cin>>l>>r;
s4=0;
calc(l,r);
cout<<s4,down
}
}
}
Compilation message
fish2.cpp:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
47 | main()
| ^~~~
fish2.cpp: In function 'void build(int, int, int)':
fish2.cpp:63:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
63 | int mid=l+r>>1;
| ~^~
fish2.cpp:67:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
67 | if(t[node<<1].a>=t[node<<1|1].a)
| ^~
fish2.cpp:69:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
69 | t[node].c=t[node<<1].c+t[node<<1|1].c;
| ^
fish2.cpp: In function 'void upd(int, int, int, int, int, int)':
fish2.cpp:75:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
75 | int mid=l+r>>1;
| ~^~
fish2.cpp: In function 'ib get(int, int, int, int, int)':
fish2.cpp:88:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
88 | int mid=l+r>>1;
| ~^~
fish2.cpp: In function 'long long int get_c(int, int, int, int, int)':
fish2.cpp:98:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
98 | int mid=l+r>>1;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
5 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2512 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
6 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
7 ms |
6684 KB |
Output is correct |
3 |
Correct |
5 ms |
6748 KB |
Output is correct |
4 |
Correct |
8 ms |
6748 KB |
Output is correct |
5 |
Correct |
5 ms |
6748 KB |
Output is correct |
6 |
Correct |
19 ms |
6792 KB |
Output is correct |
7 |
Correct |
6 ms |
6744 KB |
Output is correct |
8 |
Correct |
19 ms |
6748 KB |
Output is correct |
9 |
Correct |
5 ms |
6748 KB |
Output is correct |
10 |
Correct |
7 ms |
6748 KB |
Output is correct |
11 |
Correct |
4 ms |
6788 KB |
Output is correct |
12 |
Correct |
5 ms |
6748 KB |
Output is correct |
13 |
Correct |
6 ms |
6748 KB |
Output is correct |
14 |
Correct |
13 ms |
6780 KB |
Output is correct |
15 |
Correct |
15 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
5 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2512 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
6 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
7 ms |
6684 KB |
Output is correct |
23 |
Correct |
5 ms |
6748 KB |
Output is correct |
24 |
Correct |
8 ms |
6748 KB |
Output is correct |
25 |
Correct |
5 ms |
6748 KB |
Output is correct |
26 |
Correct |
19 ms |
6792 KB |
Output is correct |
27 |
Correct |
6 ms |
6744 KB |
Output is correct |
28 |
Correct |
19 ms |
6748 KB |
Output is correct |
29 |
Correct |
5 ms |
6748 KB |
Output is correct |
30 |
Correct |
7 ms |
6748 KB |
Output is correct |
31 |
Correct |
4 ms |
6788 KB |
Output is correct |
32 |
Correct |
5 ms |
6748 KB |
Output is correct |
33 |
Correct |
6 ms |
6748 KB |
Output is correct |
34 |
Correct |
13 ms |
6780 KB |
Output is correct |
35 |
Correct |
15 ms |
6748 KB |
Output is correct |
36 |
Correct |
201 ms |
6744 KB |
Output is correct |
37 |
Correct |
72 ms |
6748 KB |
Output is correct |
38 |
Correct |
51 ms |
6748 KB |
Output is correct |
39 |
Correct |
88 ms |
6748 KB |
Output is correct |
40 |
Correct |
49 ms |
6772 KB |
Output is correct |
41 |
Correct |
2320 ms |
6772 KB |
Output is correct |
42 |
Correct |
3188 ms |
6764 KB |
Output is correct |
43 |
Correct |
12 ms |
6744 KB |
Output is correct |
44 |
Correct |
12 ms |
6748 KB |
Output is correct |
45 |
Correct |
264 ms |
6748 KB |
Output is correct |
46 |
Correct |
379 ms |
6744 KB |
Output is correct |
47 |
Correct |
23 ms |
6744 KB |
Output is correct |
48 |
Correct |
10 ms |
6748 KB |
Output is correct |
49 |
Correct |
46 ms |
6784 KB |
Output is correct |
50 |
Correct |
1306 ms |
6748 KB |
Output is correct |
51 |
Execution timed out |
4066 ms |
6768 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
7 ms |
6684 KB |
Output is correct |
3 |
Correct |
5 ms |
6748 KB |
Output is correct |
4 |
Correct |
8 ms |
6748 KB |
Output is correct |
5 |
Correct |
5 ms |
6748 KB |
Output is correct |
6 |
Correct |
19 ms |
6792 KB |
Output is correct |
7 |
Correct |
6 ms |
6744 KB |
Output is correct |
8 |
Correct |
19 ms |
6748 KB |
Output is correct |
9 |
Correct |
5 ms |
6748 KB |
Output is correct |
10 |
Correct |
7 ms |
6748 KB |
Output is correct |
11 |
Correct |
4 ms |
6788 KB |
Output is correct |
12 |
Correct |
5 ms |
6748 KB |
Output is correct |
13 |
Correct |
6 ms |
6748 KB |
Output is correct |
14 |
Correct |
13 ms |
6780 KB |
Output is correct |
15 |
Correct |
15 ms |
6748 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
3964 ms |
7088 KB |
Output is correct |
18 |
Execution timed out |
4058 ms |
7764 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
7 ms |
6684 KB |
Output is correct |
3 |
Correct |
5 ms |
6748 KB |
Output is correct |
4 |
Correct |
8 ms |
6748 KB |
Output is correct |
5 |
Correct |
5 ms |
6748 KB |
Output is correct |
6 |
Correct |
19 ms |
6792 KB |
Output is correct |
7 |
Correct |
6 ms |
6744 KB |
Output is correct |
8 |
Correct |
19 ms |
6748 KB |
Output is correct |
9 |
Correct |
5 ms |
6748 KB |
Output is correct |
10 |
Correct |
7 ms |
6748 KB |
Output is correct |
11 |
Correct |
4 ms |
6788 KB |
Output is correct |
12 |
Correct |
5 ms |
6748 KB |
Output is correct |
13 |
Correct |
6 ms |
6748 KB |
Output is correct |
14 |
Correct |
13 ms |
6780 KB |
Output is correct |
15 |
Correct |
15 ms |
6748 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Execution timed out |
4085 ms |
6764 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
2 ms |
2392 KB |
Output is correct |
11 |
Correct |
5 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2512 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
6 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
7 ms |
6684 KB |
Output is correct |
23 |
Correct |
5 ms |
6748 KB |
Output is correct |
24 |
Correct |
8 ms |
6748 KB |
Output is correct |
25 |
Correct |
5 ms |
6748 KB |
Output is correct |
26 |
Correct |
19 ms |
6792 KB |
Output is correct |
27 |
Correct |
6 ms |
6744 KB |
Output is correct |
28 |
Correct |
19 ms |
6748 KB |
Output is correct |
29 |
Correct |
5 ms |
6748 KB |
Output is correct |
30 |
Correct |
7 ms |
6748 KB |
Output is correct |
31 |
Correct |
4 ms |
6788 KB |
Output is correct |
32 |
Correct |
5 ms |
6748 KB |
Output is correct |
33 |
Correct |
6 ms |
6748 KB |
Output is correct |
34 |
Correct |
13 ms |
6780 KB |
Output is correct |
35 |
Correct |
15 ms |
6748 KB |
Output is correct |
36 |
Correct |
201 ms |
6744 KB |
Output is correct |
37 |
Correct |
72 ms |
6748 KB |
Output is correct |
38 |
Correct |
51 ms |
6748 KB |
Output is correct |
39 |
Correct |
88 ms |
6748 KB |
Output is correct |
40 |
Correct |
49 ms |
6772 KB |
Output is correct |
41 |
Correct |
2320 ms |
6772 KB |
Output is correct |
42 |
Correct |
3188 ms |
6764 KB |
Output is correct |
43 |
Correct |
12 ms |
6744 KB |
Output is correct |
44 |
Correct |
12 ms |
6748 KB |
Output is correct |
45 |
Correct |
264 ms |
6748 KB |
Output is correct |
46 |
Correct |
379 ms |
6744 KB |
Output is correct |
47 |
Correct |
23 ms |
6744 KB |
Output is correct |
48 |
Correct |
10 ms |
6748 KB |
Output is correct |
49 |
Correct |
46 ms |
6784 KB |
Output is correct |
50 |
Correct |
1306 ms |
6748 KB |
Output is correct |
51 |
Execution timed out |
4066 ms |
6768 KB |
Time limit exceeded |
52 |
Halted |
0 ms |
0 KB |
- |