# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
672338 | Trisanu_Das | Horses (IOI15_horses) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
int n;
struct node{
ll v, x, y; double dx, dy, dv;
}t[4 * 500005];
node merge(node a, node b){
node res;
b.dx += a.dx, b.dv += a.dx;
if (a.dv > b.dv) res.v = a.v, res.dv = a.dv;
else res.v = a.x * b.v % mod, res.dv = b.dv;
res.x = a.x * b.x % mod;
res.dx = b.dx;
return res;
}
node upd(int i, int l, int r, int ps, ll vx, ll vy){
if (l > ps || r < ps) return t[x];
if (l == r && l == ps) {
node& nd = t[x];
if (vx) nd.dx = log(vx), nd.x = vx;
if (vy) nd.dy = log(vy), nd.y = vy;
nd.v = nd.x * nd.y % mod, nd.dv = nd.dx + nd.dy;
return nd;
}
int m = (l + r) / 2;
return t[i] = merge(upd(i * 2, l, mid, ps, vx, vy), upd(i * 2 + 1, mid + 1, r, ps, vx, vy));
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i = 0; i < N; i++) upd(1, 0, n - 1, i, X[i], Y[i]);
return t[1].v;
}
int updateX(int pos, int val) {
upd(1, 0, n - 1, pos, val, 0);
return t[1].v;
}
int updateY(int pos, int val) {
upd(1, 0, n - 1, pos, 0, val);
return t[1].v;
}