# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
800819 |
2023-08-01T22:15:44 Z |
Liudas |
Horses (IOI15_horses) |
C++17 |
|
299 ms |
90564 KB |
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
class segtree{
public:
struct nodes{
double clogx, clogy;
double logx, logy;
long long X, Y;
long long cX, cY;
};
vector<long long> X, Y;
vector<nodes> tree;
int N;
long long MOD = 1e9 + 7;
nodes comp(nodes a, nodes b){
nodes c = a;
c.logx += b.logx;
c.X = c.X * b.X % MOD;
if(a.clogy + a.clogx < a.logx + b.clogx + b.clogy){
c.clogy = b.clogy;
c.clogx = a.logx + b.clogx;
c.cX = a.X * b.cX % MOD;
c.cY = b.cY;
}
return c;
}
void init(int NN){
X.resize(NN);
Y.resize(NN);
int K = 1;
while(K <= NN) K *= 2;
N = K;
tree.assign(K * 2, {0, 0, 0, 0, 0, 0, 0, 0});
}
void add(int node, int l, int r, int pos){
if(pos < l || pos > r){
return;
}
if(r - l == 1){
tree[node].X = X[pos];
tree[node].cX = X[pos];
tree[node].logx = log((double)X[pos]);
tree[node].clogx = log((double)X[pos]);
tree[node].logy = log((double)Y[pos]);
tree[node].clogy = log((double)Y[pos]);
tree[node].Y = Y[pos];
tree[node].cY = Y[pos];
return;
}
int mid = (l + r) / 2;
if(pos < mid){
add(node * 2 + 1, l, mid, pos);
}
else{
add(node * 2 + 2, mid, r, pos);
}
tree[node] = comp(tree[node * 2 + 1], tree[node * 2 + 2]);
}
void add(int pos){
add(0, 0, N, pos);
}
long long ans(){
return tree[0].cX * tree[0].cY % MOD;
}
};
segtree tree;
int init(int NN, int XX[], int YY[]){
int N = NN;
tree.init(N);
for(int i = 0; i < N; i ++){
tree.X[i] = XX[i];
tree.Y[i] = YY[i];
tree.add(i);
}
return tree.ans();
}
int updateX(int pos, int val){
tree.X[pos] = val;
tree.add(pos);
return tree.ans();
}
int updateY(int pos, int val){
tree.Y[pos] = val;
tree.add(pos);
return tree.ans();
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:76:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
76 | return tree.ans();
| ~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:81:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
81 | return tree.ans();
| ~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:86:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
86 | return tree.ans();
| ~~~~~~~~^~
# |
Verdict |
Execution time |
Memory |
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 |
0 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 |
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 |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
1 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 |
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 |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
78604 KB |
Output is correct |
2 |
Correct |
293 ms |
78600 KB |
Output is correct |
3 |
Correct |
261 ms |
82404 KB |
Output is correct |
4 |
Correct |
267 ms |
86332 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 |
1 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 |
272 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 |
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 |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
163 ms |
77704 KB |
Output is correct |
34 |
Correct |
162 ms |
81636 KB |
Output is correct |
35 |
Correct |
197 ms |
88584 KB |
Output is correct |
36 |
Correct |
196 ms |
88548 KB |
Output is correct |
37 |
Correct |
140 ms |
79904 KB |
Output is correct |
38 |
Correct |
168 ms |
80716 KB |
Output is correct |
39 |
Correct |
141 ms |
79940 KB |
Output is correct |
40 |
Correct |
181 ms |
83660 KB |
Output is correct |
41 |
Correct |
141 ms |
79752 KB |
Output is correct |
42 |
Correct |
135 ms |
79888 KB |
Output is correct |
43 |
Correct |
175 ms |
84100 KB |
Output is correct |
44 |
Correct |
177 ms |
84104 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 |
1 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 |
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 |
1 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 |
468 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
460 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
1 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
202 ms |
78588 KB |
Output is correct |
34 |
Correct |
284 ms |
78708 KB |
Output is correct |
35 |
Correct |
250 ms |
82484 KB |
Output is correct |
36 |
Correct |
299 ms |
86240 KB |
Output is correct |
37 |
Correct |
162 ms |
81644 KB |
Output is correct |
38 |
Correct |
166 ms |
81760 KB |
Output is correct |
39 |
Correct |
197 ms |
88652 KB |
Output is correct |
40 |
Correct |
197 ms |
88540 KB |
Output is correct |
41 |
Correct |
140 ms |
79820 KB |
Output is correct |
42 |
Correct |
173 ms |
80816 KB |
Output is correct |
43 |
Correct |
135 ms |
79692 KB |
Output is correct |
44 |
Correct |
182 ms |
83684 KB |
Output is correct |
45 |
Correct |
141 ms |
79748 KB |
Output is correct |
46 |
Correct |
135 ms |
79796 KB |
Output is correct |
47 |
Correct |
174 ms |
84088 KB |
Output is correct |
48 |
Correct |
176 ms |
84124 KB |
Output is correct |
49 |
Correct |
243 ms |
83660 KB |
Output is correct |
50 |
Correct |
247 ms |
83740 KB |
Output is correct |
51 |
Correct |
230 ms |
90564 KB |
Output is correct |
52 |
Correct |
238 ms |
89972 KB |
Output is correct |
53 |
Correct |
225 ms |
82372 KB |
Output is correct |
54 |
Correct |
214 ms |
82572 KB |
Output is correct |
55 |
Correct |
161 ms |
80764 KB |
Output is correct |
56 |
Correct |
221 ms |
85496 KB |
Output is correct |
57 |
Correct |
164 ms |
81412 KB |
Output is correct |
58 |
Correct |
165 ms |
81988 KB |
Output is correct |
59 |
Correct |
178 ms |
84096 KB |
Output is correct |