#include "horses.h"
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
int n;
struct node{
ll v, x, y; double dx, dy, dv;
}t[4 * 500005];
node merge(node a, node b){
node res;
b.dx += a.dx, b.dv += a.dx;
if (a.dv > b.dv) res.v = a.v, res.dv = a.dv;
else res.v = a.x * b.v % mod, res.dv = b.dv;
res.x = a.x * b.x % mod;
res.dx = b.dx;
return res;
}
node upd(int i, int l, int r, int ps, ll vx, ll vy){
if (l > ps || r < ps) return t[i];
if (l == r && l == ps) {
node& nd = t[i];
if (vx) nd.dx = log(vx), nd.x = vx;
if (vy) nd.dy = log(vy), nd.y = vy;
nd.v = nd.x * nd.y % mod, nd.dv = nd.dx + nd.dy;
return nd;
}
int m = (l + r) / 2;
return t[i] = merge(upd(i * 2, l, m, ps, vx, vy), upd(i * 2 + 1, m + 1, r, ps, vx, vy));
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i = 0; i < N; i++) upd(1, 0, n - 1, i, X[i], Y[i]);
return t[1].v;
}
int updateX(int pos, int val) {
upd(1, 0, n - 1, pos, val, 0);
return t[1].v;
}
int updateY(int pos, int val) {
upd(1, 0, n - 1, pos, 0, val);
return t[1].v;
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:40:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
40 | return t[1].v;
| ~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:45:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
45 | return t[1].v;
| ~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:50:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
50 | return t[1].v;
| ~~~~~^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
228 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 |
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 |
1 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 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 |
1 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 |
1 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 |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
461 ms |
56048 KB |
Output is correct |
2 |
Correct |
537 ms |
67044 KB |
Output is correct |
3 |
Correct |
498 ms |
58160 KB |
Output is correct |
4 |
Correct |
495 ms |
62028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
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 |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
2 ms |
340 KB |
Output is correct |
31 |
Correct |
2 ms |
340 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
372 ms |
53524 KB |
Output is correct |
34 |
Correct |
382 ms |
57412 KB |
Output is correct |
35 |
Correct |
413 ms |
64504 KB |
Output is correct |
36 |
Correct |
417 ms |
64324 KB |
Output is correct |
37 |
Correct |
380 ms |
55564 KB |
Output is correct |
38 |
Correct |
383 ms |
56516 KB |
Output is correct |
39 |
Correct |
398 ms |
55436 KB |
Output is correct |
40 |
Correct |
406 ms |
59380 KB |
Output is correct |
41 |
Correct |
381 ms |
55608 KB |
Output is correct |
42 |
Correct |
382 ms |
55612 KB |
Output is correct |
43 |
Correct |
410 ms |
59844 KB |
Output is correct |
44 |
Correct |
389 ms |
59896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
1 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 |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
2 ms |
340 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
450 ms |
56080 KB |
Output is correct |
34 |
Correct |
506 ms |
67004 KB |
Output is correct |
35 |
Correct |
491 ms |
58196 KB |
Output is correct |
36 |
Correct |
505 ms |
62280 KB |
Output is correct |
37 |
Correct |
381 ms |
57428 KB |
Output is correct |
38 |
Correct |
390 ms |
57476 KB |
Output is correct |
39 |
Correct |
402 ms |
64332 KB |
Output is correct |
40 |
Correct |
406 ms |
64332 KB |
Output is correct |
41 |
Correct |
401 ms |
55572 KB |
Output is correct |
42 |
Correct |
377 ms |
56684 KB |
Output is correct |
43 |
Correct |
397 ms |
55628 KB |
Output is correct |
44 |
Correct |
428 ms |
59448 KB |
Output is correct |
45 |
Correct |
373 ms |
55500 KB |
Output is correct |
46 |
Correct |
395 ms |
55544 KB |
Output is correct |
47 |
Correct |
388 ms |
59900 KB |
Output is correct |
48 |
Correct |
447 ms |
59748 KB |
Output is correct |
49 |
Correct |
478 ms |
59412 KB |
Output is correct |
50 |
Correct |
490 ms |
59384 KB |
Output is correct |
51 |
Correct |
474 ms |
66384 KB |
Output is correct |
52 |
Correct |
480 ms |
65864 KB |
Output is correct |
53 |
Correct |
500 ms |
57848 KB |
Output is correct |
54 |
Correct |
446 ms |
58444 KB |
Output is correct |
55 |
Correct |
451 ms |
56592 KB |
Output is correct |
56 |
Correct |
463 ms |
61280 KB |
Output is correct |
57 |
Correct |
460 ms |
57168 KB |
Output is correct |
58 |
Correct |
452 ms |
57756 KB |
Output is correct |
59 |
Correct |
389 ms |
59792 KB |
Output is correct |