QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116832#149. PeruLinshey#Compile Error//C++141.4kb2023-06-30 09:04:052024-05-31 18:30:34

Judging History

你现在查看的是测评时间为 2024-05-31 18:30:34 的历史记录

  • [2024-09-10 16:34:20]
  • 管理员手动重测本题所有提交记录
  • 测评结果:49
  • 用时:176ms
  • 内存:35320kb
  • [2024-05-31 18:30:34]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 09:04:05]
  • 提交

answer


#include <bits/stdc++.h>

#include "peru.h"

using namespace std; const int maxn = 2.5e6 + 5, mod = 1e9 + 7; typedef long long ll;

ll tr[maxn << 2], tg[maxn << 2];

inline void C(int u, ll k) { tr[u] += k, tg[u] += k; }

void update(int u, int l, int r, int ul, int ur, ll k)
{
    if (ul <= l && r <= ur) return C(u, k); int mid = l + r >> 1;
    if (ul <= mid) update(u << 1, l, mid, ul, ur, k); if (ur > mid) update(u << 1 | 1, mid + 1, r, ul, ur, k);
    tr[u] = min(tr[u << 1], tr[u << 1 | 1]) + tg[u];
}

ll ask(int u, int l, int r, int ul, int ur)
{
    if (ul <= l && r <= ur) return tr[u]; int mid = l + r >> 1; ll res = 1e18;
    if (ul <= mid) res = min(res, ask(u << 1, l, mid, ul, ur));
    if (ur > mid) res = min(res, ask(u << 1 | 1, mid + 1, r, ul, ur)); return res + tg[u];
}

ll X[maxn];

int sk[maxn], tp;

int solve(int n, int k, int* v)
{
    sk[tp = 0] = -1;
    update(1, 0, n, 0, 0, v[0]);
    for (int i = 0; i < n; i++)
    {
        // update(1, 0, n, i, i, v[i]);
        while (tp && v[sk[tp]] <= v[i]) update(1, 0, n, sk[tp - 1] + 1, sk[tp], v[i] - v[sk[tp]]), tp--;
        sk[++tp] = i;
        X[i] = ask(1, 0, n, max(0, i - k + 1), i);
        if (i + 1 < n)
        update(1, 0, n, i + 1, i + 1, X[i] + v[i + 1]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans = (23ll * ans + X[i]) % mod;
    // for (int i = 0; i < n; i++) cerr << X[i] << ' '; cerr << endl;
    return ans;
}

Details

implementer.cpp: In function ‘int main()’:
implementer.cpp:34:13: error: ‘fout’ was not declared in this scope; did you mean ‘out’?
   34 |     fprintf(fout, "%d\n", sol);
      |             ^~~~
      |             out
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;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~