QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#152899 | #149. Peru | AbdelmagedNour# | Compile Error | / | / | C++20 | 1.9kb | 2023-08-28 23:00:13 | 2024-07-04 02:41:23 |
Judging History
你现在查看的是测评时间为 2024-07-04 02:41:23 的历史记录
- [2024-07-04 02:41:23]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [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; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~