QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#166873 | #149. Peru | zlt | Compile Error | / | / | C++14 | 1.7kb | 2023-09-06 19:48:22 | 2024-09-10 16:44:18 |
Judging History
你现在查看的是最新测评结果
- [2024-09-10 16:44:18]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-06 19:48:22]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-06 19:48:22]
- 提交
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
const int maxn = 2500100;
const ll mod = 1000000007;
int n, m, a[maxn], pw[maxn], q[maxn], hd = 1, tl;
ll f[maxn];
struct DS {
ll l = 1, r = 0, mid = 1, pre[maxn], suf[maxn], a[maxn];
inline void build() {
if (l > r) {
return;
}
mid = (l + r) >> 1;
suf[mid + 1] = pre[mid] = 1e18;
for (int i = mid; i >= l; --i) {
suf[i] = min(suf[i + 1], a[i]);
}
for (int i = mid + 1; i <= r; ++i) {
pre[i] = min(pre[i - 1], a[i]);
}
}
inline void dell() {
++l;
if (l > mid) {
build();
}
}
inline void delr() {
--r;
if (r < mid) {
build();
}
}
inline void addr(ll x) {
a[++r] = x;
if (l == r) {
build();
} else {
pre[r] = min(pre[r - 1], x);
}
}
inline void updl(ll x) {
a[l] = x;
suf[l] = min(suf[l + 1], x);
}
inline ll query() {
return min(suf[l], pre[r]);
}
} Q;
inline int solve(int n, int m, int *a) {
pw[0] = 1;
for (int i = 1; i <= n; ++i) {
pw[i] = 1LL * pw[i - 1] * 23 % mod;
}
ll ans = 0;
for (int i = 1; i <= n; ++i) {
while (hd <= tl && q[hd] <= i - m) {
++hd;
Q.dell();
}
while (hd <= tl && a[q[tl]] <= a[i]) {
--tl;
Q.delr();
}
q[++tl] = i;
Q.addr(f[q[tl - 1]] + a[i]);
Q.updl(f[max(0, i - m)] + a[q[hd]]);
f[i] = Q.query();
ans = (ans + f[i] % mod * pw[n - i] % mod) % 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; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccBiVJBw.o: in function `main': implementer.cpp:(.text.startup+0x151): undefined reference to `solve(int, int, int*)' collect2: error: ld returned 1 exit status