이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
multimap<long double, int> mm;
const int MOD = 1e9+7;
long double FT1[500005];
int FT2[500005];
void add(int idx, int amt){
idx++;
while(idx < 500005){
FT1[idx] += log2(amt);
FT2[idx] = (1ll * FT2[idx] * amt) % MOD;
idx += idx & -idx;
}
}
long double sum1(int idx){
idx++;
long double ret = 0;
while(idx > 0){
ret += FT1[idx];
idx -= idx & -idx;
}
return ret;
}
int sum2(int idx){
idx++;
int ret = 1;
while(idx > 0){
ret = (1ll * ret * FT2[idx]) % MOD;
idx -= idx & -idx;
}
return ret;
}
int rx[500005];
int ry[500005];
int answer(){
auto it = mm.rbegin();
return it->second;
}
int init(int N, int X[], int Y[]) {
for(int i = 0; i < N; i++){
rx[i] = X[i];
ry[i] = Y[i];
}
for(int i = 0; i < 500005; i++) FT2[i] = 1;
for(int i = 0; i < N; i++){
add(i, X[i]);
}
for(int i = 0; i < N; i++){
mm.emplace(sum1(i) + log2l(Y[i]), (int)((1ll * sum2(i) * Y[i]) % MOD));
}
return answer();
}
int updateX(int pos, int val) {
mm.erase(mm.find(sum1(pos) + log2l(ry[pos])));
add(pos, val - rx[pos]);
rx[pos] = val;
mm.emplace(sum1(pos) + log2l(ry[pos]), (int)((1ll * sum2(pos) * ry[pos]) % MOD));
return answer();
}
int updateY(int pos, int val) {
mm.erase(mm.find(sum1(pos) + log2l(ry[pos])));
ry[pos] = val;
mm.emplace(sum1(pos) + log2l(ry[pos]), (int)((1ll * sum2(pos) * ry[pos]) % MOD));
return answer();
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'void add(int, int)':
horses.cpp:13:43: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
FT2[idx] = (1ll * FT2[idx] * amt) % MOD;
~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int sum2(int)':
horses.cpp:30:38: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
ret = (1ll * ret * FT2[idx]) % 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... |