QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#724934#1650. AND = ORwosileAC ✓218ms63264kbC++142.1kb2024-11-08 15:36:172024-11-08 15:36:18

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 15:36:18]
  • 评测
  • 测评结果:AC
  • 用时:218ms
  • 内存:63264kb
  • [2024-11-08 15:36:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 100005
const int M=(1<<30)-1;
int a[N],b[N],n,Q;
pair<int,int> dc[N];
struct query{
    int l,r;
    pair<int,int>d[33];
}q[N];
int mn[20][N],mx[20][N],st0[20][N],st1[20][N];
inline int calc(int x,int y){return b[x]>b[y]?x:y;}
inline int gmx(int l,int r){
    if(l>r)return 0;
    int d=__lg(r-l+1);
    return b[calc(mx[d][l],mx[d][r-(1<<d)+1])];
}
int main(){
    scanf("%d%d",&n,&Q);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),dc[i]={a[i],i};
    sort(dc+1,dc+n+1);
    for(int i=1;i<=n;i++)b[i]=lower_bound(dc+1,dc+n+1,make_pair(a[i],i))-dc;
    for(int i=1;i<=n;i++)mn[0][i]=b[i],mx[0][i]=i;
    for(int j=1;j<19;j++)for(int i=1;i+(1<<j)-1<=n;i++)mn[j][i]=min(mn[j-1][i],mn[j-1][i+(1<<j-1)]),mx[j][i]=calc(mx[j-1][i],mx[j-1][i+(1<<j-1)]);
    for(int i=1;i<=Q;i++)scanf("%d%d",&q[i].l,&q[i].r);
    for(int d=0;d<31;d++){
        for(int i=1;i<=n;i++){
            if((1<<d)&a[i])st0[0][i]=0,st1[0][i]=b[i];
            else st0[0][i]=b[i],st1[0][i]=n+1;
        }
        for(int j=1;j<19;j++)for(int i=1;i+(1<<j)-1<=n;i++)st0[j][i]=max(st0[j-1][i],st0[j-1][i+(1<<j-1)]),st1[j][i]=min(st1[j-1][i],st1[j-1][i+(1<<j-1)]);
        for(int i=1;i<=Q;i++){
            int g=__lg(q[i].r-q[i].l+1);
            int f0=max(st0[g][q[i].l],st0[g][q[i].r-(1<<g)+1]);
            int f1=min(st1[g][q[i].l],st1[g][q[i].r-(1<<g)+1]);
            if(f0<1 || f1>n)q[i].d[d]={n+1,-1};
            else if(f0<f1)q[i].d[d]={f0,f1-1};
            else q[i].d[d]={f1,f0-1};
        }
    }
    for(int i=1;i<=Q;i++){
        if(q[i].l==q[i].r){
            printf("NO\n");
            continue;
        }
        sort(q[i].d,q[i].d+31);
        int g=__lg(q[i].r-q[i].l+1);
        int pos=calc(mx[g][q[i].l],mx[g][q[i].r-(1<<g)+1]);
        int R=min(mn[g][q[i].l],mn[g][q[i].r-(1<<g)+1])-1,lim=max(gmx(q[i].l,pos-1),gmx(pos+1,q[i].r));
        int ans=0;
        for(int j=0;j<31;j++){
            if(q[i].d[j].first>R+1)ans=1;
            R=max(R,q[i].d[j].second);
            if(R>=lim)break;
        }
        if(ans)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 41088kb

input:

5 15
0 1 1 3 2
1 1
1 2
1 3
1 4
1 5
2 2
2 3
2 4
2 5
3 3
3 4
3 5
4 4
4 5
5 5

output:

NO
NO
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO

result:

ok 15 lines

Test #2:

score: 0
Accepted
time: 60ms
memory: 53072kb

input:

1000 100000
10 21 13 3 27 17 13 5 2 11 19 12 5 30 30 30 26 29 30 23 13 10 26 5 30 31 11 10 0 9 31 30 28 7 23 11 12 15 9 15 0 10 30 29 28 20 21 28 24 29 31 6 31 10 1 11 17 20 21 12 1 7 9 0 23 5 30 18 14 1 10 0 23 5 23 30 21 12 1 17 31 8 28 21 2 29 12 24 28 4 12 28 2 9 8 25 27 14 2 24 2 6 16 25 7 26 2...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YE...

result:

ok 100000 lines

Test #3:

score: 0
Accepted
time: 183ms
memory: 63264kb

input:

99998 100000
64809358 457746235 626174899 497070574 118813143 700158742 390718358 455314343 568823698 264482194 328382807 327470966 163435843 630298535 560134023 453679015 659618722 699071266 487584642 296201642 868276574 195606863 87661911 152553323 258902299 897903510 789115811 220046142 391177127...

output:

YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO...

result:

ok 100000 lines

Test #4:

score: 0
Accepted
time: 171ms
memory: 63220kb

input:

99998 100000
200753929 508909324 82966150 231982361 64431879 785609264 1030955275 223851794 947241526 777212470 97756073 466986152 393446940 376828934 376915222 467088160 485965987 276150058 695588226 854976016 122938650 533816962 99702323 426989208 357807672 450315050 502367905 735420710 904992026 ...

output:

YES
NO
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
YES
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
NO
YES
YES
YES
NO
...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 145ms
memory: 63220kb

input:

100000 100000
2 1 2 2 0 1 3 3 1 3 3 1 0 1 1 1 3 3 0 2 3 0 0 3 2 0 2 1 0 0 0 2 3 1 2 0 2 1 2 2 2 1 0 2 0 2 3 2 0 3 2 3 1 1 0 1 3 3 1 1 0 2 3 1 0 2 2 0 1 3 0 3 3 2 2 1 0 1 0 0 1 2 1 2 0 0 1 1 0 1 1 0 1 2 3 3 1 2 3 2 3 0 3 3 0 0 0 3 1 2 2 1 2 3 0 0 3 2 2 0 1 0 1 0 1 1 3 3 2 0 0 3 2 3 2 1 1 1 2 3 2 2 0 ...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 100000 lines

Test #6:

score: 0
Accepted
time: 202ms
memory: 63200kb

input:

100000 100000
1 4 11 9 4 0 8 6 8 12 1 3 14 6 10 13 9 0 8 9 2 14 4 13 4 9 15 5 1 15 8 15 11 0 8 15 12 2 7 12 14 15 3 1 4 2 0 13 0 14 3 3 10 6 6 11 15 6 8 15 0 9 10 15 15 0 2 14 5 2 12 2 15 6 4 8 12 10 13 13 1 0 13 6 5 12 14 9 5 7 15 2 1 15 1 15 13 4 11 4 1 13 7 8 10 1 2 6 7 15 0 13 12 6 5 1 2 13 13 8...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
...

result:

ok 100000 lines

Test #7:

score: 0
Accepted
time: 199ms
memory: 63204kb

input:

100000 100000
523548949 1065731088 862996787 699475930 1067945213 274074347 966699391 784570868 986927558 336085567 496156322 639760659 68214444 65082716 141820554 401383307 976783729 752958395 830755307 913445397 205124314 268786036 119013564 213674059 120644399 695300038 30146231 758334767 9820709...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 100000 lines

Test #8:

score: 0
Accepted
time: 66ms
memory: 44812kb

input:

36 99996
1073741822 1073725438 459639348 460687924 528452350 528452286 1073741823 33816576 187007524 460687932 187007492 191201844 191201828 527927998 52789764 52756480 460819004 528452286 52789252 460819006 1065336830 52789248 262144 528465918 191203892 0 528456702 528452350 1065336830 35913728 460...

output:

NO
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO...

result:

ok 99996 lines

Test #9:

score: 0
Accepted
time: 78ms
memory: 46784kb

input:

37 99997
1073741823 1052764643 445964384 134479872 135553024 982835296 135544832 982900962 982835424 1052768739 1069547519 143974400 1052769791 985129443 982835296 1052768755 1052769783 262144 1052769779 135528448 982835426 143974400 982901219 412409920 984998371 1069547007 985653731 0 982900963 445...

output:

YES
YES
NO
NO
NO
YES
YES
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
N...

result:

ok 99997 lines

Test #10:

score: 0
Accepted
time: 72ms
memory: 40692kb

input:

10 100000
221368858 757110364 355524368 924862003 563136062 1068883839 238112041 740347235 1068883839 931250230
4 9
4 10
5 10
7 10
1 3
2 7
9 10
4 7
8 8
5 8
4 7
1 10
3 4
8 10
9 10
2 8
2 8
9 10
1 5
2 6
2 9
1 10
1 6
7 8
6 10
2 7
2 8
1 10
1 10
1 2
1 3
1 8
6 6
1 3
2 7
1 4
1 9
8 10
6 8
5 10
7 9
5 8
5 7
3 ...

output:

YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
YE...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 70ms
memory: 48896kb

input:

100 100000
979174147 411851047 246487571 1073601343 926715922 1033371927 480332563 809851698 398004273 650723607 153475591 529271092 493720096 305990450 508152337 200085808 899436818 548165927 98833191 455448835 652019988 546134791 416125236 325865525 331730982 736673799 122996999 893964835 75892557...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

ok 100000 lines

Test #12:

score: 0
Accepted
time: 79ms
memory: 53076kb

input:

1000 100000
969456424 928293203 768889638 762135318 283494173 321072508 234108675 224849312 381754742 907972481 348207051 812451135 847344541 246115204 603382082 163961133 888734611 881583442 71012798 217461146 341812614 188806431 188805551 42499998 437138389 844224993 867785000 839444333 306091876 ...

output:

NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
YES
YES
YES
NO
NO
NO
NO
YES
YE...

result:

ok 100000 lines

Test #13:

score: 0
Accepted
time: 99ms
memory: 59308kb

input:

10000 100000
137741019 97272733 555141918 865045002 1013631170 12026655 443973837 655901595 717914718 233259460 30902663 113593177 439403481 804291085 447416654 982647391 462324299 875744200 350424024 242582285 200215169 1037713478 503824856 564118168 929187917 709708234 620118677 989726984 18748296...

output:

YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
YES
...

result:

ok 100000 lines

Test #14:

score: 0
Accepted
time: 82ms
memory: 61584kb

input:

20000 100000
441177685 969756257 512645786 441507555 405438251 431517388 416763596 464178882 1031953362 522711648 449538725 505135917 1018123017 1058336268 451039118 999940629 1049975600 515985198 505276978 993841809 1063903754 459071056 1050333793 455696225 970484251 977884078 1050266385 1049479984...

output:

NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
N...

result:

ok 100000 lines

Test #15:

score: 0
Accepted
time: 173ms
memory: 63204kb

input:

99999 99999
709569395 895036495 996207717 1009859523 1019799676 614414547 832679397 901855962 997750888 615430853 975764069 927688805 887172984 750430952 1048885612 724990408 907377735 544680798 923725128 907722564 821636940 669166418 773734240 687041637 711113338 791881835 978599625 852242168 83409...

output:

NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES...

result:

ok 99999 lines

Test #16:

score: 0
Accepted
time: 190ms
memory: 63212kb

input:

99999 100000
150621003 629333203 90372521 90975736 880331866 10208243 811299064 811033521 546963144 760654177 312371890 358768403 435349808 757227345 22900434 927494769 440249105 966175018 487809707 1062259747 1058825032 188144232 1012425075 901856395 392645651 892287018 131687513 985877050 97269491...

output:

NO
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
YES
YES
NO
NO
NO
YES
YES
NO
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
NO
...

result:

ok 100000 lines

Test #17:

score: 0
Accepted
time: 214ms
memory: 63204kb

input:

100000 100000
414548150 260229283 483592753 311814674 383582896 390736530 155050499 404548134 56740502 240074805 106644007 190196246 338750099 481732641 189663287 165022355 130402325 141150869 178415798 164880518 153938566 246908931 296085649 103703079 381084176 508226050 434653347 266830340 3209810...

output:

NO
YES
NO
YES
NO
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
NO...

result:

ok 100000 lines

Test #18:

score: 0
Accepted
time: 68ms
memory: 44784kb

input:

35 99998
294420482 1035993014 1040187327 968732422 1035861942 430744834 431795974 431795462 294429954 296527106 262144 293863424 968748966 294387712 294387712 1073741823 294387714 294428930 285474816 0 1035993015 968748982 1035993023 431795458 1040187391 431795458 431795458 968748806 968753078 17039...

output:

NO
YES
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
...

result:

ok 99998 lines

Test #19:

score: 0
Accepted
time: 71ms
memory: 46840kb

input:

37 99999
545521664 681836672 686657665 686653569 681836544 1073725415 771735527 771735527 753777639 753777347 805289959 1073741823 686665921 0 1073741807 753777639 753774785 686063744 1073741799 753777379 753909735 686588033 8650752 753777635 547618816 753775299 753774787 686030976 1073741823 686588...

output:

YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
NO
YES
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO
YE...

result:

ok 99999 lines

Test #20:

score: 0
Accepted
time: 63ms
memory: 44880kb

input:

41 100000
1061416439 855895380 285214740 1073741815 16779284 927198678 860089812 855673108 4 20 318802196 860089684 855895380 1073741823 1065353207 1063513591 1061416407 1073741815 0 2068 1064566263 1063513591 1061416439 1073741823 285247508 318801940 318801940 855813460 1064566775 855829844 8600898...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
NO
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
NO
NO
YES
NO
YES
YES
YES
YES
YES
YES
NO
NO
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
...

result:

ok 100000 lines

Test #21:

score: 0
Accepted
time: 57ms
memory: 42816kb

input:

10 100000
537396288 784895942 1073725431 537396288 1073725431 839724534 931759350 779685345 741125603 537396288
1 8
1 9
6 9
1 7
1 4
1 4
4 10
8 8
6 8
4 9
4 7
4 8
1 5
3 6
4 7
1 4
4 9
10 10
5 7
3 10
1 2
7 10
7 9
4 8
5 8
4 8
7 10
1 4
3 8
9 10
2 10
8 8
2 10
5 9
1 6
2 9
2 10
1 6
1 8
7 10
2 6
7 8
2 10
1 10...

output:

YES
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
YES
YES
...

result:

ok 100000 lines

Test #22:

score: 0
Accepted
time: 73ms
memory: 46788kb

input:

100 100000
91647697 1024777936 95745265 231032189 893838708 1029994609 891575993 1033328016 230978973 896985364 99019988 500648656 360044912 770033876 891614840 635892020 623303773 227992945 755483997 84311421 896949304 1026939280 1073217533 635881304 629536624 630511228 224688380 763843481 75841013...

output:

NO
NO
NO
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO...

result:

ok 100000 lines

Test #23:

score: 0
Accepted
time: 72ms
memory: 53004kb

input:

1000 100000
742125614 1040830654 355150063 197868574 400231454 634227822 624801807 480064683 28307487 238890075 452838414 708680762 343667754 800698442 159111274 320697435 459103246 94365786 466477102 592008319 702382318 620432542 94072927 252311631 661205227 446537978 497753118 739230955 392820810 ...

output:

NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES...

result:

ok 100000 lines

Test #24:

score: 0
Accepted
time: 79ms
memory: 59332kb

input:

10000 100000
1055983260 535529672 216997134 477988508 779955480 801714382 719259468 761247240 971576478 182424156 1044987658 1012736922 458204250 197332894 524780442 441269708 259859034 233772632 150812890 433923418 944740824 1027811214 511543628 997004490 719815578 778288328 1030827594 534587144 44...

output:

YES
YES
YES
NO
NO
YES
NO
YES
NO
YES
YES
NO
NO
NO
NO
YES
NO
YES
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
YES
NO
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
YES
YES
YES
NO
YES
NO
NO
YES
NO
YES
YES
YES
NO
NO
YES
NO...

result:

ok 100000 lines

Test #25:

score: 0
Accepted
time: 89ms
memory: 59592kb

input:

20000 100000
97309938 250029170 1068302576 634053858 697003121 284474600 216323187 950178043 130921584 951829601 1053822073 888428658 398986490 885578872 361389178 681146595 377743608 500867171 1004703969 998909161 552325241 513861747 15432817 569948265 347315313 143879403 780942456 30833904 6158051...

output:

NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
YES
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO...

result:

ok 100000 lines

Test #26:

score: 0
Accepted
time: 162ms
memory: 63148kb

input:

99999 99999
151441895 691880741 960071782 951208741 681216869 430408612 673084067 671497831 940269024 940686948 671766499 404721891 406731937 691136866 674132581 950248674 941290786 951724705 966351905 421746086 145437926 942248867 959210913 965881568 941496741 411875042 154218214 403412962 15177596...

output:

YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO
YES
YES
NO
NO
NO
YES
NO
NO
YES
NO
YES
NO
YES
YES
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
YES
YES
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
NO
YES
NO
YES
YES
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES
NO
YES
NO
Y...

result:

ok 99999 lines

Test #27:

score: 0
Accepted
time: 218ms
memory: 63220kb

input:

99999 100000
128213811 114040163 123251299 255085607 178289011 240706851 265311779 248779943 184320115 106481783 64755879 65031603 112207719 47739699 184066215 113514935 40947367 39378531 252977847 238294755 47762599 44096995 253766503 171747939 183241955 192993063 238578275 115385767 260608183 6422...

output:

NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
NO
NO
YES
NO
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
YES
NO
...

result:

ok 100000 lines

Test #28:

score: 0
Accepted
time: 168ms
memory: 63140kb

input:

100000 100000
159728630 362627698 575304054 345125846 843273170 676127602 1041113810 93704434 247587058 827695954 785498450 378196818 14127574 320315634 849097426 357507314 438092754 902840790 190342002 190533970 177680626 505249910 14599026 591487478 228106710 222606290 89641074 386732406 462516818...

output:

YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES
NO
YES
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
YES
NO
YES
YES
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
YES
NO
NO
...

result:

ok 100000 lines