QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#139075 | #149. Peru | bashkort# | Compile Error | / | / | C++20 | 2.5kb | 2023-08-12 17:17:48 | 2024-09-10 16:40:59 |
Judging History
你现在查看的是最新测评结果
- [2024-09-10 16:40:59]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-07-04 01:38:40]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-12 17:17:48]
- 提交
answer
#include "peru.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;
constexpr ll infLL = 3e18;
constexpr int N = 8e6 + 7;
namespace SegmentTree {
ll t[N], tag[N];
int sz = 1;
void init(int n) {
sz = 1 << __lg(n) + !!(n & (n - 1));
t.assign(sz << 1, infLL);
tag.assign(sz << 1, 0);
}
void apply(int x, ll tg) {
t[x] += tg, tag[x] += tg;
}
void push(int x) {
if (tag[x]) {
apply(x << 1, tag[x]);
apply(x << 1 | 1, tag[x]);
tag[x] = 0;
}
}
void pull(int x) {
t[x] = min(t[x << 1], t[x << 1 | 1]);
}
void modify(int i, ll v, int x = 1, int lx = 0, int rx = sz) {
if (lx + 1 == rx) {
t[x] = v;
return;
}
int mid = lx + rx >> 1;
push(x);
if (i < mid) {
modify(i, v, x << 1, lx, mid);
} else {
modify(i, v, x << 1 | 1, mid, rx);
}
pull(x);
}
void rangeAdd(int l, int r, ll v, int x = 1, int lx = 0, int rx = sz) {
if (l >= rx || lx >= r) {
return;
}
if (l <= lx && rx <= r) {
return apply(x, v);
}
int mid = lx + rx >> 1;
push(x);
rangeAdd(l, r, v, x << 1, lx, mid);
rangeAdd(l, r, v, x << 1 | 1, mid, rx);
pull(x);
}
ll rangeMin(int l, int r, int x = 1, int lx = 0, int rx = sz) {
if (l >= rx || lx >= r) {
return infLL;
}
if (l <= lx && rx <= r) {
return t[x];
}
int mid = lx + rx >> 1;
push(x);
return min(rangeMin(l, r, x << 1, lx, mid), rangeMin(l, r, x << 1 | 1, mid, rx));
}
};
ll dp[N];
int stk[N], top = 0;
int solve(int n, int k, int a[]){
SegmentTree::init(n + 1);
SegmentTree::modify(0, 0);
int ans = 0;
for (int i = 0; i < n; ++i) {
while (top && a[stk[top - 1]] <= a[i]) {
int l = top == 1 ? 0 : stk[top - 2] + 1;
SegmentTree::rangeAdd(l, stk[top - 1] + 1, -a[stk[top - 1]]);
--top;
}
stk[top++] = i;
int l = top == 1 ? 0 : stk[top - 2] + 1;
SegmentTree::rangeAdd(l, i + 1, a[i]);
dp[i] = SegmentTree::rangeMin(max(0, i - k + 1), i + 1);
SegmentTree::modify(i + 1, dp[i]);
ans = (23LL * ans + dp[i]) % MOD;
}
return ans;
}
Details
implementer.cpp: In function ‘char nextch()’: implementer.cpp:15:31: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | if (pos == BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos = 0; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~ answer.code: In function ‘void SegmentTree::init(int)’: answer.code:18:11: error: request for member ‘assign’ in ‘SegmentTree::t’, which is of non-class type ‘ll [8000007]’ {aka ‘long long int [8000007]’} 18 | t.assign(sz << 1, infLL); | ^~~~~~ answer.code:19:13: error: request for member ‘assign’ in ‘SegmentTree::tag’, which is of non-class type ‘ll [8000007]’ {aka ‘long long int [8000007]’} 19 | tag.assign(sz << 1, 0); | ^~~~~~