QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558849#7411. Bitwise XorWarrnaCuteAC ✓199ms307516kbC++143.5kb2024-09-11 18:52:122024-09-11 18:52:14

Judging History

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

  • [2024-09-11 18:52:14]
  • 评测
  • 测评结果:AC
  • 用时:199ms
  • 内存:307516kb
  • [2024-09-11 18:52:12]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,K;
int ans=1;
const int P=998244353;
int power(int x,int y){
    if(y==0)return 1;
    int tmp=power(x,y>>1);
    if(y&1)return tmp*tmp%P*x%P;
    return tmp*tmp%P;
}
class trie01{
    public:
    int ch[300005<<6][2];
    int siz[300005<<6];
    int tot;
    void insert(int x){
        int now=0;
        // siz[0]++;
        for(int i=60;i>=0;i--){
            int nxt=((x>>i)&1);
            if(!ch[now][nxt])ch[now][nxt]=++tot;
            now=ch[now][nxt];
            siz[now]++;
        }
        return;
    }
    int getans(int X,int Y,int k){//实际上只要在不同侧就能够直接结算了
        // printf("getans %lld %lld %lld\n",X,Y,k);
        if(!X||!Y)return 0;
        if(k==-1){//
            return siz[X]*siz[Y]%P;
        }
        int ans=(siz[ch[X][0]]*siz[ch[Y][1]]+siz[ch[X][1]]*siz[ch[Y][0]])%P;
        if((K>>k)&1){//考虑第二高的位,如果当前是1,那就只能是X的左儿子匹配Y的右儿子了!
        //只判断选出两个数来的方案,只选一个数或是不选什么的我在里面也能判
            // printf("muled %lld %lld %lld %lld\n",siz[ch[X][0]],siz[ch[Y][1]],siz[ch[X][1]],siz[ch[Y][0]]);
            // return ans;
            // ans=0;//这一位为1的时候就意味着这两边必须各选一个使得这一位位数不同,
            return (getans(ch[X][0],ch[Y][1],k-1)+getans(ch[X][1],ch[Y][0],k-1))%P;
        }//如果这里选进1,那后面就可以乱选了,如果这里选进0,后面就必须还得走限制。
        return (ans+getans(ch[X][0],ch[Y][0],k-1)+getans(ch[X][1],ch[Y][1],k-1))%P;
    }
    void search(int cur,int k){
        // if(!cur)return;
        if((K>>k)&1){//k是highbit表示这里面只能选一个
            // printf("k=%lld ",k);
            if(!ch[cur][0]){
                (ans*=(siz[ch[cur][1]]+1))%=P;
                // printf("mul1 %lld\n",siz[ch[cur][1]]+1);
            }
            else if(!ch[cur][1]){
                (ans*=(siz[ch[cur][0]]+1))%=P;
                // printf("mul2 %lld\n",siz[ch[cur][0]]+1);
            }
            else{
                if(K^(1<<k)){//
                    int mul=(getans(ch[cur][0],ch[cur][1],k-1)+siz[cur]+1)%P;
                    (ans*=mul)%=P;
                    // printf("mul3 %lld\n",mul);
                }
                else{
                    int mul=(siz[ch[cur][0]]*siz[ch[cur][1]]+siz[cur]+1)%P;
                    (ans*=mul)%=P;
                    // printf("mul4 %lld\n",mul);
                }
            }
            return;
        }
        if(ch[cur][0])search(ch[cur][0],k-1);
        if(ch[cur][1])search(ch[cur][1],k-1);
        return;
    }
}T;
signed main(){
    // freopen("test.in","r",stdin);
    // freopen("ans.out","w",stdout);
    scanf("%lld%lld",&n,&K);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%lld",&x);
        T.insert(x);
    }
    if(K==0){//乱选
        printf("%lld\n",(power(2,n)-1)%P);
        return 0;
    }
    T.search(0,60);
    printf("%lld\n",(ans-1+P)%P);
    return 0;
}
/*
要求选出一个集合使得里面的数两两xor最小值不比x小。

建01trie

找到K的highbit

限制变成了:当前子树只能选一个的方案数

然后考虑,自上而下,这一位恰好为1的选择方案数,那就是找到第二个highbit,在这一层,只有在不同子树的才能选。

没有下一个了。

5 5
4 4 7 5 3 

*/

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5968kb

input:

3 0
0 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5944kb

input:

3 2
0 1 2

output:

5

result:

ok 1 number(s): "5"

Test #3:

score: 0
Accepted
time: 1ms
memory: 5828kb

input:

3 3
0 1 2

output:

4

result:

ok 1 number(s): "4"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5868kb

input:

7 4
11 5 5 8 3 1 3

output:

35

result:

ok 1 number(s): "35"

Test #5:

score: 0
Accepted
time: 1ms
memory: 6004kb

input:

10 0
1 1 0 0 1 0 0 0 1 1

output:

1023

result:

ok 1 number(s): "1023"

Test #6:

score: 0
Accepted
time: 1ms
memory: 5804kb

input:

10 0
1 1 0 1 0 1 1 0 1 0

output:

1023

result:

ok 1 number(s): "1023"

Test #7:

score: 0
Accepted
time: 1ms
memory: 5968kb

input:

10 1
1 0 0 1 0 0 0 0 0 0

output:

26

result:

ok 1 number(s): "26"

Test #8:

score: 0
Accepted
time: 1ms
memory: 6016kb

input:

10 0
0 0 1 1 0 1 1 1 1 1

output:

1023

result:

ok 1 number(s): "1023"

Test #9:

score: 0
Accepted
time: 1ms
memory: 5964kb

input:

10 1
0 0 0 0 0 1 1 0 0 1

output:

31

result:

ok 1 number(s): "31"

Test #10:

score: 0
Accepted
time: 0ms
memory: 6016kb

input:

10 2
3 3 3 0 3 1 2 2 1 2

output:

31

result:

ok 1 number(s): "31"

Test #11:

score: 0
Accepted
time: 1ms
memory: 5944kb

input:

10 0
2 1 1 1 1 2 0 1 2 0

output:

1023

result:

ok 1 number(s): "1023"

Test #12:

score: 0
Accepted
time: 1ms
memory: 5968kb

input:

10 1
2 2 2 3 2 3 3 1 2 3

output:

59

result:

ok 1 number(s): "59"

Test #13:

score: 0
Accepted
time: 0ms
memory: 5944kb

input:

10 0
0 0 0 1 1 1 0 2 3 2

output:

1023

result:

ok 1 number(s): "1023"

Test #14:

score: 0
Accepted
time: 1ms
memory: 6008kb

input:

10 3
0 2 2 2 1 2 3 0 2 1

output:

22

result:

ok 1 number(s): "22"

Test #15:

score: 0
Accepted
time: 0ms
memory: 5968kb

input:

10 232612786
899206785 627708234 142071418 602920154 868777585 1041571266 892732172 868993257 746093759 987356899

output:

109

result:

ok 1 number(s): "109"

Test #16:

score: 0
Accepted
time: 0ms
memory: 6012kb

input:

10 0
693036642 1030693062 419968059 741209191 591827389 259645735 276712455 734217910 177798129 94619093

output:

1023

result:

ok 1 number(s): "1023"

Test #17:

score: 0
Accepted
time: 0ms
memory: 5968kb

input:

10 635603548
611293890 811243506 517958533 561419149 895889603 689314144 76814806 428189482 659398653 905893003

output:

28

result:

ok 1 number(s): "28"

Test #18:

score: 0
Accepted
time: 1ms
memory: 5964kb

input:

10 598501421
901133473 1042356871 455409245 112433974 817368410 222953949 336845301 1006948209 370826440 272138888

output:

32

result:

ok 1 number(s): "32"

Test #19:

score: 0
Accepted
time: 0ms
memory: 5968kb

input:

10 569445936
869711746 277315301 943789204 430971232 323814634 798129975 683685773 693506183 425568840 820399918

output:

30

result:

ok 1 number(s): "30"

Test #20:

score: 0
Accepted
time: 1ms
memory: 5888kb

input:

10 420556732312880218
1106881251557229935 479315094315300787 1150808909500812292 323682577963266475 778601139147884850 223606994709920530 180162865619996357 598163543343955050 759543442386927924 1066745884923649787

output:

76

result:

ok 1 number(s): "76"

Test #21:

score: 0
Accepted
time: 0ms
memory: 5952kb

input:

10 582978699259358148
664286799112260583 224369278625040035 902797719937094060 670944402692952440 328843827154205288 428706657140951701 137252770966221528 52751604837394452 252242163219108700 964286128123886602

output:

34

result:

ok 1 number(s): "34"

Test #22:

score: 0
Accepted
time: 1ms
memory: 5976kb

input:

10 564992503452356335
665113046585311303 966441243412282831 254418450103486710 373213599504887965 373018025659128173 1139839833176769230 63170343788559154 552084482604372812 578369479665175584 290676303796380178

output:

34

result:

ok 1 number(s): "34"

Test #23:

score: 0
Accepted
time: 1ms
memory: 5912kb

input:

10 296378574821992743
46426013340785518 543133517958628320 4427845211879112 131398175764325177 79046368751109655 1033217350714129300 958341202565114446 639852945691905735 340024558340731405 274343413834503372

output:

107

result:

ok 1 number(s): "107"

Test #24:

score: 0
Accepted
time: 0ms
memory: 5972kb

input:

10 753648817744708845
679105509954532975 932747575918656348 715747811344168398 279517138768023690 391618536155396132 543057934603808659 157236874656623091 259985351735488895 1139457402033766834 939468151234428243

output:

30

result:

ok 1 number(s): "30"

Test #25:

score: 0
Accepted
time: 0ms
memory: 5824kb

input:

2000 0
0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 1 1 0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 1 0 0...

output:

708964704

result:

ok 1 number(s): "708964704"

Test #26:

score: 0
Accepted
time: 1ms
memory: 5904kb

input:

2000 0
0 0 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 1 1 0 0 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0...

output:

708964704

result:

ok 1 number(s): "708964704"

Test #27:

score: 0
Accepted
time: 1ms
memory: 6008kb

input:

2000 1
0 1 0 0 1 1 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 0 0 1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0 1 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 0 1 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0...

output:

1000976

result:

ok 1 number(s): "1000976"

Test #28:

score: 0
Accepted
time: 1ms
memory: 5948kb

input:

2000 0
1 0 1 0 1 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 1 0 0 1 1 1 1 1 0 1 1 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1...

output:

708964704

result:

ok 1 number(s): "708964704"

Test #29:

score: 0
Accepted
time: 1ms
memory: 5948kb

input:

2000 1
1 1 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 1 0 0 0 1 1 0 1 1 0 1 1 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1...

output:

1001975

result:

ok 1 number(s): "1001975"

Test #30:

score: 0
Accepted
time: 1ms
memory: 5884kb

input:

2000 2
1 3 2 0 1 3 1 3 3 2 2 2 3 3 1 3 3 3 0 1 3 2 0 2 1 1 1 3 2 2 1 3 3 0 2 0 1 0 3 0 1 1 3 2 1 1 2 3 1 1 2 1 3 1 0 3 0 1 0 2 0 1 1 2 2 2 2 3 1 0 2 1 0 2 1 0 3 0 0 0 0 0 1 3 3 1 1 2 3 3 0 0 2 2 0 2 1 3 3 0 1 1 0 3 3 1 2 1 2 3 2 0 3 2 0 3 0 0 1 3 2 3 0 0 1 1 0 1 0 2 0 3 2 1 3 3 3 3 0 0 0 3 0 2 3 2 3...

output:

1001964

result:

ok 1 number(s): "1001964"

Test #31:

score: 0
Accepted
time: 1ms
memory: 6008kb

input:

2000 2
3 0 2 3 1 3 3 0 2 3 0 0 0 0 1 3 3 1 0 3 2 2 0 3 1 2 3 3 1 1 1 2 0 3 2 0 0 3 0 1 1 0 2 0 0 0 3 0 0 0 1 3 1 2 2 2 0 3 3 2 0 1 0 2 0 2 1 3 3 3 0 2 3 3 0 2 3 1 3 3 0 1 2 0 3 3 0 2 2 2 2 3 3 3 2 0 0 0 3 3 1 1 3 1 1 2 1 1 0 3 0 0 0 3 2 3 1 1 1 0 3 2 1 1 0 1 0 3 3 2 1 0 3 0 1 2 1 3 2 2 2 2 3 1 2 2 1...

output:

1001984

result:

ok 1 number(s): "1001984"

Test #32:

score: 0
Accepted
time: 1ms
memory: 5872kb

input:

2000 3
3 0 0 1 2 0 2 0 1 2 3 3 3 1 0 0 2 3 2 0 2 3 1 2 2 2 0 0 2 3 3 0 3 3 3 1 2 1 1 3 1 3 3 3 1 3 2 0 2 3 3 3 2 2 2 0 3 0 2 3 0 2 3 0 0 0 2 3 2 1 1 1 2 2 0 0 3 0 1 3 3 1 0 0 2 3 0 1 3 1 0 3 2 0 3 2 0 3 1 3 2 3 0 0 3 0 0 0 1 2 3 1 0 1 2 0 3 2 1 0 0 0 3 2 0 3 0 2 1 0 1 2 3 3 0 2 0 0 1 2 0 3 2 0 1 0 0...

output:

500878

result:

ok 1 number(s): "500878"

Test #33:

score: 0
Accepted
time: 1ms
memory: 5888kb

input:

2000 0
3 2 1 1 2 1 3 2 2 0 2 0 0 0 0 1 1 1 2 1 3 3 2 3 1 2 0 0 2 3 2 0 3 1 3 3 0 1 0 1 3 2 2 3 1 2 1 0 3 3 0 0 3 3 3 0 0 0 0 0 1 1 2 0 3 3 1 3 2 0 0 3 1 0 2 0 3 3 2 0 2 0 3 1 3 1 0 3 0 1 0 2 1 0 3 1 0 3 0 2 1 2 1 0 2 3 2 3 0 2 3 3 0 3 1 1 0 2 1 0 0 3 1 2 1 2 0 1 0 1 2 3 0 1 2 2 0 1 3 0 2 3 0 0 3 0 0...

output:

708964704

result:

ok 1 number(s): "708964704"

Test #34:

score: 0
Accepted
time: 1ms
memory: 5884kb

input:

2000 3
1 3 0 2 2 0 2 1 0 0 2 1 0 0 1 1 3 2 0 2 2 0 2 0 3 1 1 3 3 2 1 3 3 2 0 1 0 3 3 0 2 3 0 0 0 0 2 2 2 0 1 2 2 2 3 0 0 3 3 0 2 2 2 2 1 0 1 2 1 0 0 1 1 0 3 2 1 3 0 2 2 1 2 0 2 2 0 2 1 3 2 3 1 3 3 2 3 0 2 1 0 3 2 0 0 0 2 2 2 3 1 0 3 0 3 1 2 0 2 2 2 2 2 0 0 3 1 1 1 2 3 3 2 1 0 2 0 2 1 0 0 3 3 0 3 2 0...

output:

501086

result:

ok 1 number(s): "501086"

Test #35:

score: 0
Accepted
time: 0ms
memory: 6596kb

input:

2000 84871189
1045107888 457736159 1040100608 728197221 258193066 35582589 511446583 980507876 434393762 889926277 6565983 1021327134 336189598 429390370 200222928 242627553 850085482 8999142 911979240 917229471 610016276 797660227 1047817351 531797743 767090800 700551186 953164435 265389835 1007662...

output:

898802445

result:

ok 1 number(s): "898802445"

Test #36:

score: 0
Accepted
time: 1ms
memory: 6592kb

input:

2000 951504201
620557932 850267211 176974794 744535683 632583510 843330442 529006451 709017771 639018779 134814560 120610907 658919140 437817344 413288199 300190866 118111296 495762049 760171784 662091678 654628965 934431180 810642884 160040182 809395723 430169155 222263790 217911944 1030547842 9753...

output:

229324

result:

ok 1 number(s): "229324"

Test #37:

score: 0
Accepted
time: 2ms
memory: 8636kb

input:

2000 788229967
538815180 630817655 274965267 564745641 936645724 199257026 329108802 402989343 46877478 946088471 760445490 481263012 807924123 1001370952 171192357 30476077 326474988 864239246 193744992 1073108566 882960785 221485574 712766380 1009610971 678404036 811480879 863819478 489736735 4892...

output:

534095

result:

ok 1 number(s): "534095"

Test #38:

score: 0
Accepted
time: 1ms
memory: 6600kb

input:

2000 665904370
720707622 799363605 458735737 153190095 327311293 475247944 311645162 394427035 411021907 848970130 225182950 321153936 226791347 1009972145 47573674 398010415 124711848 460068359 924933300 1070303963 566647429 245289242 960575303 893291101 701615518 683101204 333787114 208069217 7499...

output:

758288

result:

ok 1 number(s): "758288"

Test #39:

score: 0
Accepted
time: 1ms
memory: 6532kb

input:

2000 155206429
1015612849 107343227 768076570 556248299 786971940 865883122 302400184 805020802 113868843 722969295 579681659 867847988 613723351 386570839 310146404 336197514 871605822 91107700 216159676 120677616 180646135 1047283252 23297933 1017975862 612523938 775937610 62537255 855834639 20082...

output:

138392029

result:

ok 1 number(s): "138392029"

Test #40:

score: 0
Accepted
time: 2ms
memory: 7516kb

input:

2000 810644317790559450
951234409297480605 917050945953463382 1110412530216095289 5030990046961552 411205681829833188 765404220932245053 126045976080458432 435705840272855629 845862553616946390 1152560042560800764 567645952714623247 360729381676462789 848159168753584687 519933674668600749 2540037923...

output:

594689

result:

ok 1 number(s): "594689"

Test #41:

score: 0
Accepted
time: 0ms
memory: 7444kb

input:

2000 158540740765130049
307188828836158449 537689509214794280 537785471236196666 293604397655495572 597874280046861825 270407892057038072 932847932947767503 471369711173545165 292227431482774334 563299190758435994 339610138601354163 722608135348476612 440094441170088384 158591217241198356 3953759389...

output:

212011211

result:

ok 1 number(s): "212011211"

Test #42:

score: 0
Accepted
time: 2ms
memory: 7568kb

input:

2000 281895081539402771
308015067719274577 126839973690157396 1042327706009436292 1148795094779310777 642048482846752006 981541072387822896 208669118250151582 886201418516729153 817845297720620873 588936810039543409 629031346871575155 594627493917270017 500735062829469932 375517603768807021 80051925...

output:

928207213

result:

ok 1 number(s): "928207213"

Test #43:

score: 0
Accepted
time: 2ms
memory: 7572kb

input:

2000 1048281954270496219
1079369157737891331 954948102282751878 812163970851284857 999050589029779754 276896950225917604 413163304663465996 119771664162727614 288970558113644506 868270077720013237 1003763159329372780 888201456984216696 65034312731365865 901955073953037506 1073103323217772014 2974098...

output:

183415

result:

ok 1 number(s): "183415"

Test #44:

score: 0
Accepted
time: 2ms
memory: 7508kb

input:

2000 53809885318283364
523458659104849054 545286009975958001 193923746933083219 479141635726995550 401902225446076259 1084855165121100478 714023893466016350 1147700676192370646 346304454375572768 811094623237592343 303366583942144293 803498991796487934 530493941791779428 971086450897451585 230129538...

output:

855514808

result:

ok 1 number(s): "855514808"

Test #45:

score: 0
Accepted
time: 44ms
memory: 5960kb

input:

300000 0
1 1 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 0 1 1 1 0 1 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0 1 0 0 1 1 1 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 1 0 1 1 0 0 1 0...

output:

526952119

result:

ok 1 number(s): "526952119"

Test #46:

score: 0
Accepted
time: 44ms
memory: 5948kb

input:

300000 1
1 0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 1 0 1 0 0 0 0 1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0 1 1 0 1 0 0 1 0...

output:

538924198

result:

ok 1 number(s): "538924198"

Test #47:

score: 0
Accepted
time: 40ms
memory: 5968kb

input:

300000 1
1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 0 0 0 1 1 0 1 1 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 1 0 0...

output:

538892905

result:

ok 1 number(s): "538892905"

Test #48:

score: 0
Accepted
time: 44ms
memory: 6012kb

input:

300000 0
1 1 1 1 1 0 0 1 0 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 0...

output:

526952119

result:

ok 1 number(s): "526952119"

Test #49:

score: 0
Accepted
time: 44ms
memory: 5884kb

input:

300000 1
0 0 1 0 1 1 1 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 1 1 0 0 1 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 0 1 0 1 0 0 1 1 1 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 1 0 1 1...

output:

538906278

result:

ok 1 number(s): "538906278"

Test #50:

score: 0
Accepted
time: 43ms
memory: 5904kb

input:

300000 2
1 1 0 2 2 2 3 0 1 3 0 0 2 3 1 1 1 3 1 2 0 1 1 3 3 3 2 0 3 1 1 0 0 1 1 3 3 2 1 0 1 1 3 0 1 3 3 1 2 3 2 0 3 1 3 0 1 3 1 0 1 0 2 1 2 3 2 1 3 1 2 1 0 1 2 1 0 1 3 3 2 3 2 3 1 2 3 1 2 1 3 1 1 0 3 3 0 3 2 1 3 0 2 0 2 1 3 3 3 0 3 1 1 1 1 3 2 0 3 0 1 0 0 0 1 1 2 2 1 3 1 2 1 1 2 3 0 3 0 2 0 0 3 1 3 0...

output:

538921098

result:

ok 1 number(s): "538921098"

Test #51:

score: 0
Accepted
time: 43ms
memory: 6012kb

input:

300000 0
0 2 0 1 3 1 3 0 2 0 3 3 3 2 3 2 1 3 1 3 1 2 0 2 2 1 3 1 2 1 0 1 2 3 3 0 2 3 3 1 2 1 0 3 2 3 0 2 3 0 1 0 0 1 0 1 2 3 2 3 0 1 1 3 3 0 0 3 3 2 0 2 1 2 0 3 3 0 2 2 3 2 3 1 0 3 3 0 3 0 2 1 0 2 1 1 3 2 3 2 3 1 0 3 2 0 2 3 2 1 3 2 2 3 3 2 3 3 0 3 3 2 1 0 2 3 3 0 0 3 0 1 0 0 3 1 1 2 2 3 3 2 1 3 2 1...

output:

526952119

result:

ok 1 number(s): "526952119"

Test #52:

score: 0
Accepted
time: 43ms
memory: 6000kb

input:

300000 1
0 2 2 3 0 2 2 0 1 2 2 3 2 0 2 3 0 2 3 0 2 0 1 1 3 2 0 2 2 3 2 0 1 3 3 0 0 2 0 0 3 3 1 1 3 2 3 2 1 3 3 3 1 1 0 3 1 3 1 3 3 2 1 1 3 1 1 2 2 0 1 0 0 2 3 1 3 3 3 2 2 2 1 0 3 3 3 3 1 3 0 2 3 3 2 0 3 1 1 2 0 3 2 2 0 2 0 2 3 0 2 3 2 2 3 3 0 3 1 3 1 3 3 1 2 1 3 3 2 2 1 3 1 0 1 1 3 3 1 0 1 3 0 1 1 3...

output:

355197415

result:

ok 1 number(s): "355197415"

Test #53:

score: 0
Accepted
time: 43ms
memory: 6008kb

input:

300000 0
1 3 3 3 0 1 3 2 3 3 1 3 2 2 0 3 0 2 2 1 3 3 2 0 1 3 2 1 2 3 1 3 3 2 2 1 1 0 0 3 0 0 0 1 0 3 2 2 0 3 1 3 2 1 2 2 0 3 1 3 2 3 3 3 1 1 1 3 1 1 0 1 0 3 3 0 2 1 0 3 3 1 3 2 0 0 1 1 2 1 2 3 1 3 1 0 2 2 3 3 1 3 3 1 0 3 0 0 2 1 1 1 1 1 0 3 1 1 0 1 3 3 0 0 3 1 1 2 2 0 0 0 0 2 1 1 3 1 1 1 2 1 1 0 3 2...

output:

526952119

result:

ok 1 number(s): "526952119"

Test #54:

score: 0
Accepted
time: 39ms
memory: 5868kb

input:

300000 3
2 0 2 0 0 3 1 3 2 1 0 3 3 0 1 3 1 2 1 3 0 3 3 1 2 2 2 0 1 0 0 0 0 0 0 3 2 1 1 3 2 0 0 2 1 3 2 1 3 2 0 1 2 2 2 1 1 1 0 1 3 0 3 1 2 1 1 0 0 1 1 1 1 3 0 2 2 3 3 0 0 0 2 1 0 3 3 1 0 1 1 0 0 1 2 3 2 0 1 2 1 2 0 1 3 0 3 0 3 0 3 1 0 3 0 1 0 0 0 3 2 3 2 0 0 3 3 2 2 3 0 2 1 1 2 1 1 2 1 2 3 3 2 2 3 0...

output:

269609889

result:

ok 1 number(s): "269609889"

Test #55:

score: 0
Accepted
time: 123ms
memory: 97216kb

input:

300000 492151004
648841878 687396117 622028958 706072444 635954520 185209069 208924095 974461408 1042239242 766620568 796047134 341157817 509986884 1052564765 969815068 252243431 145822160 704350935 848749451 86196191 387317548 171404790 634277431 240750125 206346507 146739711 872075610 413693164 44...

output:

7270165

result:

ok 1 number(s): "7270165"

Test #56:

score: 0
Accepted
time: 113ms
memory: 95180kb

input:

300000 356285983
923984336 732880140 624477052 679161025 930155344 351556000 332366985 352747709 153235329 929621778 624807253 100095943 336921032 855775923 352661350 334339874 483553772 517215960 511597286 997670230 968578202 938528603 494456612 729052845 371366882 492711448 871373585 16015799 2059...

output:

408586955

result:

ok 1 number(s): "408586955"

Test #57:

score: 0
Accepted
time: 111ms
memory: 97276kb

input:

300000 855751417
842241584 513430585 722467525 499370982 160475734 781224409 132469336 46719281 634835852 667153864 190900013 996181638 707027810 370116852 223662841 246704655 314266710 621283422 43250601 342408006 917107806 349371293 1047182809 929268092 619601763 8186712 443539294 548946515 597608...

output:

151851457

result:

ok 1 number(s): "151851457"

Test #58:

score: 0
Accepted
time: 136ms
memory: 97220kb

input:

300000 440099076
603320551 173124039 393361079 450761929 909278675 278608479 1029116924 982385409 132087301 279424653 740101577 220257624 669279071 1062442629 263802252 385802138 955497848 309573967 194232741 30709161 694533148 579705671 880232424 834488828 972063176 262821021 392996895 316458011 52...

output:

542333258

result:

ok 1 number(s): "542333258"

Test #59:

score: 0
Accepted
time: 131ms
memory: 97232kb

input:

300000 489581766
619346839 337003184 350004920 534123522 90991569 1015509602 1073619521 798974334 721714323 599663586 295420986 187678671 787520637 1009745233 5996720 345813392 167342500 786459493 152929888 363386160 1031689232 421027816 683499837 726928243 51779646 222126135 1055190253 1004137968 3...

output:

282934833

result:

ok 1 number(s): "282934833"

Test #60:

score: 0
Accepted
time: 152ms
memory: 307356kb

input:

300000 296755831871074694
449916145255809411 664964133945233804 918494807762995671 1017561483435607718 1050236328754223250 975976930536111197 343124186064496069 513883346116829116 545415329069780661 246855046099834345 1082391952528494267 520503778960718250 144056201686753900 645472815426907434 71835...

output:

250889392

result:

ok 1 number(s): "250889392"

Test #61:

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

input:

300000 522904573777542368
962414065413867349 839636238044791529 1030976476089065709 548723867982105041 550361682447545338 1081644432580000526 101246847252080101 974629122513071327 888209748373157017 298502197480085908 882086499907370133 414877156946824331 813321273511839084 239322167113172577 179241...

output:

752091275

result:

ok 1 number(s): "752091275"

Test #62:

score: 0
Accepted
time: 172ms
memory: 307516kb

input:

300000 718691082336988666
963240308591950774 428786702520154646 382597201960491062 250993064794040567 594535885247435520 639856112598905671 236539320954441043 804860607150423983 926643884655461199 324139812466226028 18586199275776853 207762814491471398 967854326259020717 686070377094919104 875282634...

output:

976936805

result:

ok 1 number(s): "976936805"

Test #63:

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

input:

300000 464807235053729216
228394377666074308 295217602528773944 1077126983236785096 764651373251968371 657365624945895233 598217369137077179 916422716002992158 106786973592530724 441387283112315787 165825282209692364 257824930124214936 387540365374728219 224068482769309208 1073536771249665868 564799...

output:

928004133

result:

ok 1 number(s): "928004133"

Test #64:

score: 0
Accepted
time: 167ms
memory: 306608kb

input:

300000 895822183904582964
22140399358145156 293199197967728423 2006028774950897 146269716997786412 1118172282651385611 498746156429483475 662575125958384199 1101861263502387035 104488660382448702 900218455760274995 256224410188239297 586825807511811748 327807588465102174 1083765959133431180 69447687...

output:

52793764

result:

ok 1 number(s): "52793764"

Test #65:

score: 0
Accepted
time: 1ms
memory: 5972kb

input:

1 0
0

output:

1

result:

ok 1 number(s): "1"

Test #66:

score: 0
Accepted
time: 1ms
memory: 5972kb

input:

1 228
1152921504606846975

output:

1

result:

ok 1 number(s): "1"