# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1088291 |
2024-09-14T08:04:00 Z |
dosts |
Horses (IOI15_horses) |
C++17 |
|
1500 ms |
18520 KB |
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e14;
const int N = 5e5+50;
int add(int x,int y) {
return ((x+y) >= MOD ? x+y-MOD : x+y);
}
int mult(int x,int y) {
return ((x%MOD)*(y%MOD))%MOD;
}
int x[N],y[N],pref[N];
int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
for (int i=0;i<N;i++) x[i] = X[i],y[i] = Y[i];
pref[0] = x[0];
for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]);
int mm = 1;
int p = 0;
for (int i=N-1;i>=0;i--) {
mm*=x[i];
if (mm >= 1e10) {
p = i;
break;
}
}
int mx = 0,ans = 0;
mm = 1;
for (int i=p;i<N;i++) {
mm*=x[i];
if (mm*y[i] > mx) {
mx = mm*y[i];
ans = mult(pref[i],y[i]);
}
}
return ans;
}
int32_t updateX(int32_t pos, int32_t val) {
x[pos] = val;
pref[0] = x[0];
for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]);
int mm = 1;
int p = 0;
for (int i=N-1;i>=0;i--) {
mm*=x[i];
if (mm >= 1e10) {
p = i;
break;
}
}
int mx = 0,ans = 0;
mm = 1;
for (int i=p;i<N;i++) {
mm*=x[i];
if (mm*y[i] > mx) {
mx = mm*y[i];
ans = mult(pref[i],y[i]);
}
}
return ans;
}
int32_t updateY(int32_t pos, int32_t val) {
y[pos] = val;
pref[0] = x[0];
for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]);
int mm = 1;
int p = 0;
for (int i=N-1;i>=0;i--) {
mm*=x[i];
if (mm >= 1e10) {
p = i;
break;
}
}
int mx = 0,ans = 0;
mm = 1;
for (int i=p;i<N;i++) {
mm*=x[i];
if (mm*y[i] > mx) {
mx = mm*y[i];
ans = mult(pref[i],y[i]);
}
}
return ans;
}
Compilation message
horses.cpp: In function 'int32_t init(int32_t, int32_t*, int32_t*)':
horses.cpp:23:22: warning: declaration of 'N' shadows a global declaration [-Wshadow]
23 | int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
| ~~~~~~~~^
horses.cpp:12:11: note: shadowed declaration is here
12 | const int N = 5e5+50;
| ^
horses.cpp:31:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
31 | if (mm >= 1e10) {
| ^~
horses.cpp:45:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
45 | return ans;
| ^~~
horses.cpp: In function 'int32_t updateX(int32_t, int32_t)':
horses.cpp:56:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
56 | if (mm >= 1e10) {
| ^~
horses.cpp:70:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
70 | return ans;
| ^~~
horses.cpp: In function 'int32_t updateY(int32_t, int32_t)':
horses.cpp:81:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
81 | if (mm >= 1e10) {
| ^~
horses.cpp:95:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
95 | return ans;
| ^~~
# |
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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
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 |
# |
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 |
344 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 |
1 ms |
444 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
440 KB |
Output is correct |
15 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Incorrect |
30 ms |
4188 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1567 ms |
18520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
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 |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
440 KB |
Output is correct |
15 |
Correct |
0 ms |
448 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 |
1 ms |
348 KB |
Output is correct |
21 |
Incorrect |
31 ms |
4380 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
404 KB |
Output is correct |
3 |
Correct |
1 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 |
444 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 |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 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 |
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 |
Incorrect |
28 ms |
4312 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |