QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490715 | #8780. Training, Round 2 | maojun | WA | 21ms | 5936kb | C++23 | 803b | 2024-07-25 16:12:56 | 2024-07-25 16:12:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
int n,a,b,la[N],ra[N],lb[N],rb[N];
typedef bitset<N> bs;
bs dp[2][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].set(0);
for(int i=1;i<=n;i++){
bool o=i&1;
if(la[i]>ra[i]||lb[i]>rb[i])continue;
for(int j=0;j<n;j++)dp[o][j]=dp[!o][j];
for(int j=la[i];j<=ra[i];j++){
bs tmp=dp[!o][j];
tmp>>=lb[i];
tmp<<=N-rb[i]+lb[i]-1;
tmp>>=N-rb[i]-1;
dp[o][j+1]|=tmp;dp[o][j]|=tmp<<1;
}
}
int res=0;
for(int j=0;j<n;j++)for(int k=0;k<n;k++)if(dp[n&1][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
Wrong Answer
time: 21ms
memory: 3944kb
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:
0
result:
wrong answer 1st lines differ - expected: '5000', found: '0'