이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
long double seg1[1048576]; // Sum of log2s
long double seg2[1048576]; // log2(Answer)
int seg3[1048576]; // Range product query
int seg4[1048576]; // Real Answer
int lb[1048576];
int rb[1048576];
int rx[500005];
int ry[500005];
void build(int c, int l, int r){
lb[c] = l;
rb[c] = r;
if(l == r){
seg1[c] = log2l(rx[l]);
seg2[c] = log2l(rx[l]) + log2l(ry[l]);
seg3[c] = rx[l];
seg4[c] = (1ll * rx[l] * ry[l]) % MOD;
return;
}
int k = (l + r)/2;
build(2*c,l,k);
build(2*c+1,k+1,r);
seg1[c] = seg1[2*c] + seg1[2*c+1];
seg3[c] = (1ll * seg3[2*c] * seg3[2*c+1]) % MOD;
if(seg2[2*c] > seg2[2*c+1] + seg1[2*c]){
seg2[c] = seg2[2*c];
seg4[c] = seg4[2*c];
}else{
seg2[c] = seg2[2*c+1] + seg1[2*c];
seg4[c] = (1ll * seg4[2*c+1] * seg3[2*c]) % MOD;
}
}
void update(int c, int idx){
if(lb[c] == rb[c]){
seg1[c] = log2l(rx[idx]);
seg2[c] = log2l(rx[idx]) + log2l(ry[idx]);
return;
}
int k = (lb[c] + rb[c])/2;
if(idx <= k) update(2*c, idx);
else update(2*c+1, idx);
seg1[c] = seg1[2*c] + seg1[2*c+1];
seg3[c] = (1ll * seg3[2*c] * seg3[2*c+1]) % MOD;
if(seg2[2*c] > seg2[2*c+1] + seg1[2*c]){
seg2[c] = seg2[2*c];
seg4[c] = seg4[2*c];
}else{
seg2[c] = seg2[2*c+1] + seg1[2*c];
seg4[c] = (1ll * seg4[2*c+1] * seg3[2*c]) % MOD;
}
}
int init(int N, int X[], int Y[]) {
for(int i = 0; i < N; i++){
rx[i] = X[i];
ry[i] = Y[i];
}
build(1,0,N-1);
return seg4[1];
}
int updateX(int pos, int val) {
rx[pos] = val;
update(1, pos);
return seg4[1];
}
int updateY(int pos, int val) {
ry[pos] = val;
update(1, pos);
return seg4[1];
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:22:41: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
seg4[c] = (1ll * rx[l] * ry[l]) % MOD;
~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:29:47: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
seg3[c] = (1ll * seg3[2*c] * seg3[2*c+1]) % MOD;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:35:51: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
seg4[c] = (1ll * seg4[2*c+1] * seg3[2*c]) % MOD;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'void update(int, int)':
horses.cpp:49:47: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
seg3[c] = (1ll * seg3[2*c] * seg3[2*c+1]) % MOD;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:55:51: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
seg4[c] = (1ll * seg4[2*c+1] * seg3[2*c]) % 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... |