# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
332320 |
2020-12-02T03:27:09 Z |
Azert |
말 (IOI15_horses) |
C++14 |
|
1044 ms |
25324 KB |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 4;
const int MAX = 5e5 + 5;
const int MOD = 1e9 + 7;
int n;
int x[MAX], y[MAX];
int m[MAX * 4], mm[MAX * 4], st[MAX * 4];
void initMul(int idx, int l, int r) {
if (l == r) {
m[idx] = mm[idx] = x[l];
return;
}
int mid = (l + r) / 2;
initMul(idx * 2, l, mid);
initMul(idx * 2 + 1, mid + 1, r);
m[idx] = (1LL * m[idx * 2] * m[idx * 2 + 1]) % MOD;
mm[idx] = min(INF, 1LL * mm[idx * 2 + 1] * mm[idx * 2]);
}
int get(int idx, int l, int r, int posL, int posR, int type) {
if (posR < l || posL > r) return 1;
if (posL <= l && r <= posR) return type? m[idx] : mm[idx];
int mid = (l + r) / 2;
if (type) {
return (1LL * get(idx * 2, l, mid, posL, posR, type) * get(idx * 2 + 1, mid + 1, r, posL, posR, type)) % MOD;
}
return min(INF, 1LL * get(idx * 2, l, mid, posL, posR, type) * get(idx * 2 + 1, mid + 1, r, posL, posR, type));
}
void initSt(int idx, int l, int r) {
if (l == r) {
st[idx] = l;
return;
}
int mid = (l + r) / 2;
initSt(idx * 2, l, mid);
initSt(idx * 2 + 1, mid + 1, r);
int ll = st[idx * 2];
int rr = st[idx * 2 + 1];
if (1LL * y[rr] * get(1, 0, n - 1, ll + 1, rr, 0) >= y[ll]) st[idx] = rr;
else st[idx] = ll;
}
int get() {
int pos = st[1];
return (1LL * get(1, 0, n - 1, 0, pos, 1) * y[pos]) % MOD;
}
void updateM(int idx, int l, int r, int pos) {
if (pos < l || pos > r) return;
if (l == r) {
m[idx] = mm[idx] = x[pos];
return;
}
int mid = (l + r) / 2;
updateM(idx * 2, l, mid, pos);
updateM(idx * 2 + 1, mid + 1, r, pos);
m[idx] = (1LL * m[idx * 2] * m[idx * 2 + 1]) % MOD;
mm[idx] = min(INF, 1LL * mm[idx * 2 + 1] * mm[idx * 2]);
}
void update(int idx, int l, int r, int pos) {
if (pos > r || pos < l) return;
if (l == r) return;
int mid = (l + r) / 2;
update(idx * 2, l, mid, pos);
update(idx * 2 + 1, mid + 1, r, pos);
int ll = st[idx * 2];
int rr = st[idx * 2 + 1];
if (1LL * y[rr] * get(1, 0, n - 1, ll + 1, rr, 0) >= y[ll]) st[idx] = rr;
else st[idx] = ll;
}
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];
initMul(1, 0, n - 1);
// exit(0);
initSt(1, 0, n - 1);
return get();
}
int updateX(int pos, int val) {
x[pos] = val;
updateM(1, 0, n - 1, pos);
update(1, 0, n - 1, pos);
return get();
}
int updateY(int pos, int val) {
y[pos] = val;
update(1, 0, n - 1, pos);
return get();
}
// // #ifdef ONLINE_JUDGE
// int main() {
// int xx[2] = {1000000000, 1000000000};
// int yy[3] = {1000000000, 1000000000};
// cout << init(2, xx, yy) << "\n";
// // cout << updateY(1, 2) << "\n";
// }
// #endif
Compilation message
horses.cpp: In function 'void initMul(int, int, int)':
horses.cpp:21:50: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
21 | m[idx] = (1LL * m[idx * 2] * m[idx * 2 + 1]) % MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:22:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
22 | mm[idx] = min(INF, 1LL * mm[idx * 2 + 1] * mm[idx * 2]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int get(int, int, int, int, int, int)':
horses.cpp:32:112: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
32 | return (1LL * get(idx * 2, l, mid, posL, posR, type) * get(idx * 2 + 1, mid + 1, r, posL, posR, type)) % MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:34:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
34 | return min(INF, 1LL * get(idx * 2, l, mid, posL, posR, type) * get(idx * 2 + 1, mid + 1, r, posL, posR, type));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int get()':
horses.cpp:55:57: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
55 | return (1LL * get(1, 0, n - 1, 0, pos, 1) * y[pos]) % MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'void updateM(int, int, int, int)':
horses.cpp:70:50: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
70 | m[idx] = (1LL * m[idx * 2] * m[idx * 2 + 1]) % MOD;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:71:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
71 | mm[idx] = min(INF, 1LL * mm[idx * 2 + 1] * mm[idx * 2]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
0 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
0 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
0 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
496 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
3 ms |
364 KB |
Output is correct |
24 |
Correct |
3 ms |
364 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
15 ms |
492 KB |
Output is correct |
27 |
Correct |
3 ms |
364 KB |
Output is correct |
28 |
Correct |
3 ms |
396 KB |
Output is correct |
29 |
Correct |
2 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
2 ms |
364 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
618 ms |
21680 KB |
Output is correct |
2 |
Correct |
606 ms |
21740 KB |
Output is correct |
3 |
Correct |
813 ms |
25220 KB |
Output is correct |
4 |
Correct |
775 ms |
25324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
3 ms |
364 KB |
Output is correct |
24 |
Correct |
3 ms |
364 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
2 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
364 KB |
Output is correct |
28 |
Correct |
2 ms |
364 KB |
Output is correct |
29 |
Correct |
3 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
3 ms |
396 KB |
Output is correct |
32 |
Correct |
2 ms |
364 KB |
Output is correct |
33 |
Correct |
270 ms |
24164 KB |
Output is correct |
34 |
Correct |
264 ms |
24116 KB |
Output is correct |
35 |
Correct |
233 ms |
23020 KB |
Output is correct |
36 |
Correct |
201 ms |
22892 KB |
Output is correct |
37 |
Correct |
211 ms |
22636 KB |
Output is correct |
38 |
Correct |
214 ms |
23532 KB |
Output is correct |
39 |
Correct |
176 ms |
22508 KB |
Output is correct |
40 |
Correct |
193 ms |
23948 KB |
Output is correct |
41 |
Correct |
189 ms |
22764 KB |
Output is correct |
42 |
Correct |
184 ms |
22636 KB |
Output is correct |
43 |
Correct |
185 ms |
23276 KB |
Output is correct |
44 |
Correct |
169 ms |
23276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
3 ms |
364 KB |
Output is correct |
24 |
Correct |
4 ms |
624 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
2 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
364 KB |
Output is correct |
28 |
Correct |
2 ms |
364 KB |
Output is correct |
29 |
Correct |
2 ms |
364 KB |
Output is correct |
30 |
Correct |
2 ms |
364 KB |
Output is correct |
31 |
Correct |
2 ms |
364 KB |
Output is correct |
32 |
Correct |
3 ms |
364 KB |
Output is correct |
33 |
Correct |
591 ms |
24400 KB |
Output is correct |
34 |
Correct |
606 ms |
23404 KB |
Output is correct |
35 |
Correct |
771 ms |
24232 KB |
Output is correct |
36 |
Correct |
775 ms |
23692 KB |
Output is correct |
37 |
Correct |
258 ms |
23276 KB |
Output is correct |
38 |
Correct |
250 ms |
23276 KB |
Output is correct |
39 |
Correct |
227 ms |
22380 KB |
Output is correct |
40 |
Correct |
204 ms |
22508 KB |
Output is correct |
41 |
Correct |
214 ms |
22764 KB |
Output is correct |
42 |
Correct |
201 ms |
23404 KB |
Output is correct |
43 |
Correct |
175 ms |
22764 KB |
Output is correct |
44 |
Correct |
193 ms |
22636 KB |
Output is correct |
45 |
Correct |
198 ms |
22636 KB |
Output is correct |
46 |
Correct |
184 ms |
22636 KB |
Output is correct |
47 |
Correct |
164 ms |
22636 KB |
Output is correct |
48 |
Correct |
165 ms |
22636 KB |
Output is correct |
49 |
Correct |
1044 ms |
24152 KB |
Output is correct |
50 |
Correct |
995 ms |
24204 KB |
Output is correct |
51 |
Correct |
643 ms |
23404 KB |
Output is correct |
52 |
Correct |
404 ms |
23404 KB |
Output is correct |
53 |
Correct |
795 ms |
24172 KB |
Output is correct |
54 |
Correct |
614 ms |
24300 KB |
Output is correct |
55 |
Correct |
423 ms |
23404 KB |
Output is correct |
56 |
Correct |
451 ms |
23660 KB |
Output is correct |
57 |
Correct |
552 ms |
24172 KB |
Output is correct |
58 |
Correct |
542 ms |
24428 KB |
Output is correct |
59 |
Correct |
164 ms |
22508 KB |
Output is correct |