# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
890844 |
2023-12-22T04:09:35 Z |
NeroZein |
Horses (IOI15_horses) |
C++17 |
|
1500 ms |
43504 KB |
#include "horses.h"
#include "bits/stdc++.h"
using namespace std;
const int N = 5e5 + 5;
const int md = (int) 1e9 + 7;
struct node {
long double mx = 0, lazy = 0;
};
int n;
int x[N], y[N];
node seg[N * 2];
int mul(int a, int b) {
return (int) ((long long) a * b % md);
}
void push(int nd, int l, int r) {
if (!seg[nd].lazy) return;
seg[nd].mx += seg[nd].lazy;
if (l != r) {
int mid = (l + r) >> 1;
int rs = nd + ((mid - l + 1) << 1);
seg[nd + 1].lazy += seg[nd].lazy;
seg[rs].lazy += seg[nd].lazy;
}
seg[nd].lazy = 0;
}
void upd(int nd, int l, int r, int s, int e, long double v) {
push(nd, l, r);
if (l >= s && r <= e) {
seg[nd].lazy = v;
push(nd, l, r);
return;
}
int mid = (l + r) >> 1;
int rs = nd + ((mid - l + 1) << 1);
if (mid >= e) {
upd(nd + 1, l, mid, s, e, v);
push(rs, mid + 1, r);
} else {
if (mid < s) {
upd(rs, mid + 1, r, s, e, v);
push(nd + 1, l, mid);
} else {
upd(nd + 1, l, mid, s, e, v);
upd(rs, mid + 1, r, s, e, v);
}
}
seg[nd].mx = max(seg[nd + 1].mx, seg[rs].mx);
}
int get(int nd, int l, int r) {
if (l == r) {
return l;
}
int mid = (l + r) >> 1;
int rs = nd + ((mid - l + 1) << 1);
push(nd + 1, l, mid);
push(rs, mid + 1, r);
if (seg[nd + 1].mx < seg[rs].mx) {
return get(rs, mid + 1, r);
} else {
return get(nd + 1, l, mid);
}
}
int calc(int index) {
int ret = 1;
for (int i = 0; i <= index; ++i) {
ret = mul(ret, x[i]);
}
return mul(ret, y[index]);
}
int init(int N_, int X[], int Y[]) {
n = N_;
for (int i = 0; i < n; ++i) {
x[i] = X[i]; y[i] = Y[i];
upd(0, 0, n - 1, i, i, log2(1.0L * y[i]));
upd(0, 0, n - 1, i, n - 1, log2(1.0L * x[i]));
}
return calc(get(0, 0, n - 1));
}
int updateX(int pos, int val) {
upd(0, 0, n - 1, pos, n - 1, -log2(1.0L * x[pos]));
x[pos] = val;
upd(0, 0, n - 1, pos, n - 1, +log2(1.0L * x[pos]));
return calc(get(0, 0, n - 1));
}
int updateY(int pos, int val) {
upd(0, 0, n - 1, pos, pos, -log2(1.0L * y[pos]));
y[pos] = val;
upd(0, 0, n - 1, pos, pos, +log2(1.0L * y[pos]));
return calc(get(0, 0, n - 1));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4456 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4692 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4440 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
2 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4440 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
8 ms |
4444 KB |
Output is correct |
24 |
Correct |
8 ms |
4444 KB |
Output is correct |
25 |
Correct |
8 ms |
4444 KB |
Output is correct |
26 |
Correct |
8 ms |
4440 KB |
Output is correct |
27 |
Correct |
8 ms |
4444 KB |
Output is correct |
28 |
Correct |
8 ms |
4636 KB |
Output is correct |
29 |
Correct |
5 ms |
4440 KB |
Output is correct |
30 |
Correct |
8 ms |
4444 KB |
Output is correct |
31 |
Correct |
3 ms |
4444 KB |
Output is correct |
32 |
Correct |
5 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1547 ms |
39572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4440 KB |
Output is correct |
3 |
Correct |
1 ms |
4440 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4440 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4456 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4440 KB |
Output is correct |
21 |
Correct |
1 ms |
4544 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
7 ms |
4440 KB |
Output is correct |
24 |
Correct |
7 ms |
4444 KB |
Output is correct |
25 |
Correct |
7 ms |
4444 KB |
Output is correct |
26 |
Correct |
7 ms |
4444 KB |
Output is correct |
27 |
Correct |
8 ms |
4444 KB |
Output is correct |
28 |
Correct |
8 ms |
4596 KB |
Output is correct |
29 |
Correct |
7 ms |
4440 KB |
Output is correct |
30 |
Correct |
7 ms |
4444 KB |
Output is correct |
31 |
Correct |
4 ms |
4444 KB |
Output is correct |
32 |
Correct |
5 ms |
4444 KB |
Output is correct |
33 |
Execution timed out |
1507 ms |
43504 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4440 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4440 KB |
Output is correct |
15 |
Correct |
1 ms |
4440 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4540 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
1 ms |
4440 KB |
Output is correct |
22 |
Correct |
1 ms |
4440 KB |
Output is correct |
23 |
Correct |
7 ms |
4444 KB |
Output is correct |
24 |
Correct |
8 ms |
4644 KB |
Output is correct |
25 |
Correct |
7 ms |
4440 KB |
Output is correct |
26 |
Correct |
7 ms |
4444 KB |
Output is correct |
27 |
Correct |
8 ms |
4440 KB |
Output is correct |
28 |
Correct |
8 ms |
4644 KB |
Output is correct |
29 |
Correct |
6 ms |
4444 KB |
Output is correct |
30 |
Correct |
6 ms |
4632 KB |
Output is correct |
31 |
Correct |
3 ms |
4444 KB |
Output is correct |
32 |
Correct |
4 ms |
4440 KB |
Output is correct |
33 |
Execution timed out |
1553 ms |
41760 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |