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>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
const int INF = 1e9 + 1;
//const int N = 2e5 + 100;
const double eps = 1e-7;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
x = (x > y ? y : x);
}
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
int n;
int A[100000], B[100000];
int init(int N, int X[], int Y[]) {
ll ans = 0;
double d = 0.0;
ll tot = 1;
double g = 0.0;
n = N;
forn(i, N) {
A[i] = X[i];
B[i] = Y[i];
tot *= A[i];
tot %= mod;
if(A[i] == 0)g = -INF;
else g += (double)log10(A[i]);
if(B[i] > 0) {
double ps = log10(B[i]);
if(g + ps > d) {
d = g + ps;
ans = tot * B[i];
}
}
}
return ans;
}
int updateX(int pos, int val) {
A[pos] = val;
ll ans = 0;
double d = 0.0;
ll tot = 1;
double g = 0.0;
forn(i, n) {
tot *= A[i];
tot %= mod;
if(A[i] == 0)g = -INF;
else g += (double)log10(A[i]);
if(B[i] > 0) {
double ps = log10(B[i]);
if(g + ps > d) {
d = g + ps;
ans = tot * B[i];
}
}
}
return ans % mod;
}
int updateY(int pos, int val) {
B[pos] = val;
ll ans = 0;
double d = 0.0;
ll tot = 1;
double g = 0.0;
forn(i, n) {
tot *= A[i];
tot %= mod;
if(A[i] == 0)g = -INF;
else g += (double)log10(A[i]);
if(B[i] > 0) {
double ps = log10(B[i]);
if(g + ps > d) {
d = g + ps;
ans = tot * B[i];
}
}
}
return ans % mod;
return ans;
}
Compilation message (stderr)
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:79:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
79 | return ans;
| ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:107:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
107 | return ans % mod;
| ~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:136:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
136 | return ans % mod;
| ~~~~^~~~~
horses.cpp:137:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
137 | return ans;
| ^~~
# | 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... |