QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#463190 | #8780. Training, Round 2 | std_abs# | WA | 303ms | 102164kb | C++14 | 2.1kb | 2024-07-04 15:18:02 | 2024-07-04 15:18: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;
if(l2[i]<=r2[i]) 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: 0ms
memory: 101724kb
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: 85ms
memory: 102036kb
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: 93ms
memory: 101960kb
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: 67ms
memory: 102164kb
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: 73ms
memory: 101864kb
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: 0
Accepted
time: 85ms
memory: 101864kb
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:
5
result:
ok single line: '5'
Test #7:
score: 0
Accepted
time: 70ms
memory: 101976kb
input:
5000 700294316 774827789 700294315 700294317 774827790 774827791 700294317 700294318 774827789 774827790 700294316 700294316 774827789 774827790 700294315 700294316 774827787 774827787 700294315 700294318 774827789 774827791 700294317 700294318 774827787 774827789 700294314 700294318 774827787 77482...
output:
5
result:
ok single line: '5'
Test #8:
score: 0
Accepted
time: 78ms
memory: 101944kb
input:
5000 256309650 340081224 256309647 256309649 340081224 340081227 256309645 256309650 340081226 340081229 256309652 256309652 340081219 340081220 256309645 256309655 340081222 340081226 256309646 256309648 340081221 340081225 256309651 256309654 340081219 340081221 256309651 256309653 340081219 34008...
output:
11
result:
ok single line: '11'
Test #9:
score: 0
Accepted
time: 65ms
memory: 101864kb
input:
5000 340081224 256309650 340081224 340081227 256309647 256309649 340081226 340081229 256309645 256309650 340081219 340081220 256309652 256309652 340081222 340081226 256309645 256309655 340081221 340081225 256309646 256309648 340081219 340081221 256309651 256309654 340081219 340081226 256309651 25630...
output:
11
result:
ok single line: '11'
Test #10:
score: 0
Accepted
time: 70ms
memory: 101944kb
input:
5000 490966735 218892297 490966732 490966733 218892303 218892305 490966741 490966741 218892298 218892301 490966733 490966735 218892291 218892297 490966729 490966734 218892296 218892301 490966742 490966745 218892287 218892303 490966726 490966738 218892301 218892305 490966726 490966730 218892292 21889...
output:
21
result:
ok single line: '21'
Test #11:
score: 0
Accepted
time: 67ms
memory: 101976kb
input:
5000 218892297 490966735 218892303 218892305 490966732 490966733 218892298 218892301 490966741 490966741 218892291 218892297 490966733 490966735 218892296 218892301 490966729 490966734 218892287 218892303 490966742 490966745 218892301 218892305 490966726 490966738 218892292 218892300 490966726 49096...
output:
21
result:
ok single line: '21'
Test #12:
score: 0
Accepted
time: 69ms
memory: 101924kb
input:
5000 619930859 159808007 619930853 619930854 159808007 159808017 619930840 619930856 159808013 159808025 619930848 619930864 159807995 159808009 619930844 619930847 159808008 159808022 619930848 619930856 159807995 159808001 619930850 619930852 159808020 159808022 619930853 619930871 159807992 15980...
output:
41
result:
ok single line: '41'
Test #13:
score: 0
Accepted
time: 71ms
memory: 101936kb
input:
5000 159808007 619930859 159808007 159808017 619930853 619930854 159808013 159808025 619930840 619930856 159807995 159808009 619930848 619930864 159808008 159808022 619930844 619930847 159807995 159808001 619930848 619930856 159808020 159808022 619930850 619930852 159807992 159808024 619930853 61993...
output:
41
result:
ok single line: '41'
Test #14:
score: 0
Accepted
time: 69ms
memory: 101940kb
input:
5000 974187020 583788009 974186973 974187017 583788001 583788028 974187035 974187052 583788011 583788027 974187016 974187037 583787973 583787981 974187036 974187046 583788012 583788028 974187046 974187066 583788042 583788056 974186994 974187016 583788013 583788044 974186986 974186989 583787969 58378...
output:
100
result:
ok single line: '100'
Test #15:
score: 0
Accepted
time: 73ms
memory: 101852kb
input:
5000 583788009 974187020 583788001 583788028 974186973 974187017 583788011 583788027 974187035 974187052 583787973 583787981 974187016 974187037 583788012 583788028 974187036 974187046 583788042 583788056 974187046 974187066 583788013 583788044 974186994 974187016 583787969 583787994 974186986 97418...
output:
100
result:
ok single line: '100'
Test #16:
score: 0
Accepted
time: 74ms
memory: 101972kb
input:
5000 684153868 455686026 684153781 684153927 455685991 455686049 684153899 684153921 455686036 455686037 684153784 684153959 455685984 455686049 684153967 684153968 455685927 455686014 684153795 684153963 455685926 455686026 684153787 684153846 455686084 455686105 684153817 684153870 455685928 45568...
output:
195
result:
ok single line: '195'
Test #17:
score: 0
Accepted
time: 74ms
memory: 101912kb
input:
5000 455686026 684153868 455685991 455686049 684153781 684153927 455686036 455686037 684153899 684153921 455685984 455686049 684153784 684153959 455685927 455686014 684153967 684153968 455685926 455686026 684153795 684153963 455686084 455686105 684153787 684153846 455685928 455686002 684153817 68415...
output:
195
result:
ok single line: '195'
Test #18:
score: 0
Accepted
time: 78ms
memory: 101940kb
input:
5000 999613320 323981653 999613235 999613461 323981523 323981741 999613292 999613510 323981543 323981775 999613390 999613409 323981669 323981831 999613416 999613497 323981638 323981846 999613234 999613269 323981627 323981669 999613414 999613489 323981453 323981526 999613174 999613358 323981489 32398...
output:
366
result:
ok single line: '366'
Test #19:
score: 0
Accepted
time: 84ms
memory: 101936kb
input:
5000 323981653 999613320 323981523 323981741 999613235 999613461 323981543 323981775 999613292 999613510 323981669 323981831 999613390 999613409 323981638 323981846 999613416 999613497 323981627 323981669 999613234 999613269 323981453 323981526 999613414 999613489 323981489 323981828 999613174 99961...
output:
366
result:
ok single line: '366'
Test #20:
score: 0
Accepted
time: 107ms
memory: 101924kb
input:
5000 555184387 498929492 555184771 555184789 498929431 498929765 555184225 555184302 498929308 498929410 555184166 555184206 498929155 498929424 555183905 555184344 498929667 498929688 555184514 555184517 498929218 498929639 555184130 555184438 498929083 498929692 555184520 555184681 498929153 49892...
output:
756
result:
ok single line: '756'
Test #21:
score: 0
Accepted
time: 102ms
memory: 102000kb
input:
5000 498929492 555184387 498929431 498929765 555184771 555184789 498929308 498929410 555184225 555184302 498929155 498929424 555184166 555184206 498929667 498929688 555183905 555184344 498929218 498929639 555184514 555184517 498929083 498929692 555184130 555184438 498929153 498929492 555184520 55518...
output:
756
result:
ok single line: '756'
Test #22:
score: 0
Accepted
time: 141ms
memory: 101876kb
input:
5000 327086314 361426926 327086391 327086498 361426795 361426862 327087242 327087265 361426028 361426757 327085406 327085747 361427142 361427629 327085932 327086728 361426413 361426860 327086865 327087286 361426227 361427022 327086349 327086614 361426292 361427428 327086146 327086917 361426972 36142...
output:
1085
result:
ok single line: '1085'
Test #23:
score: 0
Accepted
time: 157ms
memory: 101936kb
input:
5000 361426926 327086314 361426795 361426862 327086391 327086498 361426028 361426757 327087242 327087265 361427142 361427629 327085406 327085747 361426413 361426860 327085932 327086728 361426227 361427022 327086865 327087286 361426292 361427428 327086349 327086614 361426972 361427709 327086146 32708...
output:
1085
result:
ok single line: '1085'
Test #24:
score: 0
Accepted
time: 210ms
memory: 101904kb
input:
5000 560545009 364655365 560544094 560544468 364654564 364655453 560544678 560544990 364655025 364657166 560543214 560546293 364653406 364653543 560543357 560543693 364655127 364656160 560545488 560546995 364657009 364657335 560543926 560546723 364654376 364656787 560545999 560546522 364654686 36465...
output:
1209
result:
ok single line: '1209'
Test #25:
score: 0
Accepted
time: 213ms
memory: 101960kb
input:
5000 364655365 560545009 364654564 364655453 560544094 560544468 364655025 364657166 560544678 560544990 364653406 364653543 560543214 560546293 364655127 364656160 560543357 560543693 364657009 364657335 560545488 560546995 364654376 364656787 560543926 560546723 364654686 364656158 560545999 56054...
output:
1209
result:
ok single line: '1209'
Test #26:
score: -100
Wrong Answer
time: 303ms
memory: 102052kb
input:
5000 812313462 162480149 812311271 812316617 162475502 162476097 812314180 812316398 162475976 162477137 812311826 812311880 162475344 162484969 812315907 812317031 162481854 162484730 812309714 812310689 162479161 162482743 812313057 812316810 162484347 162484637 812313889 812314992 162478489 16248...
output:
1430
result:
wrong answer 1st lines differ - expected: '1313', found: '1430'