QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116812#149. PeruKevin5307#Compile Error//C++141.8kb2023-06-30 08:46:152024-05-31 18:29:56

Judging History

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

  • [2024-09-10 16:33:45]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:69ms
  • 内存:33116kb
  • [2024-05-31 18:29:56]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-30 08:46:15]
  • 提交

answer

//Author: Kevin5307
#include<bits/stdc++.h>
#include"peru.h"
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
ll dp[2500250];
int solve(int n,int k,int *S)
{
	S--;
//	int mx=0;
	deque<int> dq1;
	deque<pair<int,ll>> dq2;
	S[0]=inf;
	dq1.push_back(0);
	for(int i=1;i<=n;i++)
	{
//		mx=max(mx,S[i]);
//		dp[i]=mx;
		while(sz(dq1)&&dq1.front()<=i-k)
			dq1.pop_front();
		while(sz(dq1)&&S[dq1.back()]<S[i])
			dq1.pop_back();
		if(sz(dq1))
		{
			int p=dq1.back();
			while(sz(dq2)&&dq2.back().first>=p)
				dq2.pop_back();
			while(sz(dq2)&&dq2.back().second>=dp[p]+S[i])
				dq2.pop_back();
			dq2.push_back(mp(p,dp[p]+S[i]));
		}
		else
			dq2.clear();
		dq1.push_back(i);
		while(sz(dq2)&&dq2.front().first<i-k)
			dq2.pop_front();
		dp[i]=inf;
//		for(auto x:dq1)
//			cerr<<x<<" ";
//		cerr<<endl;
//		for(auto pr:dq2)
//			cerr<<"("<<pr.first<<","<<pr.second<<") ";
//		cerr<<endl;
//		cerr<<endl;
		if(sz(dq1))
			dp[i]=min(dp[i],dp[i-k]+S[dq1.front()]);
		if(sz(dq2))
			dp[i]=min(dp[i],dq2.front().second);
	}
//	for(int i=1;i<=n;i++)
//		cerr<<dp[i]<<" ";
//	cerr<<endl;
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=(1ll*ans*23+dp[i])%1000000007;
	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;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~