QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116931#149. Peruabs998244353#Compile Error//C++171.9kb2023-06-30 10:55:132024-05-31 18:35:01

Judging History

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

  • [2024-09-10 16:36:11]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:165ms
  • 内存:119048kb
  • [2024-05-31 18:35:01]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 10:55:13]
  • 提交

answer

#include "peru.h"
#include <cstdio>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=2500003;
const int P=1000000007;
int s[N];
ll f[N];
list<int> lis[N];
int mx[N],tp;
int pos;
void chmn(ll &x,ll v){if(x>v) x=v;}
namespace ds{
	ll seq[N];int rk;
	ll sl[N],pl[N];int cl;
	ll sr[N],pr[N];int cr;
	void push_back(ll x){/*printf("pushback %lld\n",x);*/sr[++cr]=x;chmn(pr[cr]=sr[cr],pr[cr-1]);}
   void push_front(ll x){/*printf("pushfront %lld\n",x);*/sl[++cl]=x;chmn(pl[cl]=sl[cl],pl[cl-1]);}
	void build(){
		int mid=(rk>>1);
		for(int i=mid;i;--i) push_front(seq[i]);
		for(int i=mid+1;i<=rk;++i) push_back(seq[i]);
		rk=0;
	}
	void pop_back(){
		//puts("popback");
		if(cr) --cr;
		else{
			rk=0;
			while(cl) seq[++rk]=sl[cl--];
			--rk;build();
		}
	}
	void pop_front(){
		//puts("popfront");
		if(cl) --cl;
		else{
			rk=0;
			for(int i=2;i<=cr;++i) seq[++rk]=sr[i];
			cr=0;build();
		}
	}
	ll get_min(){
		if(cl&&!cr) return pl[cl];
		if(cr&&!cl) return pr[cr];
		return min(pl[cl],pr[cr]);
	}
}
int solve(int n,int k,int* _s){
	ds::pl[0]=ds::pr[0]=INF;
	for(int i=1;i<=n;++i) s[i]=_s[i-1];
	int res=0;
	pos=1;
	for(int i=1;i<=n;++i){
		list<int> cur;
		cur.emplace_back(i-1);
		while(tp&&mx[tp]<=s[i]){
			if(tp>=pos) ds::pop_back();
			cur.swap(lis[tp]);
			while(!cur.empty()&&f[cur.back()]>=f[lis[tp].front()]) cur.pop_back();
			cur.splice(cur.end(),lis[tp--]);
		}
		lis[++tp]=cur;mx[tp]=s[i];
		if(pos>tp) pos=tp;
		ds::push_back(f[cur.front()]+s[i]);
		while(lis[pos].empty()) ++pos;
		while(lis[pos].front()<i-k){
			lis[pos].pop_front();
			ds::pop_front();
			if(!lis[pos].empty()) ds::push_front(f[lis[pos].front()]+mx[pos]);
			else while(lis[pos].empty()) ++pos;
		}
		f[i]=ds::get_min();
		res=(res*23ll+f[i])%P;
		//printf("f[%d]=%lld\n",i,f[i]);
	}
    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;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~