QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116900#149. Peruyoungsystem#Compile Error//C++201.8kb2023-06-30 10:13:302024-05-31 18:34:10

Judging History

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

  • [2024-09-10 16:35:52]
  • 管理员手动重测本题所有提交记录
  • 测评结果:100
  • 用时:62ms
  • 内存:53284kb
  • [2024-05-31 18:34:10]
  • 评测
  • [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:13:30]
  • 提交

answer

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int a[2500005];
int que[2500005],ql,qr;
long long dp[2500005];
long long sta1[2500005];
int top1;
long long min1[2500005];
long long sta2[2500005];
int top2;
long long min2[2500005];
void popfirst()
{
	if(top1>=1)top1--;
	else
	{
		int mid=(top2+1)/2;
		for(int i=mid;i>=1;i--)sta1[++top1]=sta2[i];
		for(int i=mid+1;i<=top2;i++)sta2[i-mid]=sta2[i];
		top2-=mid;
		min1[1]=sta1[1];
		for(int i=2;i<=top1;i++)min1[i]=min(min1[i-1],sta1[i]);
		min2[1]=sta2[1];
		for(int i=2;i<=top2;i++)min2[i]=min(min2[i-1],sta2[i]);
		top1--;
	}
}
void popback()
{
	if(top2>=1)top2--;
	else
	{
		int mid=(top1+1)/2;
		for(int i=mid;i>=1;i--)sta2[++top2]=sta1[i];
		for(int i=mid+1;i<=top1;i++)sta1[i-mid]=sta1[i];
		top1-=mid;
		min1[1]=sta1[1];
		for(int i=2;i<=top1;i++)min1[i]=min(min1[i-1],sta1[i]);
		min2[1]=sta2[1];
		for(int i=2;i<=top2;i++)min2[i]=min(min2[i-1],sta2[i]);
		top2--;
	}
}
void pushback(long long x)
{
	sta2[++top2]=x;
	if(top2==1)min2[top2]=x;
	else min2[top2]=min(x,min2[top2-1]);
}
long long findmin()
{
	long long ans=1000000000000000000LL;
	if(top1>=1)ans=min(ans,min1[top1]);
	if(top2>=1)ans=min(ans,min2[top2]);
	return ans;
}
int solve(int n,int k,int* S)
{
	for(int i=1;i<=n;i++)a[i]=S[i-1];
	ql=qr=1;
	que[1]=0;
	a[0]=2000000000;
	for(int i=1;i<=n;i++)
	{
		while(qr>=ql&&que[ql]<i-k)
		{
			if(ql<qr)popfirst();
			ql++;
		}
		while(qr>=ql&&a[que[qr]]<=a[i])
		{
			if(ql<qr)popback();
			qr--;
		}
		dp[i]=1000000000000000000LL;
		if(ql<=qr)pushback(dp[que[qr]]+a[i]);
		que[++qr]=i;
		dp[i]=findmin();
		if(i>=k)dp[i]=min(dp[i],dp[i-k]+a[que[ql]]);
		//printf("%d %d %d %lld\n",top1,top2,i,dp[i]); 
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans=(23LL*ans+dp[i]%mod)%mod;
	return ans;
}

详细

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