# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
284385 |
2020-08-27T10:19:37 Z |
SamAnd |
Horses (IOI15_horses) |
C++17 |
|
467 ms |
68856 KB |
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int N = 500005, M = 1000000007;
int n;
struct ban
{
int ans;
int p;
int pl, pr, pp;
int y;
ban()
{
ans = 1;
p = 1;
pl = 1;
pr = 1;
}
ban(int x, int y)
{
ans = (x * 1LL * y) % M;
p = x;
pl = x;
pr = 1;
pp = x;
this->y = y;
}
};
ban t[N * 4];
ban mer(const ban& l, const ban& r)
{
ban res;
if (r.pl == M || l.pr == M)
{
res.ans = (l.p * 1LL * r.ans) % M;
res.p = (l.p * 1LL * r.p) % M;
res.pl = min(M * 1LL, l.pp * 1LL * r.pl);
res.pr = r.pr;
res.pp = min(M * 1LL, l.pp * 1LL * r.pp);
res.y = r.y;
}
else
{
if ((long double)l.y / r.y < (r.pl * 1LL * l.pr))
{
res.ans = (l.p * 1LL * r.ans) % M;
res.p = (l.p * 1LL * r.p) % M;
res.pl = min(M * 1LL, l.pp * 1LL * r.pl);
res.pr = r.pr;
res.pp = min(M * 1LL, l.pp * 1LL * r.pp);
res.y = r.y;
}
else
{
res.ans = l.ans;
res.p = (l.p * 1LL * r.p) % M;
res.pl = l.pl;
res.pr = min(M * 1LL, l.pr * 1LL * r.pp);
res.pp = min(M * 1LL, l.pp * 1LL * r.pp);
res.y = l.y;
}
}
return res;
}
void ubd(int tl, int tr, int x, int xx, int yy, int pos)
{
if (tl == tr)
{
t[pos] = ban(xx, yy);
return;
}
int m = (tl + tr) / 2;
if (x <= m)
ubd(tl, m, x, xx, yy, pos * 2);
else
ubd(m + 1, tr, x, xx, yy, pos * 2 + 1);
t[pos] = mer(t[pos * 2], t[pos * 2 + 1]);
}
int X[N], Y[N];
int init(int N_, int X[], int Y[])
{
n = N_;
for (int i = 0; i < n; ++i)
{
::X[i] = X[i];
::Y[i] = Y[i];
}
for (int i = 0; i < n; ++i)
ubd(0, n - 1, i, X[i], Y[i], 1);
return t[1].ans;
}
int updateX(int pos, int val)
{
X[pos] = val;
ubd(0, n - 1, pos, X[pos], Y[pos], 1);
return t[1].ans;
}
int updateY(int pos, int val)
{
Y[pos] = val;
ubd(0, n - 1, pos, X[pos], Y[pos], 1);
return t[1].ans;
}
Compilation message
horses.cpp: In constructor 'ban::ban(int, int)':
horses.cpp:28:5: warning: declaration of 'y' shadows a member of 'ban' [-Wshadow]
28 | {
| ^
horses.cpp:19:9: note: shadowed declaration is here
19 | int y;
| ^
horses.cpp:29:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
29 | ans = (x * 1LL * y) % M;
| ~~~~~~~~~~~~~~^~~
horses.cpp: In constructor 'ban::ban(int, int)':
horses.cpp:35:5: warning: declaration of 'y' shadows a member of 'ban' [-Wshadow]
35 | }
| ^
horses.cpp:19:9: note: shadowed declaration is here
19 | int y;
| ^
horses.cpp: In constructor 'ban::ban(int, int)':
horses.cpp:35:5: warning: declaration of 'y' shadows a member of 'ban' [-Wshadow]
35 | }
| ^
horses.cpp:19:9: note: shadowed declaration is here
19 | int y;
| ^
horses.cpp: In function 'ban mer(const ban&, const ban&)':
horses.cpp:45:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
45 | res.ans = (l.p * 1LL * r.ans) % M;
| ~~~~~~~~~~~~~~~~~~~~^~~
horses.cpp:46:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
46 | res.p = (l.p * 1LL * r.p) % M;
| ~~~~~~~~~~~~~~~~~~^~~
horses.cpp:47:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
47 | res.pl = min(M * 1LL, l.pp * 1LL * r.pl);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:49:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
49 | res.pp = min(M * 1LL, l.pp * 1LL * r.pp);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:56:43: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
56 | res.ans = (l.p * 1LL * r.ans) % M;
| ~~~~~~~~~~~~~~~~~~~~^~~
horses.cpp:57:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
57 | res.p = (l.p * 1LL * r.p) % M;
| ~~~~~~~~~~~~~~~~~~^~~
horses.cpp:58:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
58 | res.pl = min(M * 1LL, l.pp * 1LL * r.pl);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:60:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
60 | res.pp = min(M * 1LL, l.pp * 1LL * r.pp);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:66:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
66 | res.p = (l.p * 1LL * r.p) % M;
| ~~~~~~~~~~~~~~~~~~^~~
horses.cpp:68:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
68 | res.pr = min(M * 1LL, l.pr * 1LL * r.pp);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:69:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
69 | res.pp = min(M * 1LL, l.pp * 1LL * r.pp);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:92:34: warning: declaration of 'Y' shadows a global declaration [-Wshadow]
92 | int init(int N_, int X[], int Y[])
| ^
horses.cpp:91:11: note: shadowed declaration is here
91 | int X[N], Y[N];
| ^
horses.cpp:92:34: warning: declaration of 'X' shadows a global declaration [-Wshadow]
92 | int init(int N_, int X[], int Y[])
| ^
horses.cpp:91:5: note: shadowed declaration is here
91 | int X[N], Y[N];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
47224 KB |
Output is correct |
2 |
Correct |
29 ms |
47228 KB |
Output is correct |
3 |
Correct |
28 ms |
47232 KB |
Output is correct |
4 |
Correct |
29 ms |
47232 KB |
Output is correct |
5 |
Correct |
29 ms |
47232 KB |
Output is correct |
6 |
Correct |
28 ms |
47352 KB |
Output is correct |
7 |
Correct |
29 ms |
47360 KB |
Output is correct |
8 |
Correct |
29 ms |
47316 KB |
Output is correct |
9 |
Correct |
32 ms |
47232 KB |
Output is correct |
10 |
Correct |
33 ms |
47232 KB |
Output is correct |
11 |
Correct |
29 ms |
47352 KB |
Output is correct |
12 |
Correct |
28 ms |
47360 KB |
Output is correct |
13 |
Correct |
33 ms |
47224 KB |
Output is correct |
14 |
Correct |
29 ms |
47232 KB |
Output is correct |
15 |
Correct |
28 ms |
47232 KB |
Output is correct |
16 |
Correct |
29 ms |
47232 KB |
Output is correct |
17 |
Correct |
32 ms |
47232 KB |
Output is correct |
18 |
Correct |
32 ms |
47224 KB |
Output is correct |
19 |
Correct |
29 ms |
47360 KB |
Output is correct |
20 |
Correct |
29 ms |
47232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
47224 KB |
Output is correct |
2 |
Correct |
34 ms |
47232 KB |
Output is correct |
3 |
Correct |
29 ms |
47224 KB |
Output is correct |
4 |
Correct |
29 ms |
47232 KB |
Output is correct |
5 |
Correct |
28 ms |
47232 KB |
Output is correct |
6 |
Correct |
29 ms |
47360 KB |
Output is correct |
7 |
Correct |
28 ms |
47232 KB |
Output is correct |
8 |
Correct |
29 ms |
47360 KB |
Output is correct |
9 |
Correct |
29 ms |
47224 KB |
Output is correct |
10 |
Correct |
28 ms |
47252 KB |
Output is correct |
11 |
Correct |
29 ms |
47232 KB |
Output is correct |
12 |
Correct |
29 ms |
47232 KB |
Output is correct |
13 |
Correct |
29 ms |
47360 KB |
Output is correct |
14 |
Correct |
28 ms |
47360 KB |
Output is correct |
15 |
Correct |
29 ms |
47232 KB |
Output is correct |
16 |
Correct |
28 ms |
47352 KB |
Output is correct |
17 |
Correct |
29 ms |
47352 KB |
Output is correct |
18 |
Correct |
29 ms |
47224 KB |
Output is correct |
19 |
Correct |
28 ms |
47360 KB |
Output is correct |
20 |
Correct |
29 ms |
47232 KB |
Output is correct |
21 |
Correct |
29 ms |
47232 KB |
Output is correct |
22 |
Correct |
29 ms |
47232 KB |
Output is correct |
23 |
Correct |
30 ms |
47356 KB |
Output is correct |
24 |
Correct |
29 ms |
47352 KB |
Output is correct |
25 |
Correct |
32 ms |
47360 KB |
Output is correct |
26 |
Correct |
30 ms |
47352 KB |
Output is correct |
27 |
Correct |
29 ms |
47352 KB |
Output is correct |
28 |
Correct |
29 ms |
47360 KB |
Output is correct |
29 |
Correct |
30 ms |
47360 KB |
Output is correct |
30 |
Correct |
31 ms |
47352 KB |
Output is correct |
31 |
Correct |
29 ms |
47360 KB |
Output is correct |
32 |
Correct |
31 ms |
47352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
362 ms |
59768 KB |
Output is correct |
2 |
Correct |
460 ms |
68728 KB |
Output is correct |
3 |
Correct |
436 ms |
60012 KB |
Output is correct |
4 |
Correct |
446 ms |
63736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
47352 KB |
Output is correct |
2 |
Correct |
34 ms |
47224 KB |
Output is correct |
3 |
Correct |
29 ms |
47224 KB |
Output is correct |
4 |
Correct |
28 ms |
47232 KB |
Output is correct |
5 |
Correct |
28 ms |
47360 KB |
Output is correct |
6 |
Correct |
30 ms |
47232 KB |
Output is correct |
7 |
Correct |
32 ms |
47232 KB |
Output is correct |
8 |
Correct |
28 ms |
47232 KB |
Output is correct |
9 |
Correct |
32 ms |
47352 KB |
Output is correct |
10 |
Correct |
28 ms |
47232 KB |
Output is correct |
11 |
Correct |
33 ms |
47352 KB |
Output is correct |
12 |
Correct |
29 ms |
47232 KB |
Output is correct |
13 |
Correct |
30 ms |
47232 KB |
Output is correct |
14 |
Correct |
29 ms |
47232 KB |
Output is correct |
15 |
Correct |
29 ms |
47360 KB |
Output is correct |
16 |
Correct |
28 ms |
47232 KB |
Output is correct |
17 |
Correct |
28 ms |
47352 KB |
Output is correct |
18 |
Correct |
28 ms |
47224 KB |
Output is correct |
19 |
Correct |
29 ms |
47224 KB |
Output is correct |
20 |
Correct |
29 ms |
47352 KB |
Output is correct |
21 |
Correct |
30 ms |
47480 KB |
Output is correct |
22 |
Correct |
29 ms |
47352 KB |
Output is correct |
23 |
Correct |
29 ms |
47356 KB |
Output is correct |
24 |
Correct |
30 ms |
47352 KB |
Output is correct |
25 |
Correct |
34 ms |
47352 KB |
Output is correct |
26 |
Correct |
30 ms |
47452 KB |
Output is correct |
27 |
Correct |
30 ms |
47352 KB |
Output is correct |
28 |
Correct |
29 ms |
47360 KB |
Output is correct |
29 |
Correct |
30 ms |
47352 KB |
Output is correct |
30 |
Correct |
30 ms |
47352 KB |
Output is correct |
31 |
Correct |
32 ms |
47352 KB |
Output is correct |
32 |
Correct |
29 ms |
47360 KB |
Output is correct |
33 |
Correct |
339 ms |
59112 KB |
Output is correct |
34 |
Correct |
344 ms |
59128 KB |
Output is correct |
35 |
Correct |
342 ms |
66040 KB |
Output is correct |
36 |
Correct |
353 ms |
66040 KB |
Output is correct |
37 |
Correct |
321 ms |
57336 KB |
Output is correct |
38 |
Correct |
332 ms |
58232 KB |
Output is correct |
39 |
Correct |
298 ms |
57208 KB |
Output is correct |
40 |
Correct |
314 ms |
61176 KB |
Output is correct |
41 |
Correct |
299 ms |
57208 KB |
Output is correct |
42 |
Correct |
317 ms |
57336 KB |
Output is correct |
43 |
Correct |
318 ms |
61560 KB |
Output is correct |
44 |
Correct |
310 ms |
61560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
47232 KB |
Output is correct |
2 |
Correct |
28 ms |
47232 KB |
Output is correct |
3 |
Correct |
29 ms |
47232 KB |
Output is correct |
4 |
Correct |
28 ms |
47232 KB |
Output is correct |
5 |
Correct |
29 ms |
47360 KB |
Output is correct |
6 |
Correct |
29 ms |
47232 KB |
Output is correct |
7 |
Correct |
28 ms |
47232 KB |
Output is correct |
8 |
Correct |
29 ms |
47224 KB |
Output is correct |
9 |
Correct |
30 ms |
47232 KB |
Output is correct |
10 |
Correct |
29 ms |
47232 KB |
Output is correct |
11 |
Correct |
28 ms |
47360 KB |
Output is correct |
12 |
Correct |
28 ms |
47232 KB |
Output is correct |
13 |
Correct |
29 ms |
47232 KB |
Output is correct |
14 |
Correct |
28 ms |
47224 KB |
Output is correct |
15 |
Correct |
29 ms |
47224 KB |
Output is correct |
16 |
Correct |
29 ms |
47360 KB |
Output is correct |
17 |
Correct |
29 ms |
47232 KB |
Output is correct |
18 |
Correct |
28 ms |
47232 KB |
Output is correct |
19 |
Correct |
29 ms |
47360 KB |
Output is correct |
20 |
Correct |
29 ms |
47352 KB |
Output is correct |
21 |
Correct |
29 ms |
47228 KB |
Output is correct |
22 |
Correct |
29 ms |
47232 KB |
Output is correct |
23 |
Correct |
29 ms |
47360 KB |
Output is correct |
24 |
Correct |
29 ms |
47352 KB |
Output is correct |
25 |
Correct |
29 ms |
47360 KB |
Output is correct |
26 |
Correct |
29 ms |
47352 KB |
Output is correct |
27 |
Correct |
29 ms |
47352 KB |
Output is correct |
28 |
Correct |
30 ms |
47360 KB |
Output is correct |
29 |
Correct |
31 ms |
47352 KB |
Output is correct |
30 |
Correct |
29 ms |
47360 KB |
Output is correct |
31 |
Correct |
29 ms |
47352 KB |
Output is correct |
32 |
Correct |
29 ms |
47360 KB |
Output is correct |
33 |
Correct |
368 ms |
60024 KB |
Output is correct |
34 |
Correct |
463 ms |
68856 KB |
Output is correct |
35 |
Correct |
437 ms |
59896 KB |
Output is correct |
36 |
Correct |
467 ms |
63864 KB |
Output is correct |
37 |
Correct |
344 ms |
59256 KB |
Output is correct |
38 |
Correct |
342 ms |
59128 KB |
Output is correct |
39 |
Correct |
335 ms |
66040 KB |
Output is correct |
40 |
Correct |
337 ms |
66168 KB |
Output is correct |
41 |
Correct |
308 ms |
57336 KB |
Output is correct |
42 |
Correct |
312 ms |
58180 KB |
Output is correct |
43 |
Correct |
302 ms |
57208 KB |
Output is correct |
44 |
Correct |
323 ms |
61072 KB |
Output is correct |
45 |
Correct |
303 ms |
57208 KB |
Output is correct |
46 |
Correct |
304 ms |
57260 KB |
Output is correct |
47 |
Correct |
315 ms |
61560 KB |
Output is correct |
48 |
Correct |
303 ms |
61560 KB |
Output is correct |
49 |
Correct |
465 ms |
61176 KB |
Output is correct |
50 |
Correct |
458 ms |
61176 KB |
Output is correct |
51 |
Correct |
394 ms |
67960 KB |
Output is correct |
52 |
Correct |
390 ms |
67436 KB |
Output is correct |
53 |
Correct |
434 ms |
59512 KB |
Output is correct |
54 |
Correct |
378 ms |
60016 KB |
Output is correct |
55 |
Correct |
362 ms |
58360 KB |
Output is correct |
56 |
Correct |
396 ms |
62968 KB |
Output is correct |
57 |
Correct |
380 ms |
58872 KB |
Output is correct |
58 |
Correct |
378 ms |
59384 KB |
Output is correct |
59 |
Correct |
307 ms |
61560 KB |
Output is correct |