QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#490858 | #8780. Training, Round 2 | yqh2025 | WA | 17ms | 3992kb | C++14 | 1.2kb | 2024-07-25 16:35:37 | 2024-07-25 16:35:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=5010;
int n,a,b;
int la[N],ra[N],lb[N],rb[N];
int f[N][N];
set<int>s[N];
void solve(int l,int r,int id){
set<int>::iterator it=s[id].lower_bound(l);
vector<int>ve;
for(;it!=s[id].end()&&(*it)<=r;it++){
int x=*it;ve.push_back(x+1);
f[id][x+1]=f[id+1][x]=1;
s[id+1].insert(x);
}
while(1){
it=s[id].lower_bound(l);
if(it==s[id].end())break;
if((*it)>r)break;
s[id].erase(*it);
}
for(int x:ve)s[id].insert(x);
}
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]-=a,ra[i]-=a,lb[i]-=b,rb[i]-=b;
la[i]=max(la[i],0),ra[i]=max(ra[i],0);
lb[i]=max(lb[i],0),rb[i]=max(rb[i],0);
la[i]=min(la[i],n),ra[i]=min(ra[i],n);
lb[i]=min(lb[i],n),rb[i]=min(rb[i],n);
}
f[0][0]=1;s[0].insert(0);
for(int t=1;t<=n;t++){
for(int i=la[i];i<=ra[i];i++){
solve(lb[i],rb[i],i);
}
// for(int i=0;i<=n;i++){
// for(int j=0;j<=n;j++){
// cout<<f[i][j]<<" ";
// }
// cout<<endl;
// }
// cout<<endl;
}
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);
}
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3864kb
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: 17ms
memory: 3992kb
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:
1
result:
wrong answer 1st lines differ - expected: '5000', found: '1'