# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
819915 |
2023-08-10T15:28:22 Z |
Kerim |
말 (IOI15_horses) |
C++17 |
|
1500 ms |
28376 KB |
#include "horses.h"
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 5e5+5;
const int INF = 1e9+7;
int a[MAXN], b[MAXN], n;
struct node{
int mul, mod;
node(){
mul = mod = 0;
}
node(int _mul, int _mod){
mul = _mul;
mod = _mod;
}
}s[MAXN<<2];
int ans[MAXN<<2];
node merge(node x, node y){
node z = node(0, 0);
z.mul = min(x.mul * 1LL * y.mul, INF * 1LL);
z.mod = (x.mod * 1LL * y.mod) % INF;
return z;
}
node get(int l, int r, int nd, int x, int y){
if (l > y or x > r)
return node(1, 1);
if (l <= x and y <= r)
return s[nd];
int mid = (x+y) >> 1;
return merge(get(l, r, nd<<1, x, mid), get(l, r, nd<<1|1, mid+1, y));
}
int cmp(int x, int y){
if (x == y)
return 0;
if (x > y)
swap(x, y);
return b[x] < b[y] * 1LL * get(x+1, y, 1, 0, n-1).mul;
}
void upd(int p, int nd, int x, int y){
if (x == y){
ans[nd] = x;
s[nd].mul = s[nd].mod = a[p];
return;
}
int mid = (x+y) >> 1;
if (p <= mid)
upd(p, nd<<1, x, mid);
else
upd(p, nd<<1|1, mid+1, y);
s[nd] = merge(s[nd<<1], s[nd<<1|1]);
if (cmp(ans[nd<<1], ans[nd<<1|1]))
ans[nd] = ans[nd<<1|1];
else
ans[nd] = ans[nd<<1];
}
int ask(int pos){
return (get(0, pos, 1, 0, n-1).mod *1LL* b[pos]) % INF;
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i = 0; i < n; i++){
a[i] = X[i], b[i] = Y[i];
upd(i, 1, 0, n-1);
}
return ask(ans[1]);
}
int updateX(int pos, int val) {
a[pos] = val;
upd(pos, 1, 0, n-1);
return ask(ans[1]);
}
int updateY(int pos, int val) {
b[pos] = val;
upd(pos, 1, 0, n-1);
return ask(ans[1]);
}
Compilation message
horses.cpp: In function 'node merge(node, node)':
horses.cpp:23:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
23 | z.mul = min(x.mul * 1LL * y.mul, INF * 1LL);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:24:32: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
24 | z.mod = (x.mod * 1LL * y.mod) % INF;
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int ask(int)':
horses.cpp:65:51: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
65 | return (get(0, pos, 1, 0, n-1).mod *1LL* b[pos]) % INF;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15956 KB |
Output is correct |
3 |
Correct |
7 ms |
15968 KB |
Output is correct |
4 |
Correct |
7 ms |
15940 KB |
Output is correct |
5 |
Correct |
7 ms |
15956 KB |
Output is correct |
6 |
Correct |
7 ms |
15956 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
9 ms |
15956 KB |
Output is correct |
9 |
Correct |
9 ms |
15864 KB |
Output is correct |
10 |
Correct |
8 ms |
15956 KB |
Output is correct |
11 |
Correct |
7 ms |
15888 KB |
Output is correct |
12 |
Correct |
7 ms |
15956 KB |
Output is correct |
13 |
Correct |
7 ms |
15956 KB |
Output is correct |
14 |
Correct |
7 ms |
15956 KB |
Output is correct |
15 |
Correct |
7 ms |
15924 KB |
Output is correct |
16 |
Correct |
7 ms |
15956 KB |
Output is correct |
17 |
Correct |
7 ms |
15956 KB |
Output is correct |
18 |
Correct |
7 ms |
15944 KB |
Output is correct |
19 |
Correct |
12 ms |
15956 KB |
Output is correct |
20 |
Correct |
7 ms |
15956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
15908 KB |
Output is correct |
2 |
Correct |
9 ms |
15952 KB |
Output is correct |
3 |
Correct |
7 ms |
15976 KB |
Output is correct |
4 |
Correct |
10 ms |
16000 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
9 ms |
15956 KB |
Output is correct |
7 |
Correct |
9 ms |
15920 KB |
Output is correct |
8 |
Correct |
8 ms |
15956 KB |
Output is correct |
9 |
Correct |
8 ms |
15956 KB |
Output is correct |
10 |
Correct |
7 ms |
15956 KB |
Output is correct |
11 |
Correct |
7 ms |
15956 KB |
Output is correct |
12 |
Correct |
7 ms |
15960 KB |
Output is correct |
13 |
Correct |
7 ms |
15956 KB |
Output is correct |
14 |
Correct |
7 ms |
15924 KB |
Output is correct |
15 |
Correct |
10 ms |
15956 KB |
Output is correct |
16 |
Correct |
8 ms |
15956 KB |
Output is correct |
17 |
Correct |
8 ms |
15864 KB |
Output is correct |
18 |
Correct |
7 ms |
15956 KB |
Output is correct |
19 |
Correct |
7 ms |
15956 KB |
Output is correct |
20 |
Correct |
7 ms |
15956 KB |
Output is correct |
21 |
Correct |
7 ms |
15900 KB |
Output is correct |
22 |
Correct |
7 ms |
15980 KB |
Output is correct |
23 |
Correct |
9 ms |
15956 KB |
Output is correct |
24 |
Correct |
12 ms |
15992 KB |
Output is correct |
25 |
Correct |
10 ms |
15956 KB |
Output is correct |
26 |
Correct |
9 ms |
15956 KB |
Output is correct |
27 |
Correct |
10 ms |
15996 KB |
Output is correct |
28 |
Correct |
9 ms |
15920 KB |
Output is correct |
29 |
Correct |
13 ms |
15964 KB |
Output is correct |
30 |
Correct |
10 ms |
15956 KB |
Output is correct |
31 |
Correct |
10 ms |
15956 KB |
Output is correct |
32 |
Correct |
10 ms |
15956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1580 ms |
28376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
7 ms |
15956 KB |
Output is correct |
3 |
Correct |
7 ms |
15956 KB |
Output is correct |
4 |
Correct |
7 ms |
15956 KB |
Output is correct |
5 |
Correct |
8 ms |
15956 KB |
Output is correct |
6 |
Correct |
7 ms |
15956 KB |
Output is correct |
7 |
Correct |
7 ms |
15956 KB |
Output is correct |
8 |
Correct |
8 ms |
15956 KB |
Output is correct |
9 |
Correct |
8 ms |
15872 KB |
Output is correct |
10 |
Correct |
8 ms |
15880 KB |
Output is correct |
11 |
Correct |
9 ms |
15956 KB |
Output is correct |
12 |
Correct |
7 ms |
15956 KB |
Output is correct |
13 |
Correct |
7 ms |
15968 KB |
Output is correct |
14 |
Correct |
7 ms |
15956 KB |
Output is correct |
15 |
Correct |
7 ms |
15856 KB |
Output is correct |
16 |
Correct |
7 ms |
15956 KB |
Output is correct |
17 |
Correct |
8 ms |
15956 KB |
Output is correct |
18 |
Correct |
8 ms |
15956 KB |
Output is correct |
19 |
Correct |
7 ms |
15956 KB |
Output is correct |
20 |
Correct |
7 ms |
15868 KB |
Output is correct |
21 |
Correct |
7 ms |
15956 KB |
Output is correct |
22 |
Correct |
7 ms |
15920 KB |
Output is correct |
23 |
Correct |
11 ms |
15956 KB |
Output is correct |
24 |
Correct |
10 ms |
16004 KB |
Output is correct |
25 |
Correct |
9 ms |
15928 KB |
Output is correct |
26 |
Correct |
9 ms |
15956 KB |
Output is correct |
27 |
Correct |
13 ms |
15956 KB |
Output is correct |
28 |
Correct |
9 ms |
15976 KB |
Output is correct |
29 |
Correct |
10 ms |
15956 KB |
Output is correct |
30 |
Correct |
9 ms |
15984 KB |
Output is correct |
31 |
Correct |
10 ms |
15956 KB |
Output is correct |
32 |
Correct |
10 ms |
15956 KB |
Output is correct |
33 |
Execution timed out |
1577 ms |
27376 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
15956 KB |
Output is correct |
2 |
Correct |
9 ms |
15956 KB |
Output is correct |
3 |
Correct |
7 ms |
15904 KB |
Output is correct |
4 |
Correct |
8 ms |
15932 KB |
Output is correct |
5 |
Correct |
8 ms |
15948 KB |
Output is correct |
6 |
Correct |
7 ms |
15952 KB |
Output is correct |
7 |
Correct |
8 ms |
15956 KB |
Output is correct |
8 |
Correct |
7 ms |
15956 KB |
Output is correct |
9 |
Correct |
7 ms |
15936 KB |
Output is correct |
10 |
Correct |
9 ms |
15888 KB |
Output is correct |
11 |
Correct |
7 ms |
15956 KB |
Output is correct |
12 |
Correct |
7 ms |
15916 KB |
Output is correct |
13 |
Correct |
7 ms |
15928 KB |
Output is correct |
14 |
Correct |
9 ms |
15964 KB |
Output is correct |
15 |
Correct |
7 ms |
15956 KB |
Output is correct |
16 |
Correct |
7 ms |
15956 KB |
Output is correct |
17 |
Correct |
7 ms |
15924 KB |
Output is correct |
18 |
Correct |
7 ms |
15956 KB |
Output is correct |
19 |
Correct |
7 ms |
15956 KB |
Output is correct |
20 |
Correct |
7 ms |
15956 KB |
Output is correct |
21 |
Correct |
7 ms |
15912 KB |
Output is correct |
22 |
Correct |
7 ms |
15956 KB |
Output is correct |
23 |
Correct |
10 ms |
15956 KB |
Output is correct |
24 |
Correct |
12 ms |
15956 KB |
Output is correct |
25 |
Correct |
9 ms |
15956 KB |
Output is correct |
26 |
Correct |
9 ms |
15956 KB |
Output is correct |
27 |
Correct |
10 ms |
15928 KB |
Output is correct |
28 |
Correct |
9 ms |
15996 KB |
Output is correct |
29 |
Correct |
12 ms |
15908 KB |
Output is correct |
30 |
Correct |
11 ms |
16000 KB |
Output is correct |
31 |
Correct |
11 ms |
15956 KB |
Output is correct |
32 |
Correct |
10 ms |
15956 KB |
Output is correct |
33 |
Execution timed out |
1577 ms |
28352 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |