QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#462417#8780. Training, Round 2ucup-team3519#WA 119ms199220kbC++201.3kb2024-07-03 19:01:312024-07-03 19:01:32

Judging History

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

  • [2024-07-03 19:01:32]
  • 评测
  • 测评结果:WA
  • 用时:119ms
  • 内存:199220kb
  • [2024-07-03 19:01:31]
  • 提交

answer

#pragma GCC optimize(3,"Ofast","inline")
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>
using namespace std;
#define ll long long
const int N=5005;
const ll mod=998244353;
ll qpow(ll a,ll b){
	ll ans=1;
	if(b==0)
	return 1;
	if(b%2)
	ans=a;
	ll t=qpow(a,b/2);
	return t*t%mod*ans%mod;
}
ll inv(ll a){
	return qpow(a,mod-2);
}
int dp[N][N];
int dq[N][N];
struct pt{
	int l1;
	int r1;
	int l2;
	int r2;
};
pt a[N];
void ins(int i,int x,int y){
	dp[i][x]=max(dp[i][x],y);
	dq[i][y]=max(dq[i][y],x);
}
void solve(){
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x,y,z,h;
		cin>>x>>y>>z>>h;
		a[i]={x,y,z,h};
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp[i][j]=dq[i][j]=-n-1;
		}
	}
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			int x=j,y=dp[i-1][j];
			if(x>=a[i].l1&&x<=a[i].r1&&y>=a[i].l2&&y<=a[i].r2){
				ins(i,x+1,y);
				ins(i,x,y+1);
			}
			ins(i,x,y);
		}
		for(int j=0;j<=n;j++){
			int y=j,x=dq[i-1][j];
			if(x>=a[i].l1&&x<=a[i].r1&&y>=a[i].l2&&y<=a[i].r2){
				ins(i,x+1,y);
				ins(i,x,y+1);	
			}
			ins(i,x,y);
		}
	}
	int ans=0;
	for(int j=0;j<=n;j++){
		ans=max(ans,dp[n][j]+j);
		ans=max(ans,dq[n][j]+j);
	}
	cout<<ans<<'\n';
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 

	solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

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
Wrong Answer
time: 119ms
memory: 199220kb

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:

5004

result:

wrong answer 1st lines differ - expected: '5000', found: '5004'