# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
220933 |
2020-04-09T09:56:17 Z |
a_player |
Horses (IOI15_horses) |
C++14 |
|
204 ms |
50680 KB |
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
const int nax=5e5+5;
const int mod=1e9+7;
typedef long long ll;
struct node{
double lg,lgv;
int x,y,val;
};
node rt[4*nax];
int *X,*Y;
int N;
void updX(int k, int x, int y, int a, int val){
if(x>a||y<a)return;
if(x==y){
rt[k].x=val;
rt[k].lg=log(val);
rt[k].val=((ll)val*(ll)rt[k].y)%mod;
rt[k].lgv=rt[k].lg+log(rt[k].y);
return;
}
int m=(x+y)/2;
updX(2*k,x,m,a,val);
updX(2*k+1,m+1,y,a,val);
rt[k].x=((ll)rt[2*k].x*(ll)rt[2*k+1].x)%mod;
rt[k].lg=rt[2*k].lg+rt[2*k+1].lg;
if(rt[2*k].lgv<rt[2*k+1].lgv+rt[2*k].lg){
rt[k].lgv=rt[2*k+1].lgv+rt[2*k].lg;
rt[k].val=((ll)rt[2*k].x*(ll)rt[2*k+1].val)%mod;
}else{
rt[k].lgv=rt[2*k].lgv;
rt[k].val=rt[2*k].val;
}
}
void updY(int k, int x, int y, int a, int val){
if(x>a||y<a)return;
if(x==y){
rt[k].y=val;
rt[k].val=((ll)rt[k].x*(ll)val)%mod;
rt[k].lgv=rt[k].lg+log(val);
return;
}
int m=(x+y)/2;
updY(2*k,x,m,a,val);
updY(2*k+1,m+1,y,a,val);
rt[k].x=((ll)rt[2*k].x*(ll)rt[2*k+1].x)%mod;
rt[k].lg=rt[2*k].lg+rt[2*k+1].lg;
if(rt[2*k].lgv<rt[2*k+1].lgv+rt[2*k].lg){
rt[k].lgv=rt[2*k+1].lgv+rt[2*k].lg;
rt[k].val=((ll)rt[2*k].x*(ll)rt[2*k+1].val)%mod;
}else{
rt[k].lgv=rt[2*k].lgv;
rt[k].val=rt[2*k].val;
}
}
void build(int k, int x, int y){
if(x==y){
rt[k].y=Y[x];
rt[k].x=X[x];
rt[k].lg=log(X[x]);
rt[k].lgv=log(Y[x])+rt[k].lg;
rt[k].val=((ll)rt[k].x*(ll)rt[k].y)%mod;
return;
}
int m=(x+y)/2;
build(2*k,x,m);
build(2*k+1,m+1,y);
rt[k].x=(rt[2*k].x*(ll)rt[2*k+1].x)%mod;
rt[k].lg=rt[2*k].lg+rt[2*k+1].lg;
if(rt[2*k].lgv<rt[2*k+1].lgv+rt[2*k].lg){
rt[k].lgv=rt[2*k+1].lgv+rt[2*k].lg;
rt[k].val=((ll)rt[2*k].x*(ll)rt[2*k+1].val)%mod;
}else{
rt[k].lgv=rt[2*k].lgv;
rt[k].val=rt[2*k].val;
}
}
int init(int N, int X[], int Y[]) {
::N=N;
::X=X;
::Y=Y;
build(1,0,N-1);
return rt[1].val;
}
int updateX(int pos, int val) {
updX(1,0,N-1,pos,val);
return rt[1].val;
}
int updateY(int pos, int val) {
updY(1,0,N-1,pos,val);
return rt[1].val;
}
Compilation message
horses.cpp: In function 'void updX(int, int, int, int, int)':
horses.cpp:25:34: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].val=((ll)val*(ll)rt[k].y)%mod;
~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:32:41: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].x=((ll)rt[2*k].x*(ll)rt[2*k+1].x)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:36:46: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].val=((ll)rt[2*k].x*(ll)rt[2*k+1].val)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'void updY(int, int, int, int, int)':
horses.cpp:47:34: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].val=((ll)rt[k].x*(ll)val)%mod;
~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:54:41: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].x=((ll)rt[2*k].x*(ll)rt[2*k+1].x)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:58:46: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].val=((ll)rt[2*k].x*(ll)rt[2*k+1].val)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:70:38: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].val=((ll)rt[k].x*(ll)rt[k].y)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:76:37: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].x=(rt[2*k].x*(ll)rt[2*k+1].x)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:80:46: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
rt[k].val=((ll)rt[2*k].x*(ll)rt[2*k+1].val)%mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:87:33: warning: declaration of 'Y' shadows a global declaration [-Wshadow]
int init(int N, int X[], int Y[]) {
^
horses.cpp:17:9: note: shadowed declaration is here
int *X,*Y;
^
horses.cpp:87:33: warning: declaration of 'X' shadows a global declaration [-Wshadow]
int init(int N, int X[], int Y[]) {
^
horses.cpp:17:6: note: shadowed declaration is here
int *X,*Y;
^
horses.cpp:87:33: warning: declaration of 'N' shadows a global declaration [-Wshadow]
int init(int N, int X[], int Y[]) {
^
horses.cpp:18:5: note: shadowed declaration is here
int N;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
6 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
256 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
256 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
392 KB |
Output is correct |
30 |
Correct |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
39800 KB |
Output is correct |
2 |
Correct |
204 ms |
50680 KB |
Output is correct |
3 |
Correct |
141 ms |
41848 KB |
Output is correct |
4 |
Correct |
191 ms |
45664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
6 ms |
256 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
4 ms |
256 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
6 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
6 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
79 ms |
37116 KB |
Output is correct |
34 |
Correct |
84 ms |
41080 KB |
Output is correct |
35 |
Correct |
113 ms |
47996 KB |
Output is correct |
36 |
Correct |
116 ms |
47996 KB |
Output is correct |
37 |
Correct |
50 ms |
39288 KB |
Output is correct |
38 |
Correct |
81 ms |
40184 KB |
Output is correct |
39 |
Correct |
46 ms |
39160 KB |
Output is correct |
40 |
Correct |
83 ms |
43128 KB |
Output is correct |
41 |
Correct |
45 ms |
39288 KB |
Output is correct |
42 |
Correct |
46 ms |
39288 KB |
Output is correct |
43 |
Correct |
77 ms |
43512 KB |
Output is correct |
44 |
Correct |
76 ms |
43512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
4 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
4 ms |
256 KB |
Output is correct |
21 |
Correct |
4 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
256 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
106 ms |
39672 KB |
Output is correct |
34 |
Correct |
184 ms |
50680 KB |
Output is correct |
35 |
Correct |
132 ms |
41848 KB |
Output is correct |
36 |
Correct |
183 ms |
45692 KB |
Output is correct |
37 |
Correct |
80 ms |
41080 KB |
Output is correct |
38 |
Correct |
81 ms |
41080 KB |
Output is correct |
39 |
Correct |
112 ms |
48120 KB |
Output is correct |
40 |
Correct |
117 ms |
47992 KB |
Output is correct |
41 |
Correct |
53 ms |
39288 KB |
Output is correct |
42 |
Correct |
79 ms |
40188 KB |
Output is correct |
43 |
Correct |
47 ms |
39160 KB |
Output is correct |
44 |
Correct |
80 ms |
43084 KB |
Output is correct |
45 |
Correct |
52 ms |
39288 KB |
Output is correct |
46 |
Correct |
50 ms |
39328 KB |
Output is correct |
47 |
Correct |
73 ms |
43512 KB |
Output is correct |
48 |
Correct |
75 ms |
43496 KB |
Output is correct |
49 |
Correct |
157 ms |
43132 KB |
Output is correct |
50 |
Correct |
157 ms |
43128 KB |
Output is correct |
51 |
Correct |
157 ms |
49912 KB |
Output is correct |
52 |
Correct |
150 ms |
49496 KB |
Output is correct |
53 |
Correct |
129 ms |
41528 KB |
Output is correct |
54 |
Correct |
122 ms |
41976 KB |
Output is correct |
55 |
Correct |
89 ms |
40184 KB |
Output is correct |
56 |
Correct |
124 ms |
44920 KB |
Output is correct |
57 |
Correct |
89 ms |
40824 KB |
Output is correct |
58 |
Correct |
95 ms |
41336 KB |
Output is correct |
59 |
Correct |
79 ms |
43512 KB |
Output is correct |