QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#124290 | #2788. Horses | valerikk# | 0 | 59ms | 64336kb | C++17 | 1.9kb | 2023-07-14 16:37:09 | 2024-07-04 00:39:39 |
Judging History
answer
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef long long ll;
const int N = 5e5 + 7;
const ll md = 1e9 + 7;
const ll INF = 1e18;
ll mul(ll a, ll b) {
return a <= INF / b ? a * b : INF;
}
int n;
int x[N], y[N];
struct node {
ll pref, suf, prod, prodmd, ans;
bool neut;
};
node merge(const node &l, const node &r) {
if (l.neut) {
return r;
}
if (r.neut) {
return l;
}
node ret;
ret.prod = mul(l.prod, r.prod);
ret.prodmd = l.prodmd * r.prodmd % md;
ret.pref = max(l.pref, mul(r.pref, l.prod));
ret.suf = max(r.suf, mul(l.suf, r.prod));
ret.ans = max({l.ans, r.ans, l.suf * r.pref});
ret.neut = 0;
return ret;
}
node t[4 * N];
void build(int v, int tl, int tr) {
if (tr - tl == 1) {
t[v].pref = y[tl];
t[v].suf = x[tl];
t[v].prod = x[tl];
t[v].prodmd = x[tl];
t[v].ans = y[tl];
t[v].neut = 0;
return;
}
int tm = (tl + tr) / 2;
build(2 * v, tl, tm);
build(2 * v + 1, tm, tr);
t[v] = merge(t[2 * v], t[2 * v + 1]);
}
void upd(int v, int tl, int tr, int pos) {
if (tr - tl == 1) {
t[v].pref = y[tl];
t[v].suf = x[tl];
t[v].prod = x[tl];
t[v].prodmd = x[tl];
t[v].ans = y[tl];
return;
}
int tm = (tl + tr) / 2;
if (pos < tm) {
upd(2 * v, tl, tm, pos);
} else {
upd(2 * v + 1, tm, tr, pos);
}
t[v] = merge(t[2 * v], t[2 * v + 1]);
}
node get(int v, int tl, int tr, int l, int r) {
if (tl >= r || tr <= l) {
return {0, 0, 0, 0, 0, 1};
}
if (tl >= l && tr <= r) {
return t[v];
}
int tm = (tl + tr) / 2;
return merge(get(2 * v, tl, tm, l, r), get(2 * v + 1, tm, tr, l, r));
}
}
int init(int grdn, int grdx[], int grdy[]) {
n = grdn;
for (int i = 0; i < n; ++i) {
x[i] = grdx[i];
y[i] = grdy[i];
}
build(1, 0, n);
return t[1].ans;
}
int updateX(int pos, int val) {
x[pos] = val;
upd(1, 0, n, pos);
return t[1].ans;
}
int updateY(int pos, int val) {
y[pos] = val;
upd(1, 0, n, pos);
return t[1].ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7828kb
input:
1 2 3 0
output:
3
result:
wrong answer 1st lines differ - expected: '6', found: '3'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 59ms
memory: 64336kb
input:
500000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '967631222', found: '0'
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%