QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#463186 | #8780. Training, Round 2 | std_abs# | WA | 88ms | 102176kb | C++14 | 2.0kb | 2024-07-04 15:12:01 | 2024-07-04 15:12:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
const int mod = 998244353, N = 5005;
int n,x,y,l1[N],r1[N],l2[N],r2[N];
vector<int> ins_vec[N],del_vec[N];
int bit[N];
void add(int p, int x){
//cout << "add " << p << ' ' << x << endl;
for(++p; p<N; p+=p&-p) bit[p]+=x;
}
int query(int r){
int res=0;
for(++r; r; r-=r&-r) res+=bit[r];
return res;
}
int find_next(int p){ // >= p
int tar=query(p-1);
//cout << "find_next " << p << ' ' << tar << endl;
int cur=0,curval=0;
for(int i=12; i>=0; --i) if(cur+(1<<i)<N&&curval+bit[cur+(1<<i)]<=tar){
cur+=1<<i;
curval+=bit[cur];
}
return cur;
}
int dp[N][N];
bool good[N];
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> x >> y;
for(int i=0; i<n; ++i){
cin >> l1[i] >> r1[i] >> l2[i] >> r2[i];
l1[i]-=x,r1[i]-=x,l2[i]-=y,r2[i]-=y;
l1[i]=max(l1[i],0),l2[i]=max(l2[i],0);
r1[i]=min(r1[i],n-1),r2[i]=min(r2[i],n-1);
}
for(int i=0; i<n; ++i){
//cout << i << ' ' << l2[i] << ' ' << r2[i] << endl;
ins_vec[l2[i]].pb(i),del_vec[r2[i]+1].pb(i);
}
memset(dp,0x3f,sizeof dp);
dp[0][0]=0;
for(int i=0; i<n; ++i){
for(int j=0; j<n; ++j) good[j]=(l1[j]<=i&&i<=r1[j]);
for(int j=0; i+j<n; ++j){
for(int t: ins_vec[j]) if(good[t]) add(t,1);
for(int t: del_vec[j]) if(good[t]) add(t,-1);
if(dp[i][j]>=n) continue;
int x=find_next(dp[i][j])+1;
//cout << i << ' ' << j << ' ' << dp[i][j] << ' ' << x << endl;
if(x<=n){
dp[i+1][j]=min(dp[i+1][j],x);
dp[i][j+1]=min(dp[i][j+1],x);
}
}
}
int res=0;
for(int i=0; i<=n; ++i) for(int j=0; i+j<=n; ++j) if(dp[i][j]<=n) res=max(res,i+j);
cout << res << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 101808kb
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: 0
Accepted
time: 88ms
memory: 101960kb
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:
5000
result:
ok single line: '5000'
Test #3:
score: 0
Accepted
time: 87ms
memory: 101964kb
input:
5000 932138594 801577551 932138594 932138594 801577551 801577551 932138594 932138594 801577552 801577552 932138595 932138595 801577552 801577552 932138596 932138596 801577552 801577552 932138596 932138596 801577553 801577553 932138597 932138597 801577553 801577553 932138598 932138598 801577553 80157...
output:
5000
result:
ok single line: '5000'
Test #4:
score: 0
Accepted
time: 69ms
memory: 102176kb
input:
5000 76836128 716580777 76836128 76836128 716580777 716580777 76836129 76836129 716580777 716580777 76836130 76836130 716580777 716580777 76836131 76836131 716580777 716580777 76836131 76836131 716580778 716580778 76836131 76836131 716580779 716580779 76836131 76836131 716580780 716580780 76836128 7...
output:
4994
result:
ok single line: '4994'
Test #5:
score: 0
Accepted
time: 69ms
memory: 102004kb
input:
5000 716580777 76836128 716580777 716580777 76836128 76836128 716580777 716580777 76836129 76836129 716580777 716580777 76836130 76836130 716580777 716580777 76836131 76836131 716580778 716580778 76836131 76836131 716580779 716580779 76836131 76836131 716580780 716580780 76836131 76836131 716580778 ...
output:
4994
result:
ok single line: '4994'
Test #6:
score: -100
Wrong Answer
time: 71ms
memory: 101956kb
input:
5000 774827789 700294316 774827790 774827791 700294315 700294317 774827789 774827790 700294317 700294318 774827789 774827790 700294316 700294316 774827787 774827787 700294315 700294316 774827789 774827791 700294315 700294318 774827787 774827789 700294317 700294318 774827787 774827788 700294314 70029...
output:
166
result:
wrong answer 1st lines differ - expected: '5', found: '166'