이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "horses.h"
#define maxN 500005
#define mod 1000000007
using namespace std;
struct segment{
long long a,b;};
segment seg[4*maxN];
vector <int> x,y;
void build(int n,int l,int d){
if(l==d){
seg[n].a=x[l];
seg[n].b=x[l]*y[l];
}
else{
int m=(l+d)/2;
build(2*n,l,m);
build(2*n+1,m+1,d);
seg[n].a=(seg[2*n].a*seg[2*n+1].a)%mod;
seg[n].b=(max(seg[2*n].b,seg[2*n+1].b*seg[2*n].a))%mod;
}
}
void updatex(int n,int l,int d,int p,int v){
if(l==d){
x[l]=v;
seg[n].a=x[l];
seg[n].b=x[l]*y[l];
}
else{
int m=(l+d)/2;
if(p<=m) updatex(2*n,l,m,p,v);
else updatex(2*n+1,m+1,d,p,v);
seg[n].a=(seg[2*n].a*seg[2*n+1].a)%mod;
seg[n].b=(max(seg[2*n].b,seg[2*n+1].b*seg[2*n].a))%mod;
}
}
void updatey(int n,int l,int d,int p,int v){
if(l==d){
long long tmp;
y[l]=v;
seg[n].a=x[l];
seg[n].b=x[l]*y[l];
}
else{
int m=(l+d)/2;
if(p<=m) updatey(2*n,l,m,p,v);
else updatey(2*n+1,m+1,d,p,v);
seg[n].a=(seg[2*n].a*seg[2*n+1].a)%mod;
seg[n].b=(max(seg[2*n].b,seg[2*n+1].b*seg[2*n].a))%mod;
}
}
int init(int n,int a[],int b[]){
int i;
for(i=0;i<n;i++){
x.push_back(a[i]);
y.push_back(b[i]);
}
build(1,0,n-1);
return seg[1].b;
}
int updateX(int pos,int val){
updatex(1,0,x.size()-1,pos,val);
return seg[1].b;
}
int updateY(int pos,int val){
updatey(1,0,y.size()-1,pos,val);
return seg[1].b;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'void updatey(int, int, int, int, int)':
horses.cpp:42:15: warning: unused variable 'tmp' [-Wunused-variable]
long long tmp;
^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:63:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].b;
^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:66:31: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
updatex(1,0,x.size()-1,pos,val);
^
horses.cpp:67:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].b;
^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:70:31: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
updatey(1,0,y.size()-1,pos,val);
^
horses.cpp:71:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return seg[1].b;
^
# | 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... |