# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238161 | rama_pang | Horses (IOI15_horses) | C++14 | 962 ms | 22024 KiB |
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 "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
// It is always optimal to sell all horses in a single year
class SegmentTree {
private:
struct Mint {
int val = 0;
bool overflow = 0;
const Mint operator * (const Mint &x) const {
return {(int) (1ll * this->val * x.val % mod),
(bool) (this->overflow || x.overflow || (1ll * this->val * x.val >= mod))};
}
};
int sz;
vector<Mint> X;
vector<int> Y;
vector<int> optimal;
void Pull(int n, int lc, int rc) {
X[n] = X[lc] * X[rc];
Mint in_between = QueryX(1, 0, sz - 1, optimal[lc] + 1, optimal[rc]);
if (in_between.overflow) {
optimal[n] = optimal[rc];
} else if (Y[optimal[lc]] > 1ll * Y[optimal[rc]] * in_between.val) {
optimal[n] = optimal[lc];
Compilation message (stderr)
# | 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... |