이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
const int maxn = 500050;
const int P = 1e9+7;
struct node
{
int l, r;
ll val, res;
double sum, mx;
}t[maxn<<2];
int x[maxn], y[maxn];
void pu(int k)
{
if(t[k<<1].mx < t[k<<1].sum + t[k<<1|1].mx)
{
t[k].mx = t[k<<1].sum + t[k<<1|1].mx;
t[k].res = t[k<<1].val * t[k<<1|1].res % P;
}
else
{
t[k].mx = t[k<<1].mx;
t[k].res = t[k<<1].res;
}
t[k].sum = t[k<<1].sum + t[k<<1|1].sum;
t[k].val = t[k<<1].val * t[k<<1|1].val % P;
}
void build(int l, int r, int k = 1)
{
t[k].l = l; t[k].r = r;
if(l == r) return;
int mid = t[k].l + t[k].r >> 1;
build(l, mid, k<<1);
build(mid+1, r, k<<1|1);
}
void upd(int p, int k=1)
{
if(t[k].l == t[k].r)
{
t[k].val = x[p];
t[k].sum = log(1.0*x[p]);
t[k].mx = log(1.0*x[p]*y[p]);
t[k].res = x[p] * y[p] % P;
return;
}
int mid = t[k].l + t[k].r >> 1;
if(p <= mid) upd(p, k<<1); else upd(p, k<<1|1);
pu(k);
}
int init(int N, int X[], int Y[]) {
fo(i,0,N-1) x[i+1] = X[i], y[i+1] = Y[i];
build(1,N);
fo(i,1,N) upd(i);
return (int)t[1].res;
}
int updateX(int pos, int val) {
x[pos+1] = val;
upd(pos+1);
return (int)t[1].res;
}
int updateY(int pos, int val) {
y[pos+1] = val;
upd(pos+1);
return (int)t[1].res;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:64:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = t[k].l + t[k].r >> 1;
~~~~~~~^~~~~~~~
horses.cpp: In function 'void upd(int, int)':
horses.cpp:78:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid = t[k].l + t[k].r >> 1;
~~~~~~~^~~~~~~~
# | 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... |