#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
//Fast
long long fast(long long a,long long b){
if(b==0)return 1;
if(b==1)return a%mod;
long long ha = fast(a,b/2)%mod;
if(b%2==0)return (ha*ha)%mod;
else return (((ha*ha)%mod)*a)%mod;
}
long long seg[2000001],lazy[2000001];
double seg2[2000001],lazy2[2000001];
void prop(int p,int l,int r){
seg[p]*=lazy[p];
seg[p]%=mod;
seg2[p]+=lazy2[p];
if(l!=r){
lazy[p*2]*=lazy[p];
lazy[p*2]%=mod;
lazy2[p*2]+=lazy2[p];
lazy[p*2+1]*=lazy[p];
lazy[p*2+1]%=mod;
lazy2[p*2+1]+=lazy2[p];
}
lazy[p] = 1;
lazy2[p] = 0;
}
void update(int p,int l,int r,int lq,int rq,long long val,double val2){
prop(p,l,r);
if(l>=lq&&r<=rq){
lazy[p]*=val;
lazy[p]%=mod;
lazy2[p]+=val2;
prop(p,l,r);
return ;
}
if(l>rq||r<lq)return ;
int md = (l+r)/2;
update(p*2,l,md,lq,rq,val,val2);
update(p*2+1,md+1,r,lq,rq,val,val2);
if(seg2[p*2]>seg2[p*2+1]){
seg2[p]= seg2[p*2];
seg[p] = seg[p*2];
}else{
seg2[p]= seg2[p*2+1];
seg[p] = seg[p*2+1];
}
}
pair<long long,double> query(int p,int l,int r,int lq,int rq){
prop(p,l,r);
if(l>=lq&&r<=rq)return {seg[p],seg2[p]};
if(l>rq||r<lq)return {0,-1};
int md = (l+r)/2;
pair<long long,double> p1 = query(p*2,l,md,lq,rq);
pair<long long,double> p2 = query(p*2+1,md+1,r,lq,rq);
if(p1.second>p2.second)return p1;
else return p2;
}
int n;
vector<long long> x,y;
long long init(int N,int X[],int Y[]){
n = N;
for(int i = 0;i<=2e6;i++){
seg[i] = 1, lazy[i] = 1;
seg2[i] = 0 , lazy2[i] = 0;
}
for(int i = 0;i<n;i++){
x.push_back(X[i]);
y.push_back(Y[i]);
update(1,1,n,i+1,n,X[i],log2(X[i]));
update(1,1,n,i+1,i+1,Y[i],log2(Y[i]));
}
return query(1,1,n,1,n).first;
}long long updateX(int pos,int val){
update(1,1,n,pos+1,n,fast(x[pos],mod-2),-log2(x[pos]));
x[pos] = val;
update(1,1,n,pos+1,n,x[pos],log2(x[pos]));
return query(1,1,n,1,n).first;
}long long updateY(int pos,int val){
update(1,1,n,pos+1,pos+1,fast(y[pos],mod-2),-log2(y[pos]));
y[pos] = val;
update(1,1,n,pos+1,pos+1,y[pos],log2(y[pos]));
return query(1,1,n,1,n).first;
}/*
int main(){
int X[] = {2,1,3};
int Y[] = {3,4,1};
cout<<init(3,X,Y)<<endl;
cout<<updateX(0,1)<<endl;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
62932 KB |
Output is correct |
2 |
Correct |
21 ms |
62804 KB |
Output is correct |
3 |
Correct |
21 ms |
62908 KB |
Output is correct |
4 |
Correct |
21 ms |
62920 KB |
Output is correct |
5 |
Correct |
21 ms |
62796 KB |
Output is correct |
6 |
Correct |
21 ms |
62868 KB |
Output is correct |
7 |
Correct |
22 ms |
62804 KB |
Output is correct |
8 |
Correct |
21 ms |
62804 KB |
Output is correct |
9 |
Correct |
21 ms |
62832 KB |
Output is correct |
10 |
Correct |
21 ms |
62912 KB |
Output is correct |
11 |
Correct |
21 ms |
62804 KB |
Output is correct |
12 |
Correct |
24 ms |
62852 KB |
Output is correct |
13 |
Correct |
22 ms |
62912 KB |
Output is correct |
14 |
Correct |
21 ms |
62880 KB |
Output is correct |
15 |
Correct |
21 ms |
62788 KB |
Output is correct |
16 |
Correct |
21 ms |
62804 KB |
Output is correct |
17 |
Correct |
21 ms |
62884 KB |
Output is correct |
18 |
Correct |
21 ms |
62824 KB |
Output is correct |
19 |
Correct |
25 ms |
62900 KB |
Output is correct |
20 |
Correct |
23 ms |
62928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
62820 KB |
Output is correct |
2 |
Correct |
21 ms |
62808 KB |
Output is correct |
3 |
Correct |
20 ms |
62840 KB |
Output is correct |
4 |
Correct |
20 ms |
62884 KB |
Output is correct |
5 |
Correct |
24 ms |
62856 KB |
Output is correct |
6 |
Correct |
21 ms |
62804 KB |
Output is correct |
7 |
Correct |
22 ms |
62844 KB |
Output is correct |
8 |
Correct |
21 ms |
62804 KB |
Output is correct |
9 |
Correct |
21 ms |
62820 KB |
Output is correct |
10 |
Correct |
21 ms |
62816 KB |
Output is correct |
11 |
Correct |
21 ms |
62904 KB |
Output is correct |
12 |
Correct |
21 ms |
62888 KB |
Output is correct |
13 |
Correct |
21 ms |
62880 KB |
Output is correct |
14 |
Correct |
21 ms |
62872 KB |
Output is correct |
15 |
Correct |
27 ms |
62924 KB |
Output is correct |
16 |
Correct |
21 ms |
62832 KB |
Output is correct |
17 |
Correct |
21 ms |
62900 KB |
Output is correct |
18 |
Correct |
22 ms |
62912 KB |
Output is correct |
19 |
Correct |
22 ms |
62868 KB |
Output is correct |
20 |
Correct |
21 ms |
62804 KB |
Output is correct |
21 |
Correct |
22 ms |
62800 KB |
Output is correct |
22 |
Correct |
21 ms |
62932 KB |
Output is correct |
23 |
Correct |
23 ms |
62932 KB |
Output is correct |
24 |
Correct |
23 ms |
62864 KB |
Output is correct |
25 |
Correct |
24 ms |
62912 KB |
Output is correct |
26 |
Correct |
23 ms |
62908 KB |
Output is correct |
27 |
Correct |
24 ms |
62928 KB |
Output is correct |
28 |
Correct |
23 ms |
62932 KB |
Output is correct |
29 |
Correct |
24 ms |
62952 KB |
Output is correct |
30 |
Correct |
23 ms |
62944 KB |
Output is correct |
31 |
Correct |
23 ms |
62956 KB |
Output is correct |
32 |
Correct |
24 ms |
62836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
783 ms |
76052 KB |
Output is correct |
2 |
Correct |
976 ms |
76032 KB |
Output is correct |
3 |
Correct |
869 ms |
75804 KB |
Output is correct |
4 |
Correct |
908 ms |
75860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
62804 KB |
Output is correct |
2 |
Correct |
21 ms |
62852 KB |
Output is correct |
3 |
Correct |
25 ms |
62908 KB |
Output is correct |
4 |
Correct |
22 ms |
62804 KB |
Output is correct |
5 |
Correct |
25 ms |
62872 KB |
Output is correct |
6 |
Correct |
21 ms |
62796 KB |
Output is correct |
7 |
Correct |
24 ms |
62860 KB |
Output is correct |
8 |
Correct |
23 ms |
62908 KB |
Output is correct |
9 |
Correct |
21 ms |
62804 KB |
Output is correct |
10 |
Correct |
20 ms |
62872 KB |
Output is correct |
11 |
Correct |
21 ms |
62796 KB |
Output is correct |
12 |
Correct |
21 ms |
62848 KB |
Output is correct |
13 |
Correct |
20 ms |
62804 KB |
Output is correct |
14 |
Correct |
21 ms |
62804 KB |
Output is correct |
15 |
Correct |
27 ms |
62804 KB |
Output is correct |
16 |
Correct |
23 ms |
62812 KB |
Output is correct |
17 |
Correct |
21 ms |
62872 KB |
Output is correct |
18 |
Correct |
20 ms |
62856 KB |
Output is correct |
19 |
Correct |
22 ms |
62836 KB |
Output is correct |
20 |
Correct |
21 ms |
62912 KB |
Output is correct |
21 |
Correct |
25 ms |
62924 KB |
Output is correct |
22 |
Correct |
21 ms |
62804 KB |
Output is correct |
23 |
Correct |
22 ms |
62872 KB |
Output is correct |
24 |
Correct |
23 ms |
62932 KB |
Output is correct |
25 |
Correct |
23 ms |
62928 KB |
Output is correct |
26 |
Correct |
23 ms |
62956 KB |
Output is correct |
27 |
Correct |
23 ms |
62864 KB |
Output is correct |
28 |
Correct |
23 ms |
62960 KB |
Output is correct |
29 |
Correct |
27 ms |
62856 KB |
Output is correct |
30 |
Correct |
24 ms |
62940 KB |
Output is correct |
31 |
Correct |
22 ms |
62952 KB |
Output is correct |
32 |
Correct |
23 ms |
62952 KB |
Output is correct |
33 |
Correct |
654 ms |
74956 KB |
Output is correct |
34 |
Correct |
651 ms |
74884 KB |
Output is correct |
35 |
Correct |
730 ms |
74908 KB |
Output is correct |
36 |
Correct |
717 ms |
74916 KB |
Output is correct |
37 |
Correct |
635 ms |
75112 KB |
Output is correct |
38 |
Correct |
655 ms |
74944 KB |
Output is correct |
39 |
Correct |
622 ms |
74812 KB |
Output is correct |
40 |
Correct |
706 ms |
74896 KB |
Output is correct |
41 |
Correct |
626 ms |
74936 KB |
Output is correct |
42 |
Correct |
631 ms |
75020 KB |
Output is correct |
43 |
Correct |
713 ms |
74864 KB |
Output is correct |
44 |
Correct |
701 ms |
74868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
62900 KB |
Output is correct |
2 |
Correct |
21 ms |
62812 KB |
Output is correct |
3 |
Correct |
21 ms |
62820 KB |
Output is correct |
4 |
Correct |
26 ms |
62976 KB |
Output is correct |
5 |
Correct |
23 ms |
62844 KB |
Output is correct |
6 |
Correct |
25 ms |
62876 KB |
Output is correct |
7 |
Correct |
21 ms |
62876 KB |
Output is correct |
8 |
Correct |
25 ms |
62864 KB |
Output is correct |
9 |
Correct |
21 ms |
62896 KB |
Output is correct |
10 |
Correct |
21 ms |
62884 KB |
Output is correct |
11 |
Correct |
22 ms |
62796 KB |
Output is correct |
12 |
Correct |
20 ms |
62832 KB |
Output is correct |
13 |
Correct |
21 ms |
62852 KB |
Output is correct |
14 |
Correct |
21 ms |
62820 KB |
Output is correct |
15 |
Correct |
21 ms |
62892 KB |
Output is correct |
16 |
Correct |
21 ms |
62860 KB |
Output is correct |
17 |
Correct |
21 ms |
62808 KB |
Output is correct |
18 |
Correct |
22 ms |
62916 KB |
Output is correct |
19 |
Correct |
21 ms |
62804 KB |
Output is correct |
20 |
Correct |
21 ms |
62864 KB |
Output is correct |
21 |
Correct |
21 ms |
62792 KB |
Output is correct |
22 |
Correct |
21 ms |
62880 KB |
Output is correct |
23 |
Correct |
24 ms |
62932 KB |
Output is correct |
24 |
Correct |
23 ms |
62956 KB |
Output is correct |
25 |
Correct |
23 ms |
62924 KB |
Output is correct |
26 |
Correct |
23 ms |
62936 KB |
Output is correct |
27 |
Correct |
23 ms |
62948 KB |
Output is correct |
28 |
Correct |
22 ms |
62912 KB |
Output is correct |
29 |
Correct |
25 ms |
62932 KB |
Output is correct |
30 |
Correct |
24 ms |
62924 KB |
Output is correct |
31 |
Correct |
23 ms |
62884 KB |
Output is correct |
32 |
Correct |
23 ms |
62900 KB |
Output is correct |
33 |
Correct |
796 ms |
75768 KB |
Output is correct |
34 |
Correct |
956 ms |
75876 KB |
Output is correct |
35 |
Correct |
850 ms |
75756 KB |
Output is correct |
36 |
Correct |
898 ms |
75976 KB |
Output is correct |
37 |
Correct |
658 ms |
74968 KB |
Output is correct |
38 |
Correct |
653 ms |
74920 KB |
Output is correct |
39 |
Correct |
719 ms |
74976 KB |
Output is correct |
40 |
Correct |
723 ms |
75048 KB |
Output is correct |
41 |
Correct |
636 ms |
75012 KB |
Output is correct |
42 |
Correct |
635 ms |
74924 KB |
Output is correct |
43 |
Correct |
645 ms |
74892 KB |
Output is correct |
44 |
Correct |
712 ms |
74864 KB |
Output is correct |
45 |
Correct |
674 ms |
74920 KB |
Output is correct |
46 |
Correct |
630 ms |
74876 KB |
Output is correct |
47 |
Correct |
709 ms |
74920 KB |
Output is correct |
48 |
Correct |
699 ms |
74800 KB |
Output is correct |
49 |
Correct |
865 ms |
80836 KB |
Output is correct |
50 |
Correct |
866 ms |
80808 KB |
Output is correct |
51 |
Correct |
877 ms |
87692 KB |
Output is correct |
52 |
Correct |
902 ms |
87192 KB |
Output is correct |
53 |
Correct |
833 ms |
79168 KB |
Output is correct |
54 |
Correct |
810 ms |
79716 KB |
Output is correct |
55 |
Correct |
776 ms |
78036 KB |
Output is correct |
56 |
Correct |
925 ms |
82724 KB |
Output is correct |
57 |
Correct |
771 ms |
78676 KB |
Output is correct |
58 |
Correct |
793 ms |
79104 KB |
Output is correct |
59 |
Correct |
688 ms |
81168 KB |
Output is correct |