# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
800820 |
2023-08-01T22:17:03 Z |
Liudas |
Horses (IOI15_horses) |
C++17 |
|
275 ms |
62320 KB |
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
class segtree{
public:
struct nodes{
double clogx, clogy;
double logx;
long long X;
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});
}
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].cY = Y[pos];
tree[node].logx = log((double)X[pos]);
tree[node].clogx = log((double)X[pos]);
tree[node].clogy = log((double)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:74:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
74 | return tree.ans();
| ~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:79:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
79 | return tree.ans();
| ~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:84:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
84 | return tree.ans();
| ~~~~~~~~^~
# |
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 |
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 |
280 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 |
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 |
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 |
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 |
1 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 |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
62188 KB |
Output is correct |
2 |
Correct |
269 ms |
62180 KB |
Output is correct |
3 |
Correct |
242 ms |
62284 KB |
Output is correct |
4 |
Correct |
254 ms |
62180 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 |
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 |
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 |
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 |
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 |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
152 ms |
61288 KB |
Output is correct |
34 |
Correct |
152 ms |
61384 KB |
Output is correct |
35 |
Correct |
185 ms |
61288 KB |
Output is correct |
36 |
Correct |
187 ms |
61292 KB |
Output is correct |
37 |
Correct |
132 ms |
61288 KB |
Output is correct |
38 |
Correct |
170 ms |
61292 KB |
Output is correct |
39 |
Correct |
130 ms |
61292 KB |
Output is correct |
40 |
Correct |
194 ms |
61384 KB |
Output is correct |
41 |
Correct |
130 ms |
61272 KB |
Output is correct |
42 |
Correct |
133 ms |
61288 KB |
Output is correct |
43 |
Correct |
175 ms |
61292 KB |
Output is correct |
44 |
Correct |
169 ms |
61288 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 |
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 |
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 |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
187 ms |
62184 KB |
Output is correct |
34 |
Correct |
275 ms |
62224 KB |
Output is correct |
35 |
Correct |
235 ms |
62224 KB |
Output is correct |
36 |
Correct |
260 ms |
62204 KB |
Output is correct |
37 |
Correct |
153 ms |
61388 KB |
Output is correct |
38 |
Correct |
154 ms |
61376 KB |
Output is correct |
39 |
Correct |
187 ms |
61288 KB |
Output is correct |
40 |
Correct |
187 ms |
61388 KB |
Output is correct |
41 |
Correct |
139 ms |
61388 KB |
Output is correct |
42 |
Correct |
166 ms |
61344 KB |
Output is correct |
43 |
Correct |
132 ms |
61324 KB |
Output is correct |
44 |
Correct |
174 ms |
61288 KB |
Output is correct |
45 |
Correct |
129 ms |
61288 KB |
Output is correct |
46 |
Correct |
137 ms |
61288 KB |
Output is correct |
47 |
Correct |
170 ms |
61348 KB |
Output is correct |
48 |
Correct |
167 ms |
61296 KB |
Output is correct |
49 |
Correct |
225 ms |
62212 KB |
Output is correct |
50 |
Correct |
231 ms |
62320 KB |
Output is correct |
51 |
Correct |
231 ms |
62188 KB |
Output is correct |
52 |
Correct |
227 ms |
62168 KB |
Output is correct |
53 |
Correct |
204 ms |
62212 KB |
Output is correct |
54 |
Correct |
202 ms |
62180 KB |
Output is correct |
55 |
Correct |
153 ms |
61500 KB |
Output is correct |
56 |
Correct |
218 ms |
62184 KB |
Output is correct |
57 |
Correct |
153 ms |
62180 KB |
Output is correct |
58 |
Correct |
157 ms |
62312 KB |
Output is correct |
59 |
Correct |
169 ms |
61292 KB |
Output is correct |