# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
923081 |
2024-02-06T14:39:28 Z |
oblantis |
Horses (IOI15_horses) |
C++17 |
|
356 ms |
65620 KB |
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll inf = 1e9;
const int mod = 1e9+7;
const int maxn = 5e5 + 4;
ll t[maxn * 4], it, xl;
int n;
ll a[maxn], b[maxn], mx[maxn * 4];
set<int> s;
void upd(int v, int l, int r){
if(l + 1 == r){
t[v] = a[l];
mx[v] = b[l];
return;
}
if((l + r) / 2 <= it)upd(v * 2 + 2, (l + r) / 2, r);
else upd(v * 2 + 1, l, (l + r) / 2);
t[v] = t[v * 2 + 1] * t[v * 2 + 2] % mod;
mx[v] = max(mx[v * 2 + 1], mx[v * 2 + 2]);
}
ll gm(int v, int l, int r){
if(xl <= l)return mx[v];
if(r <= xl)return 0;
return max(gm(v * 2 + 1, l, (l + r) / 2), gm(v * 2 + 2, (l + r) / 2, r));
}
ll mlp(int v, int l, int r){
if(r <= xl + 1)return t[v];
if(xl < l) return 1;
return 1ll * mlp(v * 2 + 1, l, (l + r) / 2) * mlp(v * 2 + 2, (l + r) / 2, r) % mod;
}
int get(){
xl = 0;
ll ans = gm(0, 0, n), p = 1, k = 1;
if(s.empty()){
return ans;
}
int cnt = 30;
auto i = --s.end();
while(1){
if(cnt == 0)break;
cnt--;
xl = *i;
ll nx = gm(0, 0, n);
if(p * k <= nx){
ans = 1ll * nx * mlp(0, 0, n) % mod;
p = 1;
k = nx;
}
p *= a[xl];
if(p > inf || p * k > inf)break;
if(i == s.begin())break;
--i;
}
xl = 0;
ll nx = gm(0, 0, n);
if(p * k < nx)ans = nx;
return ans;
}
int init(int m, int x[], int y[]) {
n = m;
for(int i = 0; i < n; i++){
a[i] = x[i], b[i] = y[i];
it = i;
upd(0, 0, n);
if(a[i] != 1)s.insert(i);
}
return get();
}
int updateX(int pos, int val) {
if(a[pos] == val)return get();
if(a[pos] == 1)s.insert(pos);
else if(val == 1)s.erase(pos);
it = pos;
a[it] = val;
upd(0, 0, n);
return get();
}
int updateY(int pos, int val) {
it = pos;
b[it] = val;
upd(0, 0, n);
return get();
}
Compilation message
horses.cpp: In function 'int get()':
horses.cpp:48:10: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
48 | return ans;
| ^~~
horses.cpp:70:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
70 | return ans;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
436 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
440 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
544 KB |
Output is correct |
16 |
Correct |
0 ms |
444 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
600 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
456 KB |
Output is correct |
26 |
Correct |
1 ms |
600 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
456 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
345 ms |
56448 KB |
Output is correct |
2 |
Correct |
278 ms |
65464 KB |
Output is correct |
3 |
Correct |
264 ms |
56676 KB |
Output is correct |
4 |
Correct |
260 ms |
60620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
2 ms |
544 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
128 ms |
32548 KB |
Output is correct |
34 |
Correct |
118 ms |
32620 KB |
Output is correct |
35 |
Correct |
233 ms |
62016 KB |
Output is correct |
36 |
Correct |
217 ms |
61944 KB |
Output is correct |
37 |
Correct |
125 ms |
30980 KB |
Output is correct |
38 |
Correct |
162 ms |
43620 KB |
Output is correct |
39 |
Correct |
108 ms |
30480 KB |
Output is correct |
40 |
Correct |
209 ms |
57796 KB |
Output is correct |
41 |
Correct |
116 ms |
30544 KB |
Output is correct |
42 |
Correct |
122 ms |
30696 KB |
Output is correct |
43 |
Correct |
196 ms |
57936 KB |
Output is correct |
44 |
Correct |
201 ms |
57876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
356 ms |
56464 KB |
Output is correct |
34 |
Correct |
301 ms |
65620 KB |
Output is correct |
35 |
Correct |
273 ms |
56864 KB |
Output is correct |
36 |
Correct |
262 ms |
60608 KB |
Output is correct |
37 |
Correct |
131 ms |
32748 KB |
Output is correct |
38 |
Correct |
127 ms |
32512 KB |
Output is correct |
39 |
Correct |
228 ms |
62804 KB |
Output is correct |
40 |
Correct |
214 ms |
63116 KB |
Output is correct |
41 |
Correct |
123 ms |
30824 KB |
Output is correct |
42 |
Correct |
153 ms |
43500 KB |
Output is correct |
43 |
Correct |
109 ms |
30440 KB |
Output is correct |
44 |
Correct |
205 ms |
57932 KB |
Output is correct |
45 |
Correct |
116 ms |
30544 KB |
Output is correct |
46 |
Correct |
121 ms |
30628 KB |
Output is correct |
47 |
Correct |
198 ms |
58252 KB |
Output is correct |
48 |
Correct |
195 ms |
58404 KB |
Output is correct |
49 |
Correct |
191 ms |
35580 KB |
Output is correct |
50 |
Correct |
178 ms |
35932 KB |
Output is correct |
51 |
Correct |
297 ms |
64852 KB |
Output is correct |
52 |
Correct |
245 ms |
64264 KB |
Output is correct |
53 |
Correct |
298 ms |
33852 KB |
Output is correct |
54 |
Correct |
221 ms |
47372 KB |
Output is correct |
55 |
Correct |
149 ms |
31832 KB |
Output is correct |
56 |
Correct |
274 ms |
59888 KB |
Output is correct |
57 |
Correct |
231 ms |
32616 KB |
Output is correct |
58 |
Correct |
295 ms |
32852 KB |
Output is correct |
59 |
Correct |
200 ms |
58284 KB |
Output is correct |