This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "horses.h"
//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()
const int MX = 5e5+10;
const int MOD = 1e9+7;
ll n, x[MX], y[MX];
ll seg[MX*2];
void buildSeg() {
RE(i,n) seg[i+n] = x[i];
RE(i,n) seg[i] = (seg[i*2]*seg[i*2+1])%MOD;
}
void setSeg(int i, ll v) {
for(seg[i+=n]=v; i>1; i/=2) seg[i/2] = (seg[i]*seg[i^1])%MOD;
}
ll getSeg(int i, int j) {
ll res = 1;
for(i+=n, j+=n; i<j; i/=2, j/=2) {
if(i&1) res = (res*seg[i++])%MOD;
if(j&1) res = (res*seg[--j])%MOD;
}
return res;
}
int getAns() {
ll bst = 1;
int i=n-1;
while(i >= 0) {
bst = max(bst, y[i]);
bst *= x[i];
i--;
if(bst >= INF) {
break;
}
}
bst %= MOD;
bst = (bst*getSeg(0,i+1))%MOD;
return bst;
}
int init(int N, int X[], int Y[]) {
n=N;
RE(i,n) x[i]=X[i];
RE(i,n) y[i]=Y[i];
return getAns();
}
int updateX(int pos, int val) {
x[pos] = val;
setSeg(pos, val);
return getAns();
}
int updateY(int pos, int val) {
y[pos] = val;
return getAns();
}
Compilation message (stderr)
horses.cpp: In function 'void setSeg(int, ll)':
horses.cpp:38:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
38 | for(seg[i+=n]=v; i>1; i/=2) seg[i/2] = (seg[i]*seg[i^1])%MOD;
| ~^~~
horses.cpp: In function 'll getSeg(int, int)':
horses.cpp:42:10: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
42 | for(i+=n, j+=n; i<j; i/=2, j/=2) {
| ~^~~
horses.cpp:42:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
42 | for(i+=n, j+=n; i<j; i/=2, j/=2) {
| ~^~~
horses.cpp: In function 'int getAns()':
horses.cpp:51:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
51 | int i=n-1;
| ~^~
horses.cpp:56:12: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
56 | if(bst >= INF) {
| ^~~
horses.cpp:62:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
62 | return bst;
| ^~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |