# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
707688 |
2023-03-09T18:29:41 Z |
MODDI |
Horses (IOI15_horses) |
C++14 |
|
1500 ms |
12524 KB |
#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
using namespace std;
const int mod = 1e9 + 7;
vi X, Y;
ll mul(ll a, ll b){
return (a * b) % mod;
}
int N;
int init(int n, int x[], int y[]){
N = n;
for(int i = 0; i < n; i++)
X.pb(x[i]);
for(int i = 0; i < n; i++)
Y.pb(y[i]);
ll ans = 0, mult = 1, pref=1, last = 0;
for(int i = 0; i < N; i++){
pref *= X[i];
mult = mul(mult, X[i]);
mult %= mod;
ll cur_sell = mul(mult, Y[i]);
cur_sell %= mod;
if(cur_sell < 0) assert(false);
if(pref * Y[i] > last){
ans = mult * Y[i] % mod;
pref = 1;
last = Y[i];
}
}
if(ans <= 0) assert(false);
return ans;
}
int updateX(int pos, int val){
X[pos] = val*1ll;
ll ans = 0, mult = 1, pref=1, last = 0;
for(int i = 0; i < N; i++){
pref *= X[i];
mult = mul(mult, X[i]);
mult %= mod;
ll cur_sell = mul(mult, Y[i]);
cur_sell %= mod;
if(cur_sell < 0) assert(false);
if(pref * Y[i] > last){
ans = mult * Y[i] % mod;
pref = 1;
last = Y[i];
}
}
if(ans <= 0) assert(false);
return ans;
}
int updateY(int pos, int val){
Y[pos] = val*1LL;
ll ans = 0, mult = 1, pref=1, last = 0;
for(int i = 0; i < N; i++){
pref *= X[i];
mult = mul(mult, X[i]);
mult %= mod;
ll cur_sell = mul(mult, Y[i]);
cur_sell %= mod;
if(cur_sell < 0) assert(false);
if(pref * Y[i] > last){
ans = mult * Y[i] % mod;
pref = 1;
last = Y[i];
}
}
if(ans <= 0) assert(false);
return ans;
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:36:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
36 | return ans;
| ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:55:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
55 | return ans;
| ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:74:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
74 | return ans;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
7 ms |
340 KB |
Output is correct |
24 |
Correct |
6 ms |
340 KB |
Output is correct |
25 |
Correct |
6 ms |
340 KB |
Output is correct |
26 |
Correct |
6 ms |
340 KB |
Output is correct |
27 |
Correct |
6 ms |
340 KB |
Output is correct |
28 |
Correct |
7 ms |
340 KB |
Output is correct |
29 |
Correct |
7 ms |
340 KB |
Output is correct |
30 |
Correct |
6 ms |
340 KB |
Output is correct |
31 |
Correct |
6 ms |
340 KB |
Output is correct |
32 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1566 ms |
9156 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
7 ms |
340 KB |
Output is correct |
24 |
Correct |
7 ms |
348 KB |
Output is correct |
25 |
Correct |
6 ms |
336 KB |
Output is correct |
26 |
Correct |
7 ms |
312 KB |
Output is correct |
27 |
Correct |
8 ms |
340 KB |
Output is correct |
28 |
Correct |
7 ms |
340 KB |
Output is correct |
29 |
Correct |
6 ms |
212 KB |
Output is correct |
30 |
Correct |
6 ms |
348 KB |
Output is correct |
31 |
Correct |
6 ms |
340 KB |
Output is correct |
32 |
Correct |
6 ms |
344 KB |
Output is correct |
33 |
Execution timed out |
1553 ms |
12524 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
7 ms |
340 KB |
Output is correct |
24 |
Correct |
7 ms |
308 KB |
Output is correct |
25 |
Correct |
7 ms |
340 KB |
Output is correct |
26 |
Correct |
6 ms |
340 KB |
Output is correct |
27 |
Correct |
6 ms |
340 KB |
Output is correct |
28 |
Correct |
7 ms |
336 KB |
Output is correct |
29 |
Correct |
6 ms |
212 KB |
Output is correct |
30 |
Correct |
6 ms |
304 KB |
Output is correct |
31 |
Correct |
7 ms |
340 KB |
Output is correct |
32 |
Correct |
8 ms |
344 KB |
Output is correct |
33 |
Execution timed out |
1579 ms |
11312 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |