QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#490680#8780. Training, Round 2maojunRE 1ms5936kbC++23763b2024-07-25 16:05:142024-07-25 16:05:14

Judging History

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

  • [2024-07-25 16:05:14]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5936kb
  • [2024-07-25 16:05:14]
  • 提交

answer

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

const int N=505;
int n,a,b,la[N],ra[N],lb[N],rb[N];

bool dp[N][N][N];
int main(){
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d%d",&la[i],&ra[i],&lb[i],&rb[i]);
		la[i]=max(0,la[i]-a);
		ra[i]=min(n-1,ra[i]-a);
		lb[i]=max(0,lb[i]-b);
		rb[i]=min(n-1,lb[i]-b);
	}
	dp[0][0][0]=1;
	for(int i=0;i<n;i++)if(la[i+1]<=ra[i+1]&&lb[i+1]<=rb[i+1])
		for(int j=0;j<n;j++)for(int k=0;k<n;k++){
			dp[i+1][j][k]|=dp[i][j][k];
			if(la[i+1]<=j&&j<=ra[i+1]&&lb[i+1]<=k&&k<=rb[i+1]){
				dp[i+1][j+1][k]|=dp[i][j][k];
				dp[i+1][j][k+1]|=dp[i][j][k];
			}
		}
	int res=0;
	for(int j=0;j<n;j++)for(int k=0;k<n;k++)if(dp[n][j][k])res=max(res,j+k);
	printf("%d\n",res);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5936kb

input:

3 0 0
0 1 0 1
1 1 0 1
1 1 1 1

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Runtime Error

input:

5000 801577551 932138594
801577551 801577551 932138594 932138594
801577552 801577552 932138594 932138594
801577552 801577552 932138595 932138595
801577552 801577552 932138596 932138596
801577553 801577553 932138596 932138596
801577553 801577553 932138597 932138597
801577553 801577553 932138598 93213...

output:


result: