이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
const ll mod=1e9+7;
ll n;
ll a[500001], b[500001];
pair<pair<ll, ll>, pair<ll, ll>> st[1000001];
void f(ll xf){
if(st[xf*2+1].S.F==1){
st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {1, st[xf*2+1].S.S}};
}
else{
if(st[xf*2].F.S<st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S){
st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {(st[xf*2].S.F||(st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S*st[xf*2].F.F)>=1000000000), st[xf*2+1].S.S}};
}
else{
st[xf]=st[xf*2];
st[xf].S.S*=st[xf*2+1].S.S*st[xf*2+1].F.F;
}
}
return ;
}
void update(ll xf){
xf/=2;
while(xf>0){
f(xf);
xf/=2;
}
return ;
}
int init(int N, int X[], int Y[]) {
n=N;
for(int i=0; i<N; i++){
a[i]=X[i];
b[i]=Y[i];
}
for(int i=0; i<n; i++){
st[i+n]={{a[i], b[i]}, {(a[i]*b[i]>=1000000000), 1}};
}
for(int i=n-1; i>0; i--){
f(i);
}
return (st[1].F.F*st[1].F.S)%mod;
}
int updateX(int pos, int val) {
a[pos]=val;
st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1000000000), 1}};
update(pos+n);
return (st[1].F.F*st[1].F.S)%mod;
}
int updateY(int pos, int val) {
b[pos]=val;
st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1000000000), 1}};
update(pos+n);
return (st[1].F.F*st[1].F.S)%mod;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:43:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
43 | for(int i=n-1; i>0; i--){
| ~^~
horses.cpp:46:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
46 | return (st[1].F.F*st[1].F.S)%mod;
| ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
53 | return (st[1].F.F*st[1].F.S)%mod;
| ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:60:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
60 | return (st[1].F.F*st[1].F.S)%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... |