QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601987 | #8780. Training, Round 2 | gtrhetr | TL | 0ms | 0kb | C++14 | 976b | 2024-09-30 17:22:19 | 2024-09-30 17:22:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
set<int> st[5010];
int n,x,y;
bool bo[5010][5010];
inline int rd()
{
int x=0;char ch=getchar();
for (;ch<'0'||ch>'9';ch=getchar());
for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
return x;
}
int main()
{
freopen("hh.in","r",stdin);
n=rd();x=rd();y=rd();
bo[0][0]=true;
st[0].insert(0);
for (int i=1;i<=n;i++)
{
int l1=rd(),r1=rd(),l2=rd(),r2=rd();
for (int j=i-1;j>=0;j--)
{
int l=max(l1-x,j-(r2-y)),r=min(r1-x,j-(l2-y));
if (l>r||r<0||l>=i) continue;
for (set<int>::iterator it=st[j].lower_bound(l);it!=st[j].end()&&*it<=r;st[j].erase(it++))
{
if (!bo[j+1][*it])
{
st[j+1].insert(*it);
bo[j+1][*it]=true;
}
if (!bo[j+1][*it+1])
{
st[j+1].insert(*it+1);
bo[j+1][*it+1]=true;
}
}
}
}
int ans=0;
for (int i=1;i<=n;i++) for (int j=0;j<=i;j++) if (bo[i][j]) ans=i;
printf("%d\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 0 0 0 1 0 1 1 1 0 1 1 1 1 1