This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#include "horses.h"
struct Node {
int x, y;
double _x, _y;
};
const int mod = int(1e9 + 7);
int mul(int a, int b) {
return (long long) a * b % mod;
}
Node operator+(Node &a, Node &b) {
Node ret;
if(a._y > a._x * b._y) {
ret.y = a.y;
ret._y = a._y;
}
else {
ret.y = mul(a.x, b.y);
ret._y = a._x * b._y;
}
ret.x = mul(a.x, b.x);
ret._x = a._x * b._x;
return ret;
};
struct Tree {
vector<Node> tree;
int sz = 1;
Tree(int n = 0) {
while(sz < n) sz *= 2;
tree.resize(sz * 2);
}
void update(int pos) {
pos += sz;
tree[pos]._x = tree[pos].x;
tree[pos]._y = tree[pos].y;
while(pos /= 2)
tree[pos] = tree[pos * 2] + tree[pos * 2 + 1];
}
Node& operator[](int pos) { return tree[pos + sz]; }
int query() { return tree[1].y; }
} tree;
int init(int N, int X[], int Y[]) {
tree = Tree(N + 1);
REP(i, N) {
tree[i].x = X[i];
tree[i + 1].y = Y[i];
}
REP(i, N + 1) tree.update(i);
return tree.query();
}
int updateX(int pos, int val) {
tree[pos].x = val;
tree.update(pos);
return tree.query();
}
int updateY(int pos, int val) {
tree[++pos].y = val;
tree.update(pos);
return tree.query();
}
Compilation message (stderr)
horses.cpp: In function 'int mul(int, int)':
horses.cpp:15:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
return (long long) a * b % 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... |