QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#746678 | #8646. Card Collection | 275307894a | 0 | 3ms | 28552kb | C++14 | 3.2kb | 2024-11-14 15:15:31 | 2024-11-14 15:15:32 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2e5+5,M=N*4+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,m,A[N],B[N],X[N],Y[N];
int flag[N];
struct ST{
int mx[20][N],mi[20][N];
void init(int *A){
copy(A+1,A+n+1,mx[0]+1);copy(A+1,A+n+1,mi[0]+1);
for(int i=1;(1<<i)<=n;i++){
for(int j=1;j+(1<<i)-1<=n;j++){
mx[i][j]=max(mx[i-1][j],mx[i-1][j+(1<<i-1)]);
mi[i][j]=min(mi[i-1][j],mi[i-1][j+(1<<i-1)]);
}
}
}
int qrymin(int x,int y){
int d=__lg(y-x+1);return min(mi[d][x],mi[d][y-(1<<d)+1]);
}
int qrymax(int x,int y){
int d=__lg(y-x+1);return max(mx[d][x],mx[d][y-(1<<d)+1]);
}
}a,b;
bool qry(int vx,int vy){
auto check3=[&](int x,int y){
if(x>y) return true;
return (a.qrymax(x,y)>=vx||b.qrymin(x,y)<=vy)&&(a.qrymin(x,y)<=vx||b.qrymax(x,y)>=vy);
};
for(int i=1;i<=n;i++) if(A[i]==vx&&B[i]==vy&&check3(1,i-1)&&check3(i+1,n)) return true;
auto check1=[&](int x,int y){
if(x>y) return true;
return !(a.qrymax(x,y)<=vx&&b.qrymin(x,y)>vy);
};
int i1=n+2;for(int i=1;i<=n;i++) if(A[i]==vx){i1=i;break;}
int d1=n+2,lim1;
for(int i=1;i<=n;i++) if(A[i]>=vx&&B[i]<=vy&&check1(1,i-1)){d1=i;break;}
lim1=max(i1,d1+1);while(lim1<=n&&!check1(d1+1,lim1)) lim1++;
auto check2=[&](int x,int y){
if(x>y) return true;
return !(a.qrymin(x,y)>vx&&b.qrymax(x,y)<=vy);
};
int i2=-1;for(int i=n;i;i--) if(B[i]==vy){i2=i;break;}
int d2=-1,lim2;
for(int i=n;i;i--) if(A[i]<=vx&&B[i]>=vy&&check2(i+1,n)){d2=i;break;}
lim2=min(i2,d2-1);while(lim2>0&&!check2(lim2,d2-1)) lim2--;
gdb(d1,d2,lim1,lim2);
if(d1>=i1&&d2<=i2&&d1+1==d2) return true;
if(d1>=i1&&d1+1<=lim2) return true;
if(d2<=i2&&d2-1>=lim1) return true;
return lim1+1<=lim2;
}
void build(){
a.init(A);b.init(B);
for(int i=1;i<=m;i++) flag[i]|=qry(X[i],Y[i]);
}
void Solve(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d%d",&A[i],&B[i]);
for(int i=1;i<=m;i++) scanf("%d%d",&X[i],&Y[i]);
build();
reverse(A+1,A+n+1);reverse(B+1,B+n+1);
build();
for(int i=1;i<=n;i++) A[i]*=-1,B[i]*=-1;
for(int i=1;i<=m;i++) X[i]*=-1,Y[i]*=-1;
build();
reverse(A+1,A+n+1);reverse(B+1,B+n+1);
build();
for(int i=1;i<=m;i++) if(flag[i]) printf("%d ",i);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 11
Accepted
time: 0ms
memory: 18364kb
input:
2 10 171631799 561094698 171631799 867698918 126573648 561094698 171631799 867698918 171631799 561094698 126573648 561094698 126573648 561094698 171631799 561094698 126573648 561094698 126573648 561094698 126573648 561094698 171631799 561094698
output:
2 3 6 10
result:
ok 4 number(s): "2 3 6 10"
Test #2:
score: 11
Accepted
time: 0ms
memory: 18364kb
input:
3 10 713180371 43103927 713180371 136832929 853543805 251852293 892623928 251852293 713180371 136832929 713180371 43103927 853543805 43103927 892623928 136832929 713180371 43103927 853543805 43103927 892623928 136832929 713180371 43103927 892623928 251852293
output:
2 3 6 9
result:
ok 4 number(s): "2 3 6 9"
Test #3:
score: 11
Accepted
time: 3ms
memory: 20404kb
input:
4 10 254412080 855555783 254412080 534954259 610506813 184822793 804271098 233942602 804271098 233942602 536633825 184822793 254412080 855555783 804271098 233942602 536633825 233942602 254412080 855555783 804271098 534954259 610506813 534954259 536633825 184822793 536633825 855555783
output:
1 3 4 6 7 8
result:
ok 6 numbers
Test #4:
score: 11
Accepted
time: 0ms
memory: 20408kb
input:
5 10 148547041 170447714 617759855 170447714 617759855 963162312 148547041 948767426 423489361 460053818 423489361 460053818 817714720 948767426 617759855 673099807 617759855 963162312 617759855 673099807 423489361 460053818 423489361 460053818 817714720 948767426 817714720 170447714 148547041 67309...
output:
1 4 6 7
result:
ok 4 number(s): "1 4 6 7"
Test #5:
score: 11
Accepted
time: 0ms
memory: 18420kb
input:
6 10 452189481 369706489 974106249 369706489 152471743 55874110 152471743 7767562 623180600 783682263 116778263 783682263 974106249 369706489 452189481 7767562 623180600 7767562 116778263 783682263 330861484 7767562 452189481 640079581 974106249 640079581 623180600 783682263 974106249 7767562 116778...
output:
1 4 8
result:
ok 3 number(s): "1 4 8"
Test #6:
score: 11
Accepted
time: 0ms
memory: 18320kb
input:
7 10 546365360 29458595 459505526 682968936 892069847 113227141 892069847 682968936 459505526 895773339 436538726 29458595 892069847 29458595 892069847 21442381 200908509 682968936 84249914 782064261 691849455 682968936 691849455 682968936 691849455 21442381 691849455 682968936 691849455 21442381 84...
output:
result:
ok 0 number(s): ""
Test #7:
score: 11
Accepted
time: 3ms
memory: 24520kb
input:
8 10 53884460 816621582 931458006 534340303 53884460 621933704 317941616 487589985 53884460 793793344 831491668 487589985 53884460 816621582 53884460 417129074 831491668 417129074 317941616 534340303 395845824 793793344 395845824 417129074 317941616 166559933 100528187 487589985 83144683 816621582 8...
output:
2 10
result:
ok 2 number(s): "2 10"
Test #8:
score: 11
Accepted
time: 0ms
memory: 24528kb
input:
9 10 703128946 628411749 703128946 876135124 678057110 783023566 563107567 908344997 255577987 177945114 703128946 177945114 519769912 951772210 678057110 470396423 703128946 470396423 563107567 783023566 813952930 470396423 230207898 177945114 230207898 628411749 519769912 555485281 703128946 78302...
output:
1 6
result:
ok 2 number(s): "1 6"
Test #9:
score: 11
Accepted
time: 0ms
memory: 24468kb
input:
10 10 411828800 587312736 368564282 297078085 368564282 265187364 287645241 405039514 368564282 535066135 368564282 265187364 701629305 581674146 894581821 581674146 600278299 347261251 368564282 390901645 633230417 151902557 287645241 297078085 1782717 405039514 287645241 587312736 894581821 587312...
output:
2 5 7
result:
ok 3 number(s): "2 5 7"
Test #10:
score: 11
Accepted
time: 0ms
memory: 24508kb
input:
11 10 594865443 637250974 223004376 637250974 785025296 887146590 120666718 887146590 31665956 652873089 594865443 887146590 1682073 112213166 31665956 121276446 785025296 121276446 28305142 652873089 28305142 661968377 1682073 120498688 938018458 887146590 120666718 112213166 28305142 112213166 223...
output:
10
result:
ok 1 number(s): "10"
Test #11:
score: 11
Accepted
time: 0ms
memory: 22472kb
input:
12 10 39186066 168002748 671722214 32295292 39186066 469855569 442075770 469855569 689698028 968471023 3489285 168002748 671722214 968471023 182809077 689539890 481317320 742954502 265274602 32295292 265274602 26013512 481317320 742954502 976556207 168425358 689698028 32295292 749415058 545907259 24...
output:
10
result:
ok 1 number(s): "10"
Test #12:
score: 11
Accepted
time: 0ms
memory: 22476kb
input:
13 10 527355089 377970728 552459003 455747923 709625462 510634723 552459003 377970728 731571039 951161417 232811148 951161417 552459003 658700181 232811148 377970728 518940837 455747923 455586174 378372201 219157258 378372201 219157258 377970728 709625462 385691279 455586174 510634723 915002219 1039...
output:
1 4 7 8 10
result:
ok 5 number(s): "1 4 7 8 10"
Test #13:
score: 11
Accepted
time: 0ms
memory: 24504kb
input:
14 10 118092342 284486250 927338949 433938384 402661724 978896809 647730583 672355271 31848729 951232518 735207774 379785691 647730583 976797409 118092342 976797409 16895438 951232518 266079358 317991591 402661724 759687663 927338949 672355271 384578818 379785691 927338949 675446949 647730583 672355...
output:
1 2 9
result:
ok 3 number(s): "1 2 9"
Test #14:
score: 11
Accepted
time: 0ms
memory: 26556kb
input:
15 10 180664786 545082798 348151122 545082798 945365791 568927334 87112728 22695274 969050024 993697033 76897725 568927334 946081941 721317554 736012091 124380018 76897725 993697033 969050024 297352406 87112728 22695274 477303819 152140956 497190005 127179215 477303819 957952273 946081941 297352406 ...
output:
2 3
result:
ok 2 number(s): "2 3"
Test #15:
score: 11
Accepted
time: 0ms
memory: 26576kb
input:
16 10 950185079 359470460 717527338 766264034 950185079 464367361 702133494 562464640 47221737 933850433 804214161 68526353 835127535 923127189 663871966 429877028 663871966 933850433 663871966 860592052 717527338 159513156 817202184 970491880 835127535 475614319 519002985 475614319 109565532 137441...
output:
5 9
result:
ok 2 number(s): "5 9"
Test #16:
score: 11
Accepted
time: 0ms
memory: 28552kb
input:
17 10 785164241 654900960 360828785 824839755 439791874 641288092 577364156 862808499 668131950 862808499 893897612 712643610 893897612 596494049 736363695 306279255 668131950 262689126 141356696 306279255 141356696 559915287 785164241 712643610 785164241 862808499 785164241 91314622 657093012 89959...
output:
1 2 4 7 8
result:
ok 5 number(s): "1 2 4 7 8"
Test #17:
score: 0
Wrong Answer
time: 0ms
memory: 26560kb
input:
18 10 634436200 539568435 939344787 325688918 488541626 821095697 430879210 182007328 634436200 676635380 863100947 105320937 634436200 259039153 155697449 650750783 863100947 290661066 904360323 275647130 148773803 836392810 155697449 275647130 904360323 325688918 242889289 395936619 863100947 8363...
output:
4 8 10
result:
wrong answer 2nd numbers differ - expected: '5', found: '8'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%