# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
16726 |
2015-09-10T06:14:14 Z |
comet |
Horses (IOI15_horses) |
C++ |
|
344 ms |
54280 KB |
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
//#include "horses.h"
using namespace std;
#define MOD (ll)(1e9+7)
typedef long long ll;
ll N,X[500010],Y[500010];
struct SegTree{
struct node{
ll L,R,E,p;
node(){L=R=E=1;p=500001;}
node(int pos,int val){
L=E=val;
R=1;
p=pos;
}
void write(){
printf("%lld %lld %lld %lld",p,L,R,E);
}
};
vector<node> tree;
int sz;
void init(int n){
for(sz=1;sz<n;sz<<=1);
sz--;
tree.resize(2*sz+10);
}
#define LL (x<<1)
#define RR ((x<<1)+1)
void update(int pos,int val){
int x=pos+sz;
tree[x]=node(pos,val);
x>>=1;
while(x){
ll z=min(MOD,tree[LL].R*tree[RR].L);
/*
printf("x=%d\n",x);
printf("L-> ");tree[LL].write();puts("");
printf("R-> ");tree[RR].write();puts("");
*/
if(Y[tree[LL].p]<z*Y[tree[RR].p]){
//puts("1");
tree[x].p=tree[RR].p;
tree[x].L=min(MOD,tree[LL].E*tree[RR].L);
tree[x].R=tree[RR].R;
tree[x].E=min(MOD,tree[LL].E*tree[RR].E);
}
else{
//puts("2");
tree[x].p=tree[LL].p;
tree[x].L=tree[LL].L;
tree[x].R=min(MOD,tree[LL].R*tree[RR].E);
tree[x].E=min(MOD,tree[LL].E*tree[RR].E);
}
x>>=1;
}
}
int query(){
return tree[1].p;
}
#undef LL
#undef RR
}horse;
struct MUL{
vector<ll> tree;
int sz;
void init(int n){
for(sz=1;sz<n;sz<<=1);
sz--;
tree.resize(2*sz+10,1);
}
void update(int x,int c){
x+=sz;
tree[x]=c;
x>>=1;
while(x){
tree[x]=(tree[x*2]*tree[x*2+1])%MOD;
x>>=1;
}
}
ll query(int L,int R){
L+=sz,R+=sz;
ll ret=1;
while(L<R){
if(L&1)ret=(ret*tree[L++])%MOD;
if(~R&1)ret=(ret*tree[R--])%MOD;
L>>=1,R>>=1;
}
if(L==R)ret=(ret*tree[L])%MOD;
return ret;
}
}mul;
int init(int n, int x[], int y[]) {
N=n;
horse.init(n);
mul.init(n);
for(int i=0;i<n;i++){
X[i+1]=x[i];
Y[i+1]=y[i];
}
for(int i=1;i<=n;i++)horse.update(i,X[i]),mul.update(i,X[i]);
//printf("pos=%d\n",horse.query());
ll ret=mul.query(1,horse.query());
return ret=(ret*Y[horse.query()])%MOD;
}
int updateX(int pos, int val) {
pos++;
X[pos]=val;
horse.update(pos,val);
mul.update(pos,val);
//printf("updateX : pos=%d\n",horse.query());
ll ret=mul.query(1,horse.query());
ret=(ret*Y[horse.query()])%MOD;
return ret;
}
int updateY(int pos, int val) {
pos++;
Y[pos]=val;
horse.update(pos,X[pos]);
//printf("updateY : pos=%d\n",horse.query());
ll ret=mul.query(1,horse.query());
ret=(ret*Y[horse.query()])%MOD;
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9400 KB |
Output is correct |
2 |
Correct |
0 ms |
9400 KB |
Output is correct |
3 |
Correct |
0 ms |
9400 KB |
Output is correct |
4 |
Correct |
0 ms |
9400 KB |
Output is correct |
5 |
Correct |
0 ms |
9400 KB |
Output is correct |
6 |
Correct |
0 ms |
9400 KB |
Output is correct |
7 |
Correct |
0 ms |
9400 KB |
Output is correct |
8 |
Correct |
0 ms |
9400 KB |
Output is correct |
9 |
Correct |
0 ms |
9400 KB |
Output is correct |
10 |
Correct |
0 ms |
9400 KB |
Output is correct |
11 |
Correct |
0 ms |
9400 KB |
Output is correct |
12 |
Correct |
0 ms |
9400 KB |
Output is correct |
13 |
Correct |
0 ms |
9400 KB |
Output is correct |
14 |
Correct |
0 ms |
9400 KB |
Output is correct |
15 |
Correct |
0 ms |
9400 KB |
Output is correct |
16 |
Correct |
0 ms |
9400 KB |
Output is correct |
17 |
Correct |
0 ms |
9400 KB |
Output is correct |
18 |
Correct |
0 ms |
9400 KB |
Output is correct |
19 |
Correct |
0 ms |
9400 KB |
Output is correct |
20 |
Correct |
0 ms |
9400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9400 KB |
Output is correct |
2 |
Correct |
0 ms |
9400 KB |
Output is correct |
3 |
Correct |
0 ms |
9400 KB |
Output is correct |
4 |
Correct |
0 ms |
9400 KB |
Output is correct |
5 |
Correct |
0 ms |
9400 KB |
Output is correct |
6 |
Correct |
0 ms |
9400 KB |
Output is correct |
7 |
Correct |
0 ms |
9400 KB |
Output is correct |
8 |
Correct |
0 ms |
9400 KB |
Output is correct |
9 |
Correct |
0 ms |
9400 KB |
Output is correct |
10 |
Correct |
0 ms |
9400 KB |
Output is correct |
11 |
Correct |
0 ms |
9400 KB |
Output is correct |
12 |
Correct |
0 ms |
9400 KB |
Output is correct |
13 |
Correct |
0 ms |
9400 KB |
Output is correct |
14 |
Correct |
0 ms |
9400 KB |
Output is correct |
15 |
Correct |
0 ms |
9400 KB |
Output is correct |
16 |
Correct |
0 ms |
9400 KB |
Output is correct |
17 |
Correct |
0 ms |
9400 KB |
Output is correct |
18 |
Correct |
0 ms |
9400 KB |
Output is correct |
19 |
Correct |
0 ms |
9400 KB |
Output is correct |
20 |
Correct |
0 ms |
9400 KB |
Output is correct |
21 |
Correct |
0 ms |
9400 KB |
Output is correct |
22 |
Correct |
0 ms |
9400 KB |
Output is correct |
23 |
Correct |
0 ms |
9400 KB |
Output is correct |
24 |
Correct |
1 ms |
9400 KB |
Output is correct |
25 |
Correct |
0 ms |
9400 KB |
Output is correct |
26 |
Correct |
0 ms |
9400 KB |
Output is correct |
27 |
Correct |
0 ms |
9400 KB |
Output is correct |
28 |
Correct |
0 ms |
9400 KB |
Output is correct |
29 |
Correct |
0 ms |
9400 KB |
Output is correct |
30 |
Correct |
0 ms |
9400 KB |
Output is correct |
31 |
Correct |
0 ms |
9400 KB |
Output is correct |
32 |
Correct |
0 ms |
9400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
278 ms |
54280 KB |
Output is correct |
2 |
Correct |
340 ms |
54280 KB |
Output is correct |
3 |
Correct |
327 ms |
54280 KB |
Output is correct |
4 |
Correct |
344 ms |
54280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9400 KB |
Output is correct |
2 |
Correct |
0 ms |
9400 KB |
Output is correct |
3 |
Correct |
0 ms |
9400 KB |
Output is correct |
4 |
Correct |
0 ms |
9400 KB |
Output is correct |
5 |
Correct |
0 ms |
9400 KB |
Output is correct |
6 |
Correct |
0 ms |
9400 KB |
Output is correct |
7 |
Correct |
0 ms |
9400 KB |
Output is correct |
8 |
Correct |
0 ms |
9400 KB |
Output is correct |
9 |
Correct |
0 ms |
9400 KB |
Output is correct |
10 |
Correct |
0 ms |
9400 KB |
Output is correct |
11 |
Correct |
0 ms |
9400 KB |
Output is correct |
12 |
Correct |
0 ms |
9400 KB |
Output is correct |
13 |
Correct |
0 ms |
9400 KB |
Output is correct |
14 |
Correct |
0 ms |
9400 KB |
Output is correct |
15 |
Correct |
0 ms |
9400 KB |
Output is correct |
16 |
Correct |
0 ms |
9400 KB |
Output is correct |
17 |
Correct |
0 ms |
9400 KB |
Output is correct |
18 |
Correct |
0 ms |
9400 KB |
Output is correct |
19 |
Correct |
0 ms |
9400 KB |
Output is correct |
20 |
Correct |
0 ms |
9400 KB |
Output is correct |
21 |
Correct |
0 ms |
9400 KB |
Output is correct |
22 |
Correct |
0 ms |
9400 KB |
Output is correct |
23 |
Correct |
0 ms |
9400 KB |
Output is correct |
24 |
Correct |
0 ms |
9400 KB |
Output is correct |
25 |
Correct |
0 ms |
9400 KB |
Output is correct |
26 |
Correct |
0 ms |
9400 KB |
Output is correct |
27 |
Correct |
0 ms |
9400 KB |
Output is correct |
28 |
Correct |
0 ms |
9400 KB |
Output is correct |
29 |
Correct |
0 ms |
9400 KB |
Output is correct |
30 |
Correct |
0 ms |
9400 KB |
Output is correct |
31 |
Correct |
0 ms |
9400 KB |
Output is correct |
32 |
Correct |
0 ms |
9400 KB |
Output is correct |
33 |
Correct |
213 ms |
54280 KB |
Output is correct |
34 |
Correct |
200 ms |
54280 KB |
Output is correct |
35 |
Correct |
249 ms |
54280 KB |
Output is correct |
36 |
Correct |
301 ms |
54280 KB |
Output is correct |
37 |
Correct |
187 ms |
54280 KB |
Output is correct |
38 |
Correct |
232 ms |
54280 KB |
Output is correct |
39 |
Correct |
180 ms |
54280 KB |
Output is correct |
40 |
Correct |
249 ms |
54280 KB |
Output is correct |
41 |
Correct |
179 ms |
54280 KB |
Output is correct |
42 |
Correct |
176 ms |
54280 KB |
Output is correct |
43 |
Correct |
253 ms |
54280 KB |
Output is correct |
44 |
Correct |
253 ms |
54280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9400 KB |
Output is correct |
2 |
Correct |
0 ms |
9400 KB |
Output is correct |
3 |
Correct |
0 ms |
9400 KB |
Output is correct |
4 |
Correct |
0 ms |
9400 KB |
Output is correct |
5 |
Correct |
0 ms |
9400 KB |
Output is correct |
6 |
Correct |
0 ms |
9400 KB |
Output is correct |
7 |
Correct |
0 ms |
9400 KB |
Output is correct |
8 |
Correct |
0 ms |
9400 KB |
Output is correct |
9 |
Correct |
0 ms |
9400 KB |
Output is correct |
10 |
Correct |
0 ms |
9400 KB |
Output is correct |
11 |
Correct |
0 ms |
9400 KB |
Output is correct |
12 |
Correct |
0 ms |
9400 KB |
Output is correct |
13 |
Correct |
0 ms |
9400 KB |
Output is correct |
14 |
Correct |
0 ms |
9400 KB |
Output is correct |
15 |
Correct |
0 ms |
9400 KB |
Output is correct |
16 |
Correct |
0 ms |
9400 KB |
Output is correct |
17 |
Correct |
0 ms |
9400 KB |
Output is correct |
18 |
Correct |
0 ms |
9400 KB |
Output is correct |
19 |
Correct |
0 ms |
9400 KB |
Output is correct |
20 |
Correct |
0 ms |
9400 KB |
Output is correct |
21 |
Correct |
0 ms |
9400 KB |
Output is correct |
22 |
Correct |
0 ms |
9400 KB |
Output is correct |
23 |
Correct |
0 ms |
9400 KB |
Output is correct |
24 |
Correct |
0 ms |
9400 KB |
Output is correct |
25 |
Correct |
1 ms |
9400 KB |
Output is correct |
26 |
Correct |
0 ms |
9400 KB |
Output is correct |
27 |
Correct |
0 ms |
9400 KB |
Output is correct |
28 |
Correct |
0 ms |
9400 KB |
Output is correct |
29 |
Correct |
0 ms |
9400 KB |
Output is correct |
30 |
Correct |
0 ms |
9400 KB |
Output is correct |
31 |
Correct |
1 ms |
9400 KB |
Output is correct |
32 |
Correct |
0 ms |
9400 KB |
Output is correct |
33 |
Correct |
292 ms |
54280 KB |
Output is correct |
34 |
Correct |
331 ms |
54280 KB |
Output is correct |
35 |
Correct |
308 ms |
54280 KB |
Output is correct |
36 |
Correct |
320 ms |
54280 KB |
Output is correct |
37 |
Correct |
206 ms |
54280 KB |
Output is correct |
38 |
Correct |
215 ms |
54280 KB |
Output is correct |
39 |
Correct |
285 ms |
54280 KB |
Output is correct |
40 |
Correct |
252 ms |
54280 KB |
Output is correct |
41 |
Correct |
196 ms |
54280 KB |
Output is correct |
42 |
Correct |
221 ms |
54280 KB |
Output is correct |
43 |
Correct |
179 ms |
54280 KB |
Output is correct |
44 |
Correct |
256 ms |
54280 KB |
Output is correct |
45 |
Correct |
183 ms |
54280 KB |
Output is correct |
46 |
Correct |
198 ms |
54280 KB |
Output is correct |
47 |
Correct |
219 ms |
54280 KB |
Output is correct |
48 |
Correct |
277 ms |
54280 KB |
Output is correct |
49 |
Correct |
289 ms |
54280 KB |
Output is correct |
50 |
Correct |
295 ms |
54280 KB |
Output is correct |
51 |
Correct |
313 ms |
54280 KB |
Output is correct |
52 |
Correct |
321 ms |
54280 KB |
Output is correct |
53 |
Correct |
272 ms |
54280 KB |
Output is correct |
54 |
Correct |
290 ms |
54280 KB |
Output is correct |
55 |
Correct |
240 ms |
54280 KB |
Output is correct |
56 |
Correct |
320 ms |
54280 KB |
Output is correct |
57 |
Correct |
221 ms |
54280 KB |
Output is correct |
58 |
Correct |
225 ms |
54280 KB |
Output is correct |
59 |
Correct |
227 ms |
54280 KB |
Output is correct |