QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116875#149. Peruxtqqwq#0 45ms93752kbC++142.7kb2023-06-30 09:42:222024-09-10 16:35:00

Judging History

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

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

answer

#include<bits/stdc++.h>
#include"peru.h"

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

struct node{
	ll x;
	int l,r;
	node(ll x=0,int l=0,int r=0):x(x),l(l),r(r){}
	bool operator==(const node c)const{return x==c.x&&r==c.r;}
	bool operator<(const node c)const{return x==c.x?r<c.r:x>c.x;}
}q[2500005];

const int cys=1000000007;
int top,front,rear,mid;
int a[2500005],stk[2500005];
ll d[2500005],min1[2500005],min2[2500005];
priority_queue<node> q1,q2;

void rebuild(int l,int r){
	int mid=(l+r-1)/2;
	min1[mid+1]=min2[mid]=1ll<<60;
	for(int i=mid;i>=l;i--) min1[i]=min(min1[i+1],q[i].x);
	for(int i=mid+1;i<r;i++) min2[i]=min(min2[i-1],q[i].x);
}

void pop2(){
	rear--;
	if(mid==rear) rebuild(front,rear);
}

void pop1(){
	front++;
	if(front==mid+1) rebuild(front,rear);
}

void push2(node th){
	q[rear++]=th;
	if(front+1==rear) rebuild(front,rear);
	else min2[rear-1]=min(rear-2<=mid?(1ll<<60):min2[rear-2],th.x);
}

int solve(int n,int k,int *S){
	for(int i=0;i<n;i++) a[i+1]=S[i];
	d[0]=0;
	int cur=0;
	for(int i=1;i<=n;i++){
		// cout<<"################ "<<i<<endl;
		while(top&&a[stk[top]]<a[i]){
			if(stk[top-1]>=i-k-1){
				// cout<<"erase "<<stk[top-1]<<' '<<stk[top]<<' '<<d[stk[top-1]]+a[stk[top]]<<endl;
				// q2.push(node(d[stk[top-1]]+a[stk[top]],stk[top-1],stk[top]));
				if(front<rear&&q[rear-1].l==stk[top-1]) pop2();
			}
			top--;
		}
		// cout<<"insert "<<stk[top]<<' '<<i<<' '<<d[stk[top]]+a[i]<<endl;
		// q1.push(node(d[stk[top]]+a[i],stk[top],i));
		node th(d[stk[top]]+a[i],stk[top],i);
		if(front<rear&&q[rear-1].l==stk[top]) pop2();
		push2(th);
		stk[++top]=i;
		d[i]=1ll<<60;
		// while(!q1.empty()&&!q2.empty()&&q1.top()==q2.top()) q1.pop(),q2.pop();
		// while(!q1.empty()&&q1.top().l<i-k){
		// 	q1.pop();
		// 	while(!q1.empty()&&!q2.empty()&&q1.top()==q2.top()) q1.pop(),q2.pop();
		// }
		while(front<rear&&q[front].l<i-k) pop1();
		if(front<rear) chkmin(d[i],min(front<=mid?min1[front]:(1ll<<60),mid+1<rear?min2[rear-1]:(1ll<<60)));
		// for(int i=front;i<rear;i++) cout<<q[i].l<<' '<<q[i].r<<' '<<q[i].x<<endl;
		// if(!q1.empty()) chkmin(d[i],q1.top().x);
		chkmin(cur,top);
		while(stk[cur]<=i-k) cur++;
		if(i>=k) chkmin(d[i],d[i-k]+a[stk[cur]]);
	}
	// for(int i=1;i<=n;i++) cout<<d[i]<<' ';
	// cout<<endl;
	ll ret=0;
	for(int i=1;i<=n;i++) ret=(ret*23+d[i])%cys;
	return ret;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 51344kb

input:

2000 170
1054018657 1037445664 1011691297 1009972317 1006506677 1002579733 999792775 999477541 975467893 970302369 968173111 957735623 953086083 938540451 932313113 930563895 924682633 917831575 913506401 908739591 905368525 899452913 894354220 890127447 885923007 583391543 880642788 878397752 87822...

output:

283575538

result:

wrong answer 1st lines differ - expected: '559335223', found: '283575538'

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 14ms
memory: 58912kb

input:

400000 1000
1999989721 1999987224 1999984551 1999977673 1999977545 1999976801 1999975837 1999972607 1999956301 1999952801 1999942489 1999940593 1999940337 1999936353 1999936273 1999926073 1999925513 1999922980 1999918301 1999912501 1999909301 1999906125 1999902913 1999895622 1999893617 1999885490 19...

output:

285003781

result:

wrong answer 1st lines differ - expected: '677928817', found: '285003781'

Subtask #3:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 45ms
memory: 93752kb

input:

2500000 2000
1073315871 1073250349 1072791751 1072104046 1072071097 1071841833 1071809381 1071710686 1071580105 1071482003 1071383725 1071154701 1070499431 1070335288 1070334157 1069943617 1069681476 1069584279 1069581771 1069322519 1069189353 1069125955 1068832186 1068797487 1068662939 1068565681 1...

output:

994283579

result:

wrong answer 1st lines differ - expected: '12623259', found: '994283579'