QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#866840#8811. Heat StrokelgvcCompile Error//C++233.8kb2025-01-22 19:59:142025-01-22 19:59:15

Judging History

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

  • [2025-01-22 19:59:15]
  • 评测
  • [2025-01-22 19:59:14]
  • 提交

answer

#include <bits/stdc++.h>
//0 qian j ge
//1 hou j ge
#define INF 0x3f3f3f3f
int N,L,va[8009],c[8009],la[8009][8009],vc[70000009][2],v2[70000009][2],
su[8009],ff[8009][8009],su2[8009],v3[70000009][2];
std::vector<int> t[8009];
int sv2(int n,int x,int y,int op);
int sv(int n,int x,int y,int op);
int fd(int n,int x,int y,int op) {
	int a=sv(n,x,y,op);
	if((n==N-1)||(x==c[n])) return a;
	int l1=0;
	if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
	a=std::min(a,sv2(n,ff[n+1][l1],y,op)+x);
	return a;
}
int fd2(int n,int x,int y,int op) {
	if(x>c[n]) return INF;
	int id=x*(c[n]+1)+y+su[n-1];
	if(v3[id][op]!=-1) return v3[id][op];
	return v3[id][op]=std::min(fd(n,x,y,op),fd2(n,x+1,y,op));
}
int sv2(int n,int x,int y,int op) {
	if(x<0) return INF;
	int id=x*(c[n]+1)+y+su2[n-1];
	if(v2[id][op]!=-1) return v2[id][op];
	int ans=sv2(n,x-1,y,op);
	for(int xx=x;xx<=x;xx++) {
		int l2=0,l1=0;
		if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
		if(xx<c[n+1]) l2=t[n+1][xx+1]-1;else l2=L;
		//if(l2>l1) continue;
		int lim=l2;
		int tp1=la[lim][n],tp2=la[lim][n+1];
		int vv=va[n+1];
		if(op==1) vv-=std::min(y,tp1);
		else vv-=(std::max(tp1,y)-y);	
		if(vv<=0) {
			ans=std::min(ans,fd(n+1,xx,0,0));
		} else {
			int yy=vv;
			if(yy<=tp2) ans=std::min(ans,fd(n+1,xx,yy,0));	
			yy=vv+xx-std::min(xx,tp2);
			if(yy<=xx) ans=std::min(ans,fd(n+1,xx,xx-yy,1));				
		}
	}
	return v2[id][op]=ans;
}
int sv(int n,int x,int y,int op) {
	int id=x*(c[n]+1)+y+su[n-1];
	if(n==N-1) {
		if(op==1) y=x-y;
		if(x<c[n]&&(x-y)<va[n+1]) return INF;
		return x;
	}
	if(vc[id][op]!=-1) {
		return vc[id][op];
	}
	int ans=INF;
	int limm=0;
	//if(x<c[n]) limm=c[n+1];
	int l1=0;
	if(x<c[n]) l1=t[n][x+1]-1;else l1=L;
	if(x<c[n]) limm=ff[n+1][l1]+1;
	if(x==c[n]) {
		for(int xx=0;xx<=c[n+1];xx++) {
			int l2=0;
			if(xx<c[n+1]) l2=t[n+1][xx+1]-1;else l2=L;
			//assert(l1<=l2);
			int lim=std::min(l1,l2);
			int tp1=la[lim][n],tp2=la[lim][n+1];
			int vv=va[n+1];
			if(op==1) vv-=std::min(y,tp1);
			else vv-=(std::max(tp1,y)-y);	
			if((vv<=0)||(xx==c[n+1]&&x==c[n])) {
				ans=std::min(ans,fd(n+1,xx,0,0)+x);
			} else {
				if(vv<=tp2) ans=std::min(ans,fd(n+1,xx,vv,0)+x);	
				if(vv<=tp2) ans=std::min(ans,fd(n+1,xx,tp2-vv,1)+x);				
			}
		}
	} else {
		int lim=l1;
		int tp1=la[lim][n],tp2=la[lim][n+1];
		int vv=va[n+1];
		if(op==1) vv-=std::min(y,tp1);
		else vv-=(std::max(tp1,y)-y);	
		if(vv<=0) {
			ans=std::min(ans,fd2(n+1,limm,0,0)+x);
		} else if(vv<=tp2) {
			ans=std::min(ans,fd2(n+1,limm,vv,0)+x);
			ans=std::min(ans,fd2(n+1,limm,tp2-vv,1)+x);			
		}
//		for(int xx=limm;xx<=c[n+1];xx++) {
//			if((vv<=0)||(xx==c[n+1]&&x==c[n])) {
//				ans=std::min(ans,fd(n+1,xx,0,0)+x);
//			} else {
//				if(vv<=tp2) ans=std::min(ans,fd(n+1,xx,vv,0)+x);	
//				if(vv<=tp2) ans=std::min(ans,fd(n+1,xx,tp2-vv,1)+x);				
//			}
//		}
	}
	return vc[id][op]=ans;
}
signed main(void) {
	memset(vc,-1,sizeof(vc));
	memset(v3,-1,sizeof(v3));
	memset(v2,-1,sizeof(v2));
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		scanf("%d",&va[i]);
		t[i].push_back(0);
	}
	scanf("%d",&L);
	for(int i=1;i<=L;i++) {
		int x;
		scanf("%d",&x);
		t[x].push_back(i);
		c[x]++;
		for(int j=1;j<=N;j++) {
			la[i][j]=la[i-1][j];
		}
		la[i][x]=t[x].size()-1;
	}
	for(int i=1;i<=N;i++) {
		int la=0;
		for(int j=0;j<=c[i];j++) {
			int l2=0;
			if(j<c[i]) l2=t[i][j+1]-1;else l2=L+1;
			for(int k=la;k<l2;k++) {
				ff[i][k]=j-1;
			}
			la=l2;
		}
	}
	for(int i=1;i<=N;i++) {
		su[i]=su[i-1]+(c[i]+1)*(c[i]+1);
		su2[i]=su2[i-1]+(c[i]+1)*c[i+1];
		assert(su2[i]<=70000000);
	}
	int ans=0x3f3f3f3f;
	for(int i=0;i<=c[1];i++) {
		for(int j=0;j<=i&&j<=va[1];j++) {
			if((i==c[1])||(j==va[1])) ans=std::min(ans,fd(1,i,j,0));
			if((i==c[1])||(j==va[1])) ans=std::min(ans,fd(1,i,i-j,1));
		}
	}
//	printf("%d\n",sv(4,0,0,0));
	printf("%d",L-ans);
}

Details

answer.code: In function ‘int main()’:
answer.code:110:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  110 |         scanf("%d",&N);
      |         ~~~~~^~~~~~~~~
answer.code:112:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  112 |                 scanf("%d",&va[i]);
      |                 ~~~~~^~~~~~~~~~~~~
answer.code:115:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  115 |         scanf("%d",&L);
      |         ~~~~~^~~~~~~~~
answer.code:118:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  118 |                 scanf("%d",&x);
      |                 ~~~~~^~~~~~~~~
/tmp/cc6j4pou.o: in function `sv(int, int, int, int)':
answer.code:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x77): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0xeb): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x189): relocation truncated to fit: R_X86_64_PC32 against symbol `va' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x1e3): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x20e): relocation truncated to fit: R_X86_64_PC32 against symbol `va' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x281): relocation truncated to fit: R_X86_64_PC32 against symbol `va' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x311): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x392): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cc6j4pou.o
/tmp/cc6j4pou.o: in function `fd(int, int, int, int)':
answer.code:(.text+0x4a0): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc6j4pou.o
answer.code:(.text+0x4b1): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status