QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#524568#149. PeruRafi22#Compile Error//C++201.8kb2024-08-19 20:11:442024-08-19 20:11:45

Judging History

你现在查看的是测评时间为 2024-08-19 20:11:45 的历史记录

  • [2024-09-10 16:46:32]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:76ms
  • 内存:85488kb
  • [2024-08-19 20:11:45]
  • 评测
  • [2024-08-19 20:11:44]
  • 提交

answer

#include "peru.h"
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=2000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;

const int N=2500007;

ll DP[N];
int a[N];
vector<pair<int,int>>G[N];

int solve(int n,int k,int* v)
{
	FOR(i,1,n) a[i]=v[i-1];
	a[0]=inf,a[n+1]=inf;
	vector<pair<int,int>>X;
	X.pb({inf+1,0});
	FOR(i,1,n+1)
	{
		int last=-1;
		while(X.back().st<a[i]) 
		{
			last=X.back().st;
			X.pop_back();
		}
		if(last!=-1&&i-1-X.back().nd<=k) G[i-1].pb({X.back().nd,last});
		X.pb({a[i],i});
	}
	X.clear();
	X.pb({inf+1,n+1});
	ROF(i,n,0)
	{
		int last=-1;
		while(X.back().st<=a[i]) 
		{
			last=X.back().st;
			X.pop_back();
		}
		if(last!=-1&&X.back().nd-1-i<=k) G[X.back().nd-1].pb({i,last});
		X.pb({a[i],i});
	}
	deque<pair<ll,int>>Q;
	FOR(i,1,n)
	{
		DP[i]=infl;
		if(sz(Q)>0&&Q[0].nd<=i-k) Q.pop_front();
		while(sz(Q)>0&&Q.back().st<a[i]) Q.pop_back();
		Q.pb({a[i],i});
		if(i>=k) DP[i]=DP[i-k]+Q[0].st;
		for(auto [j,c]:G[i])
		{
			debug(i,j,c);
			DP[i]=min(DP[i],DP[j]+c);
		}
	}
	ROF(i,n-1,1) DP[i]=min(DP[i],DP[i+1]);
	FOR(i,1,n) debug(DP[i]);
	ll h=0,pot=1;
	ROF(i,n,1)
	{
		h=(h+DP[i]%mod*pot)%mod;
		pot=pot*23%mod;
	}
    return (int)h;
}

詳細信息

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