QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152899#149. PeruAbdelmagedNour#Compile Error//C++201.9kb2023-08-28 23:00:132024-07-04 02:41:23

Judging History

你现在查看的是测评时间为 2024-07-04 02:41:23 的历史记录

  • [2024-09-10 16:43:33]
  • 管理员手动重测本题所有提交记录
  • 测评结果:18
  • 用时:2ms
  • 内存:8200kb
  • [2024-07-04 02:41:23]
  • 评测
  • [2023-08-28 23:00:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
//#include "grader.cpp"
#include "peru.h"
typedef long long ll;
const int N=2500005,mod=(1e9)+7;
struct SegTree{
    ll tree[1<<23][2],sz;
    #define val(p) tree[p][0]
    #define lazy(p) tree[p][1]
    void init(int n){
        sz=1;
        while(sz<n)sz*=2;
    }
    void push(int p){
        if(lazy(p)){
            for(auto ch:{p*2+1,p*2+2}){
                lazy(ch)+=lazy(p);
                val(ch)+=lazy(p);
            }
            lazy(p)=0;
        }
    }
    void update(int l,int r,int p,int l_q,int r_q,ll val){
        if(l_q<=l&&r<=r_q){
            lazy(p)+=val;
            val(p)+=val;
            return;
        }
        push(p);
        int md=(l+r)>>1;
        if(l_q<=md)update(l,md,p*2+1,l_q,r_q,val);
        if(md<r_q)update(md+1,r,p*2+2,l_q,r_q,val);
        val(p)=min(val(p*2+1),val(p*2+2));
    }
    void update(int l,int r,ll val){
        update(0,sz-1,0,l,r,val);
    }
    ll query(int l,int r,int p,int idx){
        if(l==r)return val(p);
        push(p);
        int md=(l+r)>>1;
        if(idx<=md)return query(l,md,p*2+1,idx);
        else return min(val(p*2+1),query(md+1,r,p*2+2,idx));
    }
    ll query(int idx){
        return query(0,sz-1,0,idx);
    }
}tree;
ll dp[N];
int solve(int n, int k, int* v){
    dp[0]=0;
    tree.init(n+1);
    vector<int>st;
    for(int i=1;i<=n;i++){
        while(!st.empty()&&v[st.back()]<=v[i-1]){
            int l=0,r=st.back();st.pop_back();
            if(!st.empty())l=st.back()+1;
            tree.update(l,r,-v[r]);
        }
        int l=0,r=i-1;
        if(!st.empty())l=st.back()+1;
        tree.update(l,r,v[i-1]);
        dp[i]=tree.query(i-1);
        tree.update(i,i,dp[i]);
        st.push_back(i-1);
        if(i>=k)tree.update(i-k,i-k,1LL<<50);
    }
    long long res=0;
    for(int i=1;i<=n;i++)res=(res*23+dp[i])%mod;
    return res;
}

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;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~