QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396463#7988. 史莱姆工厂zyxawaCompile Error//C++144.0kb2024-04-22 20:15:352024-04-22 20:15:37

Judging History

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

  • [2024-04-22 20:15:37]
  • 评测
  • [2024-04-22 20:15:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,s,w,c[151],m[151],p[21];
ll f[151][151],fl[151][151][21],fr[151][151][21];
void upd(ll &x,ll y){x=max(x,y);}
int main(){
	memset(f,-0x3f,sizeof(f)),memset(fl,-0x3f,sizeof(fl)),memset(fr,-0x3f,sizeof(fr));
	scanf("%d%d%d",&n,&s,&w);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	for(int i=1;i<=n;i++) scanf("%d",&m[i]);
	for(int i=s;i<=2*s-2;i++) scanf("%d",&p[i]);
	for(int i=1;i<s;i++) p[i]=p[s]-(s-i)*w;
	for(int i=1;i<=n;i++) f[i][i]=p[m[i]],fl[i][i][m[i]]=fr[i][i][m[i]]=f[i][i-1]=0;
	for(int t=2;t<=n;t++){
		for(int l=1;l+t-1<=n;l++){
			int r=l+t-1;
			// upd(fl[l][r][m[l]],f[l+1][r]);
			// for(int k=l+1;k<r;k++) if(c[k]==c[l]) for(int i=1;i<s-m[k];i++) upd(fl[l][r][i+m[k]],fl[l][k-1][i]+f[k+1][r]);
			// upd(fr[l][r][m[r]],f[l][r-1]);
			// for(int k=l+1;k<r;k++) if(c[k]==c[r]) for(int i=1;i<s-m[k];i++) upd(fr[l][r][i+m[k]],fr[k+1][r][i]+f[l][k-1]);
			if(c[l]!=c[r+1]){
				upd(fl[l][r][m[l]],f[l+1][r]);
				for(int k=l-1;k<r;k++) if(c[k+1]==c[l]) for(int i=1;i+m[l]<s;i++) upd(fl[l][r][i+m[l]],max(f[l][k]+fl[k+1][r][i],fl[l][k][i]+f[k+1][r]));
			}
			if(c[r]!=c[l-1]){
				upd(fr[l][r][m[l]],f[l][r-1]);
				for(int k=l;k<=r;k++) if(c[k]==c[r]) for(int i=1;i+m[r]<s;i++) upd(fr[l][r][i+m[r]],max(f[k+1][r]+fr[l][k][i],fr[k+1][r][i]+f[l][k]));
			}
			// if(c[l-1]==c[r+1]) continue;
			for(int k=l;k<r;k++) if(c[k]!=c[r+1]||c[k+1]!=c[l-1]) upd(f[l][r],f[l][k]+f[k+1][r]);
			if(c[l]!=c[r]) continue;
			upd(f[l][r],f[l+1][r-1]+p[m[l]+m[r]]);

			// for(int k=l+1;k<r;k++){
			// 	if(c[k]==c[l]){
			// 		for(int i=1;i<s;i++){
			// 			for(int j=1;j<s;j++){
			// 				if(i+m[k]<s||j+m[k]<s) upd(f[l][r],fl[l][k-1][i]+fr[k+1][r][j]+p[i+j+m[k]]);
			// 			}
			// 		}
			// 	}
			// }
			for(int k=l;k<r;k++){
				for(int i=1;i<s;i++){
					for(int j=1;j<s;j++){
						upd(f[l][r],fl[l][k][i]+fr[k+1][r][j]+p[i+j]);
					}
				}
			}
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}
//dp[l][r][k][c]区间[l,r]剩下一个重量k,颜色为c的最大值#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,s,w,c[151],m[151],p[21];
ll f[151][151],fl[151][151][21],fr[151][151][21];
void upd(ll &x,ll y){x=max(x,y);}
int main(){
	memset(f,-0x3f,sizeof(f)),memset(fl,-0x3f,sizeof(fl)),memset(fr,-0x3f,sizeof(fr));
	scanf("%d%d%d",&n,&s,&w);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	for(int i=1;i<=n;i++) scanf("%d",&m[i]);
	for(int i=s;i<=2*s-2;i++) scanf("%d",&p[i]);
	for(int i=1;i<s;i++) p[i]=p[s]-(s-i)*w;
	for(int i=1;i<=n;i++) f[i][i]=p[m[i]],fl[i][i][m[i]]=fr[i][i][m[i]]=f[i][i-1]=0;
	for(int t=2;t<=n;t++){
		for(int l=1;l+t-1<=n;l++){
			int r=l+t-1;
			//upd(fl[l][r][m[l]],f[l+1][r]);
			//for(int k=l+1;k<r;k++) if(c[k]==c[l]) for(int i=1;i<s-m[k];i++) upd(fl[l][r][i+m[k]],fl[l][k-1][i]+f[k+1][r]);
			//upd(fr[l][r][m[r]],f[l][r-1]);
			//for(int k=l+1;k<r;k++) if(c[k]==c[r]) for(int i=1;i<s-m[k];i++) upd(fr[l][r][i+m[k]],fr[k+1][r][i]+f[l][k-1]);
			if(c[l]!=c[r+1]){
			upd(fl[l][r][m[l]],f[l+1][r]);
			for(int k=l-1;k<r;k++) if(c[k+1]==c[l]) for(int i=1;i+m[l]<s;i++) upd(fl[l][r][i+m[l]],f[l][k]+fl[k+1][r][i]);
			}
			if(c[r]!=c[l-1]){
			upd(fr[l][r][m[l]],f[l][r-1]);
			for(int k=l;k<=r;k++) if(c[k]==c[r]) for(int i=1;i+m[r]<s;i++) upd(fr[l][r][i+m[r]],f[k+1][r]+fr[l][k][i]);
			}
			if(c[l-1]==c[r+1]) continue;
			for(int k=l;k<r;k++) if(c[k]!=c[r+1]||c[k+1]!=c[l-1]) upd(f[l][r],f[l][k]+f[k+1][r]);
			if(c[l]!=c[r]) continue;
			upd(f[l][r],f[l+1][r-1]+p[m[l]+m[r]]);

			// for(int k=l+1;k<r;k++){
			// 	if(c[k]==c[l]){
			// 		for(int i=1;i<s;i++){
			// 			for(int j=1;j<s;j++){
			// 				if(i+m[k]<s||j+m[k]<s) upd(f[l][r],fl[l][k-1][i]+fr[k+1][r][j]+p[i+j+m[k]]);
			// 			}
			// 		}
			// 	}
			// }
			for(int k=l;k<r;k++){
				for(int i=1;i<s;i++){
					for(int j=1;j<s;j++){
						upd(f[l][r],fl[l][k][i]+fr[k+1][r][j]+p[i+j]);
					}
				}
			}
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}
//dp[l][r][k][c]区间[l,r]剩下一个重量k,颜色为c的最大值

Details

answer.code:59:5: error: redefinition of ‘int n’
   59 | int n,s,w,c[151],m[151],p[21];
      |     ^
answer.code:4:5: note: ‘int n’ previously declared here
    4 | int n,s,w,c[151],m[151],p[21];
      |     ^
answer.code:59:7: error: redefinition of ‘int s’
   59 | int n,s,w,c[151],m[151],p[21];
      |       ^
answer.code:4:7: note: ‘int s’ previously declared here
    4 | int n,s,w,c[151],m[151],p[21];
      |       ^
answer.code:59:9: error: redefinition of ‘int w’
   59 | int n,s,w,c[151],m[151],p[21];
      |         ^
answer.code:4:9: note: ‘int w’ previously declared here
    4 | int n,s,w,c[151],m[151],p[21];
      |         ^
answer.code:59:11: error: redefinition of ‘int c [151]’
   59 | int n,s,w,c[151],m[151],p[21];
      |           ^
answer.code:4:11: note: ‘int c [151]’ previously declared here
    4 | int n,s,w,c[151],m[151],p[21];
      |           ^
answer.code:59:18: error: redefinition of ‘int m [151]’
   59 | int n,s,w,c[151],m[151],p[21];
      |                  ^
answer.code:4:18: note: ‘int m [151]’ previously declared here
    4 | int n,s,w,c[151],m[151],p[21];
      |                  ^
answer.code:59:25: error: redefinition of ‘int p [21]’
   59 | int n,s,w,c[151],m[151],p[21];
      |                         ^
answer.code:4:25: note: ‘int p [21]’ previously declared here
    4 | int n,s,w,c[151],m[151],p[21];
      |                         ^
answer.code:60:4: error: redefinition of ‘ll f [151][151]’
   60 | ll f[151][151],fl[151][151][21],fr[151][151][21];
      |    ^
answer.code:5:4: note: ‘ll f [151][151]’ previously declared here
    5 | ll f[151][151],fl[151][151][21],fr[151][151][21];
      |    ^
answer.code:60:16: error: redefinition of ‘ll fl [151][151][21]’
   60 | ll f[151][151],fl[151][151][21],fr[151][151][21];
      |                ^~
answer.code:5:16: note: ‘ll fl [151][151][21]’ previously declared here
    5 | ll f[151][151],fl[151][151][21],fr[151][151][21];
      |                ^~
answer.code:60:33: error: redefinition of ‘ll fr [151][151][21]’
   60 | ll f[151][151],fl[151][151][21],fr[151][151][21];
      |                                 ^~
answer.code:5:33: note: ‘ll fr [151][151][21]’ previously declared here
    5 | ll f[151][151],fl[151][151][21],fr[151][151][21];
      |                                 ^~
answer.code:61:6: error: redefinition of ‘void upd(ll&, ll)’
   61 | void upd(ll &x,ll y){x=max(x,y);}
      |      ^~~
answer.code:6:6: note: ‘void upd(ll&, ll)’ previously defined here
    6 | void upd(ll &x,ll y){x=max(x,y);}
      |      ^~~
answer.code:62:5: error: redefinition of ‘int main()’
   62 | int main(){
      |     ^~~~
answer.code:7:5: note: ‘int main()’ previously defined here
    7 | int main(){
      |     ^~~~
answer.code: In function ‘int main()’:
answer.code:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d%d%d",&n,&s,&w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:10:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         for(int i=1;i<=n;i++) scanf("%d",&c[i]);
      |                               ~~~~~^~~~~~~~~~~~
answer.code:11:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         for(int i=1;i<=n;i++) scanf("%d",&m[i]);
      |                               ~~~~~^~~~~~~~~~~~
answer.code:12:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         for(int i=s;i<=2*s-2;i++) scanf("%d",&p[i]);
      |                                   ~~~~~^~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:64:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   64 |         scanf("%d%d%d",&n,&s,&w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:65:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |         for(int i=1;i<=n;i++) scanf("%d",&c[i]);
      |                               ~~~~~^~~~~~~~~~~~
answer.code:66:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   66 |         for(int i=1;i<=n;i++) scanf("%d",&m[i]);
      |                               ~~~~~^~~~~~~~~~~~
answer.code:67:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   67 |         for(int i=s;i<=2*s-2;i++) scanf("%d",&p[i]);
      |                                   ~~~~~^~~~~~~~~~~~