QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124160#149. PerudengtingyuCompile Error//C++141.5kb2023-07-14 11:12:112024-09-10 16:39:16

Judging History

你现在查看的是最新测评结果

  • [2024-09-10 16:39:16]
  • 管理员手动重测本题所有提交记录
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 11:12:14]
  • 评测
  • [2023-07-14 11:12:11]
  • 提交

answer

#include<bits/stdc++.h>
#include "peru.h"
using namespace std;
#define ll long long
#define N 2500010
#define yu (1000000007)
inline void add(ll &x,ll y){x+=y;if(x>=yu)x-=yu;return;}
#define inf 1e9
ll n,k;
ll a[N];
ll pw[N];
ll f[N];
struct node{
	ll st1[N],st2[N],top1=0,top2=0;
	ll mi1[N],mi2[N];
	inline void cg(ll x){
		ll p=(top1+top2+x)>>1,q=top1+top2-p;vector<ll>xu;
		for(int i=top1;i>=1;i--)xu.push_back(st1[i]);for(int i=1;i<=top2;i++)xu.push_back(st2[i]);
		ll nw=0;for(int i=p;i>=1;i--)st1[i]=xu[nw++];for(int i=1;i<=q;i++)st2[i]=xu[nw++];
		for(int i=1;i<=p;i++)mi1[i]=min(mi1[i-1],st1[i]);for(int i=1;i<=q;i++)mi2[i]=min(mi2[i-1],st2[i]);
		top1=p;top2=q;
		return ;
	}inline void popfront(){
		if(!top1)cg(1);if(top1)top1--;
		return ;
	}inline void popback(){
		if(!top2)cg(0);if(top2)top2--;
		return ;
	}inline ll ask(){
		return min(mi1[top1],mi2[top2]);
	}inline void insert(ll x){
		st2[++top2]=x;mi2[top2]=min(mi2[top2-1],x);
		return ;
	}
}o;
ll q[N],ql,qr;
int solve(int N,int K,int *s){
	n=N;k=K;for(int i=1;i<=n;i++)a[i]=s[i-1];
	o.mi1[0]=o.mi2[0]=inf;
	pw[0]=1;for(int i=1;i<=n;i++)pw[i]=pw[i-1]*23%yu;ql=1;qr=0;
	for(int i=1;i<=n;i++){
		while(q[ql]<i-k&&ql<=qr)ql++,o.popfront();
		while(a[q[qr]]<a[i]&&ql<=qr)qr--,o.popback();
		q[++qr]=i;if(qr>ql)o.insert(f[q[qr-1]]+a[i]);
		f[i]=o.ask();
		f[i]=min(f[i],f[max(0ll,i-k)]+a[q[1]]);
	}ll ans=0;
	for(int i=1;i<=n;i++)add(ans,f[i]*pw[n-i]%yu);
	return ans;
}

詳細信息

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:5:11: error: expected ‘,’ or ‘...’ before numeric constant
    5 | #define N 2500010
      |           ^~~~~~~
answer.code:37:15: note: in expansion of macro ‘N’
   37 | int solve(int N,int K,int *s){
      |               ^
answer.code: In function ‘int solve(int)’:
answer.code:38:15: error: ‘K’ was not declared in this scope
   38 |         n=N;k=K;for(int i=1;i<=n;i++)a[i]=s[i-1];
      |               ^
answer.code:38:43: error: ‘s’ was not declared in this scope
   38 |         n=N;k=K;for(int i=1;i<=n;i++)a[i]=s[i-1];
      |                                           ^