#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define ROF(i,a,b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
ll MOD = 1000000007;
ll power(ll base, ll n){
if (n == 0) return 1;
if (n == 1) return base;
ll halfn = power(base, n/2);
if (n % 2 == 0) return (halfn * halfn) % MOD;
return (((halfn * halfn) % MOD) * base) % MOD;
}
ll inverse(ll n){
return power(n, MOD-2);
}
vector<ll> x, y;
int n;
struct lol{
ld val;
int ind;
ld add;
};
// range addition and maximum
struct segtree{
vector<lol> mx;
int sz;
void init(int m){
sz = m;
mx.assign(4*m, {0,0,0});
}
void update(int v, int tl, int tr, int l, int r, ld val){
if (tl==tr) mx[v].ind = tl;
if (tl == l && tr == r){
mx[v].add += val;
mx[v].val += val;
return;
}
if (l > r) return;
int tm = (tl + tr)/2;
update(2*v, tl, tm, l, min(r,tm), val);
update(2*v+1, tm+1, tr, max(l,tm+1), r, val);
if (mx[2*v].val + 1e-11 > mx[2*v+1].val){
mx[v].val = mx[2*v].val + mx[v].add;
mx[v].ind = mx[2*v].ind;
}else{
mx[v].val = mx[2*v+1].val + mx[v].add;
mx[v].ind = mx[2*v+1].ind;
}
}
void update(int l, int r, ld val){
update(1,0,sz-1,l,r,val);
}
int get(){
return mx[1].ind;
}
} st;
// range update point value
struct segtree2{
vector<ll> prod;
int sz;
void init(int m){
sz = m;
prod.assign(4*m, 1);
}
void update(int v, int tl, int tr, int l, int r, ll val){
if (l>r) return;
if (tl==l && tr==r){
prod[v] *= val;
prod[v] %= MOD;
return;
}
int tm = (tl+tr)/2;
update(2*v, tl, tm, l, min(r,tm), val);
update(2*v+1, tm+1, tr, max(l,tm+1), r, val);
}
void update(int l, int r, ll val){
update(1,0,sz-1,l,r,val);
}
ll get(int v, int tl, int tr, int pos){
if (tl==tr) return prod[v];
int tm = (tl+tr)/2;
if (pos <= tm){
return (get(2*v,tl,tm,pos)*prod[v]) % MOD;
}else{
return (get(2*v+1,tm+1,tr,pos)*prod[v]) % MOD;
}
}
ll get(int pos){
return get(1,0,sz-1,pos);
}
} st2;
vector<ld> a, b;
int init(int N, int X[], int Y[]) {
cout << setprecision(12);
n = N;
FOR(i,0,n){
x.pb(X[i]);
y.pb(Y[i]);
}
st.init(N);
st2.init(N);
FOR(i,0,N){
st.update(i,n-1,log(x[i]));
st.update(i,i,log(y[i]));
st2.update(i,n-1,x[i]);
}
int ans = st.get();
ll answer = (st2.get(ans) * y[ans]) % MOD;
return (int) answer;
}
int updateX(int pos, int val) {
st.update(pos,n-1,log(val)-log(x[pos]));
ll value = (inverse(x[pos]) * (ll)val) % MOD;
st2.update(pos,n-1,value);
x[pos] = val;
int ans = st.get();
ll answer = (st2.get(ans) * y[ans]) % MOD;
return (int) answer;
}
int updateY(int pos, int val) {
st.update(pos,pos,log(val)-log(y[pos]));
y[pos] = val;
int ans = st.get();
ll answer = (st2.get(ans) * y[ans]) % MOD;
return (int) answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
296 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
2 ms |
468 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
469 ms |
122800 KB |
Output is correct |
2 |
Correct |
617 ms |
135428 KB |
Output is correct |
3 |
Correct |
548 ms |
126580 KB |
Output is correct |
4 |
Correct |
594 ms |
130460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
2 ms |
468 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
500 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
446 ms |
121884 KB |
Output is correct |
34 |
Correct |
445 ms |
125800 KB |
Output is correct |
35 |
Correct |
470 ms |
132740 KB |
Output is correct |
36 |
Correct |
472 ms |
132768 KB |
Output is correct |
37 |
Correct |
439 ms |
124036 KB |
Output is correct |
38 |
Correct |
443 ms |
124884 KB |
Output is correct |
39 |
Correct |
401 ms |
123924 KB |
Output is correct |
40 |
Correct |
439 ms |
127948 KB |
Output is correct |
41 |
Correct |
392 ms |
123988 KB |
Output is correct |
42 |
Correct |
405 ms |
123960 KB |
Output is correct |
43 |
Correct |
437 ms |
128240 KB |
Output is correct |
44 |
Correct |
434 ms |
128248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
2 ms |
468 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
2 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
2 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
454 ms |
124424 KB |
Output is correct |
34 |
Correct |
615 ms |
135392 KB |
Output is correct |
35 |
Correct |
567 ms |
126528 KB |
Output is correct |
36 |
Correct |
598 ms |
130672 KB |
Output is correct |
37 |
Correct |
501 ms |
125804 KB |
Output is correct |
38 |
Correct |
444 ms |
125844 KB |
Output is correct |
39 |
Correct |
476 ms |
132740 KB |
Output is correct |
40 |
Correct |
466 ms |
132816 KB |
Output is correct |
41 |
Correct |
396 ms |
123992 KB |
Output is correct |
42 |
Correct |
472 ms |
124968 KB |
Output is correct |
43 |
Correct |
421 ms |
123920 KB |
Output is correct |
44 |
Correct |
446 ms |
127776 KB |
Output is correct |
45 |
Correct |
395 ms |
123900 KB |
Output is correct |
46 |
Correct |
425 ms |
124060 KB |
Output is correct |
47 |
Correct |
443 ms |
128192 KB |
Output is correct |
48 |
Correct |
424 ms |
128232 KB |
Output is correct |
49 |
Correct |
571 ms |
127944 KB |
Output is correct |
50 |
Correct |
563 ms |
127872 KB |
Output is correct |
51 |
Correct |
537 ms |
134644 KB |
Output is correct |
52 |
Correct |
533 ms |
134152 KB |
Output is correct |
53 |
Correct |
517 ms |
126180 KB |
Output is correct |
54 |
Correct |
519 ms |
126760 KB |
Output is correct |
55 |
Correct |
487 ms |
124932 KB |
Output is correct |
56 |
Correct |
559 ms |
129780 KB |
Output is correct |
57 |
Correct |
459 ms |
125560 KB |
Output is correct |
58 |
Correct |
457 ms |
126072 KB |
Output is correct |
59 |
Correct |
428 ms |
128244 KB |
Output is correct |