이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MX = 500500;
int N;
int X[MX], Y[MX];
namespace searcher {
pair<ld, int> best[MX << 1];
ld sum[MX << 1];
void pop(int v) {
best[v] = max(best[v << 1], make_pair(best[v << 1 | 1].first + sum[v << 1], best[v].second));
sum[v] = sum[v << 1] + sum[v << 1 | 1];
}
void modify(int p) {
p += N;
best[p] = make_pair(log(X[p - N]) + log(Y[p - N]), p - N);
sum[p] = log(X[p - N]);
for (p >>= 1; p > 0; p >>= 1) {
pop(p);
}
}
};
namespace calculator {
static const int MOD = 1000000007;
int mult(int x, int y) { return ll(x) * y % MOD; }
int st[MX << 1];
void modify(int p) {
p += N;
st[p] = X[p - N];
for (p >>= 1; p > 0; p >>= 1) {
st[p] = mult(st[p << 1], st[p << 1 | 1]);
}
}
int query(int p) {
int ans = Y[p];
for (int l = N, r = p + N; l <= r; l >>= 1, r >>= 1) {
if (l & 1) ans = mult(ans, st[l++]);
if (!(r & 1)) ans = mult(ans, st[r--]);
}
return ans;
}
};
int init(int _N, int _X[], int _Y[]) {
N = _N;
for (int i = 0; i < N; ++i) X[i] = _X[i], Y[i] = _Y[i];
for (int i = 0; i < N; ++i) {
searcher::modify(i);
calculator::modify(i);
}
return calculator::query(searcher::best[1].second);
}
int updateX(int pos, int val) {
X[pos] = val;
searcher::modify(pos);
calculator::modify(pos);
return calculator::query(searcher::best[1].second);
}
int updateY(int pos, int val) {
Y[pos] = val;
searcher::modify(pos);
calculator::modify(pos);
return calculator::query(searcher::best[1].second);
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'int calculator::mult(int, int)':
horses.cpp:37:43: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
int mult(int x, int y) { return ll(x) * y % 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... |