QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491517 | #8780. Training, Round 2 | LYY_yyyy | WA | 21ms | 6432kb | C++14 | 1.9kb | 2024-07-25 20:04:30 | 2024-07-25 20:04:31 |
Judging History
answer
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
int n,a,b;
int l1[5010],r1[5010],l2[5010],r2[5010];
bool vis[5010][5010];
vector<pair<int,int> > add,del;
struct node
{
int l,r;
set<pair<int,int> > s;
}tr[20010];
inline void pushup(int u)
{
tr[u].s.clear();
for(auto o:tr[u<<1].s) tr[u].s.insert(o);
for(auto o:tr[u<<1|1].s) tr[u].s.insert(o);
}
void build(int u,int l,int r)
{
tr[u]={l,r};
if(tr[u].l==tr[u].r)
{
if(tr[u].l==0) tr[u].s.insert({0,0});
return;
}int mid=l+r>>1;
build(u<<1,l,mid);build(u<<1|1,mid+1,r);
pushup(u);
}
void modify_d(int u,int x,int y)
{
if(tr[u].l==tr[u].r) return tr[u].s.insert(make_pair(y,x)),void();
int mid=tr[u].l+tr[u].r>>1;
if(x<=mid) modify_d(u<<1,x,y);
else modify_d(u<<1|1,x,y);
pushup(u);
}
inline void ads(int x,int y)
{
if(vis[x][y]) return;
vis[x][y]=1;
add.pb(make_pair(x,y));
}
void modify(int u,int l,int r,int l1,int r1)
{
if(tr[u].l>=l&&tr[u].r<=r)
{
auto o=tr[u].s.lower_bound(make_pair(l1,0)),p=tr[u].s.lower_bound(make_pair(r1+1,0));
for(auto i=o;i!=p;i++) del.pb(*i);
for(auto o:del) tr[u].s.erase(o),ads(o.first+1,o.second),ads(o.first,o.second+1);
del.clear();
return;
}
int mid=tr[u].l+tr[u].r>>1;
if(l<=mid) modify(u<<1,l,r,l1,r1);
else modify(u<<1|1,l,r,l1,r1);
pushup(u);
}
void ad()
{
for(auto o:add) modify_d(1,o.first,o.second);
add.clear();
}
bool ck(int i)
{
if(l1[i]<0||l2[i]<0) return 1;
if(r1[i]>n||r2[i]>n) return 1;
return 0;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n>>a>>b;
for(int i=1;i<=n;i++) cin>>l1[i]>>r1[i]>>l2[i]>>r2[i],l1[i]-=a,r1[i]-=a,l2[i]-=b,r2[i]-=b;
build(1,0,n);
for(int i=1;i<=n;i++)
{
if(ck(i)) continue;
modify(1,l1[i],r1[i],l2[i],r2[i]);
ad();
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++) if(vis[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: 1ms
memory: 6432kb
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: 4880kb
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:
6
result:
wrong answer 1st lines differ - expected: '5000', found: '6'