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 "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)|1)
struct Node{
double sumx, y, max_val;
int res, modx, xx, yy;
} tree[1<<21];
int n;
void update(int l, int r, int x, int pos, int dx, int dy){
if( r < pos || pos < l) return;
if( l == pos && l == r ){
if( dx ) tree[x].sumx = log10(dx), tree[x].xx = dx;
if( dy ) tree[x].y = log10(dy), tree[x].yy = dy;
tree[x].max_val = tree[x].sumx + tree[x].y;
tree[x].res = 1LL * tree[x].xx * tree[x].yy % mod;
tree[x].modx = tree[x].xx;
return;
}
int mid = (l+r)>>1;
update( l, mid, L(x), pos, dx, dy );
update( mid+1, r, R(x), pos, dx, dy );
tree[x].sumx = tree[L(x)].sumx + tree[R(x)].sumx;
tree[x].modx = 1LL * tree[L(x)].modx * tree[R(x)].modx % mod;
if( tree[L(x)].max_val < tree[R(x)].max_val + tree[L(x)].sumx ){
tree[x].max_val = tree[R(x)].max_val + tree[L(x)].sumx;
tree[x].res = 1LL * tree[R(x)].res * tree[L(x)].modx % mod;
}
else{
tree[x].max_val = tree[L(x)].max_val;
tree[x].res = tree[L(x)].res;
}
}
int init(int N, int X[], int Y[]) {
n = N;
for(int i = 0 ; i < n ; i++) update( 0, n-1, 1, i, X[i], Y[i] );
return tree[1].res;
}
int updateX(int pos, int val) {
update(0, n-1, 1, pos, val, 0);
return tree[1].res;
}
int updateY(int pos, int val) {
update(0, n-1, 1, pos, 0, val);
return tree[1].res;
}
Compilation message (stderr)
horses.cpp: In function 'void update(int, int, int, int, int, int)':
horses.cpp:21:47: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[x].res = 1LL * tree[x].xx * tree[x].yy % mod;
^
horses.cpp:31:57: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[x].modx = 1LL * tree[L(x)].modx * tree[R(x)].modx % mod;
^
horses.cpp:34:56: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
tree[x].res = 1LL * tree[R(x)].res * tree[L(x)].modx % mod;
^
# | 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... |