# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
248389 |
2020-07-12T10:43:10 Z |
lyc |
Horses (IOI15_horses) |
C++14 |
|
1028 ms |
115832 KB |
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
using ll=long long;
using ii=pair<int,int>;
const int mxN = 5e5+5;
const int mod = 1e9+7;
int N, X[mxN], Y[mxN];
struct node {
int s, e, m;
int px, idx;
long double v, lz;
node *l, *r;
node(int s, int e): s(s), e(e), m((s+e)/2), px(0), idx(s), v(0), lz(0) {
if (s != e) {
l = new node(s,m);
r = new node(m+1,e);
}
}
long double val() {
if (lz != 0) {
v += lz;
if (s != e) {
l->lz += lz;
r->lz += lz;
}
lz = 0;
}
return v;
}
void recalc() {
if (l->val() > r->val()) v = l->val(), idx = l->idx;
else v = r->val(), idx = r->idx;
}
void ux(int i, int x) {
if (s == e) { px = x; return; }
if (i <= m) l->ux(i,x);
else r->ux(i,x);
px = 1LL * l->px * r->px % mod;
}
void av(int i, double x) {
if (s == e) { v += x; return; }
else if (i <= m) l->av(i,x);
else r->av(i,x);
val();
recalc();
}
void av(int i, int j, double x) {
if (s == i && e == j) { lz += x; return; }
if (j <= m) l->av(i,j,x);
else if (i > m) r->av(i,j,x);
else l->av(i,m,x), r->av(m+1,j,x);
val();
recalc();
}
int qx(int i, int j) {
if (s == i && e == j) return px;
if (j <= m) return l->qx(i,j);
if (i > m) return r->qx(i,j);
return 1LL * l->qx(i,m) * r->qx(m+1,j) % mod;
}
void dbg() {
if (s == e) {
cout << s << " :: " << px _ idx _ v _ lz << endl;
} else l->dbg(), r->dbg();
}
} *root;
int calc() { return 1LL * root->qx(0,root->idx) * Y[root->idx] % mod; }
int init(int _N, int _X[], int _Y[]) {
N = _N;
root = new node(0,N-1);
FOR(i,0,N-1) {
X[i] = _X[i], Y[i] = _Y[i];
root->ux(i,X[i]);
root->av(i,N-1,log10(X[i]));
root->av(i,log10(Y[i]));
}
return calc();
}
int updateX(int pos, int val) {
root->av(pos,N-1,-log10(X[pos]));
X[pos] = val;
root->ux(pos,val);
root->av(pos,N-1,log10(val));
return calc();
}
int updateY(int pos, int val) {
root->av(pos,-log10(Y[pos]));
Y[pos] = val;
root->av(pos,log10(val));
return calc();
}
Compilation message
horses.cpp: In constructor 'node::node(int, int)':
horses.cpp:25:23: warning: declaration of 'e' shadows a member of 'node' [-Wshadow]
node(int s, int e): s(s), e(e), m((s+e)/2), px(0), idx(s), v(0), lz(0) {
^
horses.cpp:20:12: note: shadowed declaration is here
int s, e, m;
^
horses.cpp:25:23: warning: declaration of 's' shadows a member of 'node' [-Wshadow]
node(int s, int e): s(s), e(e), m((s+e)/2), px(0), idx(s), v(0), lz(0) {
^
horses.cpp:20:9: note: shadowed declaration is here
int s, e, m;
^
horses.cpp: In member function 'void node::ux(int, int)':
horses.cpp:53:34: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
px = 1LL * l->px * r->px % mod;
~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In member function 'int node::qx(int, int)':
horses.cpp:77:48: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return 1LL * l->qx(i,m) * r->qx(m+1,j) % mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int calc()':
horses.cpp:87:64: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
int calc() { return 1LL * root->qx(0,root->idx) * Y[root->idx] % mod; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
3 ms |
512 KB |
Output is correct |
31 |
Correct |
2 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
653 ms |
104076 KB |
Output is correct |
2 |
Correct |
987 ms |
115832 KB |
Output is correct |
3 |
Correct |
884 ms |
106872 KB |
Output is correct |
4 |
Correct |
1028 ms |
110692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
516 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
1 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
516 KB |
Output is correct |
33 |
Correct |
615 ms |
106220 KB |
Output is correct |
34 |
Correct |
597 ms |
106192 KB |
Output is correct |
35 |
Correct |
686 ms |
111556 KB |
Output is correct |
36 |
Correct |
640 ms |
111608 KB |
Output is correct |
37 |
Correct |
498 ms |
104312 KB |
Output is correct |
38 |
Correct |
608 ms |
105208 KB |
Output is correct |
39 |
Correct |
506 ms |
104184 KB |
Output is correct |
40 |
Correct |
617 ms |
108152 KB |
Output is correct |
41 |
Correct |
487 ms |
104184 KB |
Output is correct |
42 |
Correct |
504 ms |
104312 KB |
Output is correct |
43 |
Correct |
585 ms |
108664 KB |
Output is correct |
44 |
Correct |
592 ms |
108408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
0 ms |
384 KB |
Output is correct |
22 |
Correct |
0 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
2 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
1 ms |
512 KB |
Output is correct |
32 |
Correct |
2 ms |
512 KB |
Output is correct |
33 |
Correct |
684 ms |
106872 KB |
Output is correct |
34 |
Correct |
1010 ms |
115820 KB |
Output is correct |
35 |
Correct |
900 ms |
106876 KB |
Output is correct |
36 |
Correct |
998 ms |
110788 KB |
Output is correct |
37 |
Correct |
615 ms |
106104 KB |
Output is correct |
38 |
Correct |
592 ms |
106144 KB |
Output is correct |
39 |
Correct |
648 ms |
113016 KB |
Output is correct |
40 |
Correct |
637 ms |
113272 KB |
Output is correct |
41 |
Correct |
494 ms |
104312 KB |
Output is correct |
42 |
Correct |
651 ms |
105272 KB |
Output is correct |
43 |
Correct |
486 ms |
104184 KB |
Output is correct |
44 |
Correct |
613 ms |
108136 KB |
Output is correct |
45 |
Correct |
485 ms |
104440 KB |
Output is correct |
46 |
Correct |
501 ms |
104296 KB |
Output is correct |
47 |
Correct |
595 ms |
108496 KB |
Output is correct |
48 |
Correct |
618 ms |
108436 KB |
Output is correct |
49 |
Correct |
942 ms |
108144 KB |
Output is correct |
50 |
Correct |
904 ms |
108168 KB |
Output is correct |
51 |
Correct |
728 ms |
114960 KB |
Output is correct |
52 |
Correct |
724 ms |
114396 KB |
Output is correct |
53 |
Correct |
747 ms |
106616 KB |
Output is correct |
54 |
Correct |
760 ms |
107128 KB |
Output is correct |
55 |
Correct |
608 ms |
105336 KB |
Output is correct |
56 |
Correct |
773 ms |
109908 KB |
Output is correct |
57 |
Correct |
577 ms |
105848 KB |
Output is correct |
58 |
Correct |
571 ms |
106488 KB |
Output is correct |
59 |
Correct |
580 ms |
108664 KB |
Output is correct |