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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int mod = 1e9 + 7, ans[300001], n, terx[300001], tery[300001], sx[300001];
float mx[300001], sgx[300001], sgy[300001];
void upd(int node, int idx, int l, int r, int x, int y)
{
if ( l > idx || r < idx )
return;
if ( l == r ) {
if ( x != -1 ) {
sgx[node] = log10(x);
terx[node] = x;
}
if ( y != -1 ) {
sgy[node] = log10(y);
tery[node] = y;
}
sx[node] = terx[node];
mx[node] = sgx[node] + sgy[node];
ans[node] = (1ll * terx[node] * tery[node]) % mod;
return;
}
int mid = (l + r) / 2;
upd(node * 2, idx, l, mid, x, y);
upd(node * 2 + 1, idx, mid + 1, r, x, y);
sgx[node] = sgx[node * 2] + sgx[node * 2 + 1];
sx[node] = (1ll * sx[node * 2] * sx[node * 2 + 1]) % mod;
if ( mx[node * 2] > mx[node * 2 + 1] + sgx[node * 2] ) {
mx[node] = mx[node * 2];
ans[node] = ans[node * 2];
} else {
mx[node] = mx[node * 2 + 1] + sgx[node * 2];
ans[node] = (1ll * ans[node * 2 + 1] * sx[node * 2]) % mod;
}
}
int init(int N, int X[], int Y[]) {
n = N;
for (ll i = 0; i < N; i++)
upd(1, i, 0, N - 1, X[i], Y[i]);
return ans[1];
}
int updateX(int pos, int val) {
upd(1, pos, 0, n - 1, val, -1);
return ans[1];
}
int updateY(int pos, int val) {
upd(1, pos, 0, n - 1, -1, val);
return ans[1];
}
Compilation message (stderr)
horses.cpp: In function 'void upd(int, int, int, int, int, int)':
horses.cpp:35:21: warning: conversion to 'float' from '__gnu_cxx::__enable_if<true, double>::__type {aka double}' may alter its value [-Wfloat-conversion]
sgx[node] = log10(x);
~~~~~^~~
horses.cpp:40:21: warning: conversion to 'float' from '__gnu_cxx::__enable_if<true, double>::__type {aka double}' may alter its value [-Wfloat-conversion]
sgy[node] = log10(y);
~~~~~^~~
horses.cpp:46:47: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
ans[node] = (1ll * terx[node] * tery[node]) % mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:56:53: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
sx[node] = (1ll * sx[node * 2] * sx[node * 2 + 1]) % mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:63:56: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
ans[node] = (1ll * ans[node * 2 + 1] * sx[node * 2]) % mod;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:71:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
upd(1, i, 0, N - 1, X[i], Y[i]);
^
# | 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... |