QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#491436 | #8780. Training, Round 2 | c20150005 | TL | 198ms | 23932kb | C++14 | 933b | 2024-07-25 19:29:15 | 2024-07-25 19:29:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;using ll=long long;
int rd(int x=0,char c=getchar()){int f=1;while(!isdigit(c))f=(c^'-'?1:-1),c=getchar();while(isdigit(c))x=x*10+(c^48),c=getchar();return x*f;}
const int N=5005;
int n,a,b;
int l1[N],r1[N],l2[N],r2[N];
bool f[N][N];
void output(){
for(int i=0;i<N;puts(""),i++)for(int j=0;j<N;j++)cout<<f[i][j];
puts("");
}
int main(){
n=rd(),a=rd(),b=rd();
for(int i=1;i<=n;i++)l1[i]=rd()-a,r1[i]=rd()-a,l2[i]=rd()-b,r2[i]=rd()-b;
f[0][0]=1;
for(int i=1;i<=n;i++)for(int x=N-1;~x;x--)for(int y=N-1;~y;y--){
if(x)if(x-1>=l1[i]&&x-1<=r1[i])f[x][y]|=f[x-1][y];
if(y)if(y-1>=l2[i]&&y-1<=r2[i])f[x][y]|=f[x][y-1];
if(y)if(x>=l1[i]&&x<=r1[i])f[x][y]|=f[x][y-1];
if(x)if(y>=l2[i]&&y<=r2[i])f[x][y]|=f[x-1][y];
}
// for(int i=1;i<=n;i++)
int ans=0;
for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(f[i][j])ans=max(ans,i+j);
printf("%d",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 198ms
memory: 23932kb
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
Time Limit Exceeded
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...