이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef long double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
const ll mod2=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
ll mul(ll a, ll b) {
return a*b%mod;
}
const int N=501000;
int n;
db a[N],b[N],ps[N];
ll pp[N];
struct node {
db mx,lzy;
ll f,lzyp;
}nd[4*N];
void upd(int p) {
if (nd[p+p].mx>nd[p+p+1].mx) {
nd[p].mx=nd[p+p].mx;
nd[p].f=nd[p+p].f;
} else {
nd[p].mx=nd[p+p+1].mx;
nd[p].f=nd[p+p+1].f;
}
}
void push(int p) {
nd[p].mx+=nd[p].lzy;
nd[p].f=mul(nd[p].f,nd[p].lzyp);
nd[p+p].lzy+=nd[p].lzy;
nd[p+p+1].lzy+=nd[p].lzy;
nd[p+p].lzyp=mul(nd[p+p].lzyp,nd[p].lzyp);
nd[p+p+1].lzyp=mul(nd[p+p+1].lzyp,nd[p].lzyp);
nd[p].lzy=0;
nd[p].lzyp=1;
}
void build(int p,int l,int r) {
nd[p].lzyp=1;
if (l==r) {
nd[p].mx=ps[l]+log10l(b[l]);
nd[p].f=mul(pp[l],b[l]);
return;
}
int md=l+r>>1;
build(p+p,l,md);
build(p+p+1,md+1,r);
upd(p);
}
void modify(int p,int l,int r,int ql,int qr,db x,ll y) {
push(p);
if (l>qr||r<ql) return;
if (ql<=l&&r<=qr) {
nd[p].lzy+=x;
nd[p].lzyp=mul(nd[p].lzyp,y);
push(p);
return;
}
int md=l+r>>1;
modify(p+p,l,md,ql,qr,x,y);
modify(p+p+1,md+1,r,ql,qr,x,y);
upd(p);
}
int init(int N,int* x,int* y) {
n=N;
ps[0]=0; pp[0]=1;
rep(i,1,n+1) ps[i]=ps[i-1]+log10l(x[i-1]);
rep(i,1,n+1) pp[i]=mul(pp[i-1],x[i-1]);
rep(i,1,n+1) a[i]=x[i-1],b[i]=y[i-1];
build(1,1,n);
return nd[1].f;
}
int updateX(int pos,int val) {
++pos;
modify(1,1,n,pos,n,log10l(val)-log10l(a[pos]),mul(val,powmod(a[pos],mod-2)));
a[pos]=val;
return nd[1].f;
}
int updateY(int pos,int val) {
++pos;
modify(1,1,n,pos,pos,log10l(val)-log10l(b[pos]),mul(val,powmod(b[pos],mod-2)));
b[pos]=val;
return nd[1].f;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'int rnd(int)':
horses.cpp:18:33: warning: conversion from 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
18 | int rnd(int x) { return mrand() % x;}
| ~~~~~~~~^~~
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:62:24: warning: conversion from 'db' {aka 'long double'} to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
62 | nd[p].f=mul(pp[l],b[l]);
| ~~~^
horses.cpp:65:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
65 | int md=l+r>>1;
| ~^~
horses.cpp: In function 'void modify(int, int, int, int, int, db, ll)':
horses.cpp:80:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
80 | int md=l+r>>1;
| ~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:86:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
86 | int init(int N,int* x,int* y) {
| ~~~~^
horses.cpp:27:11: note: shadowed declaration is here
27 | const int N=501000;
| ^
horses.cpp:93:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
93 | return nd[1].f;
| ~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:98:68: warning: conversion from 'db' {aka 'long double'} to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
98 | modify(1,1,n,pos,n,log10l(val)-log10l(a[pos]),mul(val,powmod(a[pos],mod-2)));
| ~~~~~^
horses.cpp:100:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
100 | return nd[1].f;
| ~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:105:70: warning: conversion from 'db' {aka 'long double'} to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
105 | modify(1,1,n,pos,pos,log10l(val)-log10l(b[pos]),mul(val,powmod(b[pos],mod-2)));
| ~~~~~^
horses.cpp:107:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
107 | return nd[1].f;
| ~~~~~~^
# | 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... |