QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105757#4782. 完美的旅行1234567890100 ✓2238ms86176kbC++1412.3kb2023-05-15 11:24:152023-05-15 11:24:26

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-15 11:24:26]
  • 评测
  • 测评结果:100
  • 用时:2238ms
  • 内存:86176kb
  • [2023-05-15 11:24:15]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std ;
#define int long long

const int N = 6e5 + 5 , mod = 998244353 , G = 3 ; 

namespace BINOM {
    int inv[N] , ifac[N] , fac[N] ;
    int init(int n = N) {
        inv[1] = fac[0] = ifac[0] = 1 ; 
        for (int i = 2 ; i < n ; ++ i) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod ; 
        for (int i = 1 ; i < n ; ++ i) {
            fac[i] = 1ll * fac[i - 1] * i % mod ; 
            ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod ; 
        }
        return 0 ; 
    }int get_binom = init() ;
    int C(int n , int m) {
        if (n < m || m < 0) return 0 ; 
        return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod ; 
    }
} 
using namespace BINOM ; 

int qmi(int a , int b = mod - 2) {
    int res = 1; a %= mod;
    while (b) {
        if (b & 1) res = (long long)res * a % mod;
        a = (long long)a * a % mod , b >>= 1;
    }
    return res;
}

inline void Add(int &x, int y) {
	x += y;
	if(x >= mod) x -= mod;
}
inline void Dec(int &x, int y) {
	x -= y;
	if(x < 0) x += mod;
}
inline int add(int x, int y) {
	x += y;
	if(x >= mod) x -= mod;
	return x;
}
inline int dec(int x, int y) {
	x -= y;
	if(x < 0) x += mod;
	return x;
}

namespace POLY {
    #define L(i, j, k) for(int i = (j); i <= (k); ++i)
    #define R(i, j, k) for(int i = (j); i >= (k); --i)
    #define V (*this)
    #define SZ() ((int) size())
    #define sz(a) ((int) a.size())
    #define vi vector < int >
    using ll = long long ;

    const int MOD = mod , inv2 = (MOD + 1) / 2 , _G = G ;  
    int rt[N << 1], Lim;
    int extend(int n) { return 1 << (__lg(n - 1) + 1) ; }
    int Pinit(int x) {
        for(Lim = 1; Lim < x; Lim <<= 1) ;
        for(int i = 1; i < Lim; i <<= 1) {
            int sG = qmi (_G, (MOD - 1) / (i << 1));
            rt[i] = 1;
            L(j, i + 1, i * 2 - 1) rt[j] = (ll) rt[j - 1] * sG % MOD;
        }
        return 0 ;
    }
    static int __POLY_INIT = Pinit(extend(N)) ;
    struct poly : public vector<int> {
        poly() : vi(){}
        poly(int n , int v = 0) : vi(n , v){}
        poly(vi t) : vi(t){}
        poly(initializer_list<int> li) : vi(li) {}
        int v(int i) { return i < 0 || i >= (int)size() ? 0 : V[i]; }
        void init(int n = 0) { vi(n).swap(V); }
        void clear() { init(0) ; }
        inline void dif() {
            int n = size() ; 
            for (int l = n >> 1; l >= 1; l >>= 1) 
                for(int j = 0; j < n; j += l << 1) 
                    for(int k = 0, *w = rt + l; k < l; k++, w++) {
                        int x = V[j + k], y = V[j + k + l];
                        V[j + k] = add(x, y);
                        V[j + k + l] = (ll) * w * dec(x, y) % MOD;
                    }
        }
        void dit () {
            int n = size() ; 
            for(int i = 2; i <= n; i <<= 1) 
                for(int j = 0, l = (i >> 1); j < n; j += i) 
                    for(int k = 0, *w = rt + l; k < l; k++, w++) {
                        int pa = V[j + k], pb = (ll) V[j + k + l] * *w % MOD;
                        V[j + k] = add(pa, pb), V[j + k + l] = dec(pa, pb);
                    }
            reverse(begin() + 1, end());
            for(int i = 0, iv = qmi(n); i < n; i++) V[i] = (ll) V[i] * iv % MOD;
        } 
        void trim() { while (!empty() && !back()) pop_back() ; }
        friend poly operator * (poly aa, poly bb) {
            if(!sz(aa) || !sz(bb)) return {};
            // return poly(MTT::conv(aa , bb , MOD));
            int all = sz(aa) + sz(bb) - 1 , lim = extend(all);
            aa.resize(lim), bb.resize(lim), aa.dif(), bb.dif();
            L(i, 0, lim - 1) aa[i] = (ll) aa[i] * bb[i] % MOD;
            aa.dit(), aa.resize(all);
            return aa;
        }
        poly Inv() {
            assert(empty() || V[0]);
            poly f, g , res = {qmi(V[0])} ;
            for(int m = 1, pn; m < SZ(); m <<= 1) {
                pn = m << 1, f = res, g.resize(pn), f.resize(pn);
                for(int i = 0; i < pn; i++) g[i] = v(i) ; 
                g *= f ; for(int i = 0; i < m; i++) g[i] = 0;
                g *= f , res.resize(pn);
                for(int i = m; i < min(pn, SZ()); i++) 
                    res[i] = (MOD - g[i]) % MOD;
            }
            return res.resize(SZ()) , res ;
        }
        poly operator << (int x) {
            poly zm (size() + x);
            L(i, 0, (int)size() - 1) zm[i + x] = V[i];
            return zm;
        }
        poly operator >> (int x) {
            if (x >= (int)size()) return poly();
            poly zm (size() - x);
            L(i, x , (int)size() - 1) zm[i - x] = V[i];
            return zm;
        }
        poly shift(ll k) {
            poly g = V ; 
            if (k > 0) {
                for (int i = SZ() - 1 ; i >= k ; -- i) g[i] = g[i - k] ;
                for (ll i = min((ll)SZ(), k) - 1; i >= 0 ; -- i) g[i] = 0 ; 
            }
            else if (k < 0) {
                k = -k ;
                for (int i = 0 ; i + k < SZ() ; ++ i) g[i] = g[i + k] ;
                for (ll i = max((ll)SZ() - k , 0ll) ; i < SZ() ; ++ i) g[i] = 0;
            }
            return g ;
        }
        friend pair<poly , poly> div (poly aa, poly bb) { //商,余
            aa.trim() , bb.trim();
            int n = aa.size() , m = bb.size() ;
            if (n < m) return {poly() , aa} ; 
            poly tb = bb ;
            aa.Rev() , bb.Rev() , bb.resize(n - m + 1) , bb = bb.Inv() ;
            poly cc = aa * bb ; cc.resize(n - m + 1) ; 
            cc.Rev() , aa.Rev() ; 
            poly dd = aa - tb * cc ; dd.resize(m - 1) , dd.trim() ;
            return {cc , dd} ; 
        }
        friend poly operator + (poly aa, poly bb) {
            poly res(max(sz(aa), sz(bb)));
            L(i, 0, sz(res) - 1) res[i] = add(aa.v(i), bb.v(i));
            return poly(res);
        }
        friend poly operator - (poly aa, poly bb) {
            poly res(max(sz(aa), sz(bb)));
            L(i, 0, sz(res) - 1) res[i] = dec(aa.v(i), bb.v(i));
            return poly(res);
        }
        friend poly operator * (poly aa, int bb) {
            poly res(sz(aa));
            L(i, 0, sz(aa) - 1) res[i] = (ll) aa[i] * bb % MOD;
            return res;
        }
        friend poly operator / (poly aa, poly bb) { return div(aa , bb).first ; }
        friend poly operator % (poly aa, poly bb) { return div(aa , bb).second ; }
        poly & operator += (poly o) {
            resize(max(SZ(), sz(o)));
            L(i, 0, SZ() - 1) (V[i] += o.v(i)) %= MOD;
            return V ;
        }
        poly & operator -= (poly o) {
            resize(max(SZ(), sz(o)));
            L(i, 0, SZ() - 1) (V[i] += MOD - o.v(i)) %= MOD;
            return V;
        }
        poly & operator *= (poly o) { return V = V * o; }
        poly & operator /= (poly o) { return V = V / o; }
        poly & operator %= (poly o) { return V = V % o; }
        poly Integ() {
            if(!SZ()) return poly();
            poly res(SZ() + 1);
            L(i, 1, SZ()) res[i] = (ll) V[i - 1] * inv[i] % MOD;
            return res;
        }
        poly Deriv() {
            if(!SZ()) return poly();
            poly res(SZ() - 1); 
            L(i, 1, SZ() - 1) res[i - 1] = (ll) V[i] * i % MOD;
            return res;
        }
        poly Ln() { // a[0] = 1
            poly g = (V.Inv() * V.Deriv()).Integ();
            return g.resize(SZ()), g;
        }
        poly Exp() { // a[0] = 0
            poly f , res = {1} ; 
            for(int m = 1, pn; m < SZ(); m <<= 1) {
                pn = min(m << 1, SZ()), f.resize(pn), res.resize(pn);
                for(int i = 0; i < pn; i++) f[i] = v(i);
                f -= res.Ln(), (f[0] += 1) %= MOD, res *= f, res.resize(pn); 
            }
            return res.resize(SZ()), res;
        }
        poly qpow(int x) {
            poly g(SZ()) , r = V; g[0] = 1 ; 
            for (;x;x >>= 1, r = r * r, r.resize(SZ())) 
                if (x & 1) g *= r , g.resize(SZ());
            return g; 
        }
        poly pow(int x, int rx = -1) { // x : the power % MOD; rx : the power % (MOD - 1)
            if(rx == -1) rx = x;
            int cnt = 0 , n = SZ(); 
            while (V[cnt] == 0 && cnt < n) ++ cnt;
            poly res = V >> cnt ; 
            int c = res[0], w = qmi(res[0]);
            res = (res * w).Ln();
            res = (res * x).Exp() ;
            // cout << c << ' ' << rx << ' ' << ' ' << (ll)c * c % mod << ' ' << qmi(c , rx) << '\n' ;
            res = res * qmi(c , rx);
            // if ((ll)cnt * x > n) L(i, 0, n - 1) res[i] = 0;
            // else if(cnt) {
            //     R(i, n - cnt * x - 1, 0) res[i + cnt * x] = res[i];
            //     L(i, 0, cnt * x - 1) res[i] = 0; 
            // }
            res = res.shift((ll) cnt * x);
            return res.resize(n) , res;
        }
        poly sqrt(int Rt = 1) { // a[0] = 1
            poly res = {Rt} , f; int n = SZ() ; 
            for(int m = 1, pn; m < n; m <<= 1) {
                pn = min(m << 1, n), f.resize(pn);
                for(int i = 0; i < pn; i++) f[i] = v(i);
                f += res * res, f.resize(pn), res.resize(pn), res = f * res.Inv(), res.resize(pn);
                for(int i = 0; i < pn; i++) res[i] = (ll) res[i] * inv2 % MOD;
            }
            return res;
        }
        void Rev() { reverse(begin() , end()); }
        void read() { for (int i = 0 ; i < (int)size() ; ++ i) { scanf("%d" , &V[i]); } }
        void print() {
            for (int i = 0 ; i < (int)size() || (puts("") , 0) ; ++ i) {
                printf("%d " , V[i]) ;
            }
        }
        #undef L
        #undef R
        #undef V
        #undef SZ
        #undef add
        #undef dec
        /*
        65537 = 2^16 + 1 , G = 3
        998244353 = 119 * 2^23 + 1 , G = 3
        1004535809 = 479 * 2^21 + 1 , G = 3 (>1e9)
        4179340454199820289 = 29 * 2^57 + 1 , G = 3 (>4e18)
        */
    } ;
} using namespace POLY ;
inline int read () {
	int x = 0, f = 1;
	char ch = getchar ();
	while (ch < '0' || ch > '9') f = ((ch == '-') ? -1 : f), ch = getchar ();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar ();
	return x * f;
}
inline void write (int x) {
	if (x < 0) x = -x, putchar ('-');
	if (x >= 10) write (x / 10);
	putchar (x % 10 + '0');
}
int n, m;
int a[70][70];
int f[1005][70][70], g[1005][70][70];

int ans[20005][70];
signed main () {
//	freopen ("Para.in", "r", stdin);
//	freopen ("1.out", "w", stdout);
	n = read(), m = read();
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) a[i][j] = read();
	
	for(int i = 0; i < n; i++) f[0][i][i] = g[0][i][i] = 1;
	ll B = sqrt(m) + 1;
	for(int i = 1; i <= B; i++) for(int j = 0; j < n; j++) for(int k = 0; k < n; k++) for(int jj = 0; jj < n; jj++) Add(f[i][k][j], f[i-1][k][jj] * a[jj][j] % mod);
	for(int i = 1; i <= B; i++) for(int j = 0; j < n; j++) for(int k = 0; k < n; k++) for(int jj = 0; jj < n; jj++) Add(g[i][j][k], g[i-1][jj][k] * a[j][jj] % mod);
	
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) a[i][j] = f[B][i][j];
	memset(f, 0, sizeof f);
	for(int i = 0; i < n; i++) f[0][i][i] = 1;
	
	for(int i = 1; i <= B; i++) for(int j = 0; j < n; j++) for(int k = 0; k < n; k++) for(int jj = 0; jj < n; jj++) Add(f[i][k][j], f[i-1][k][jj] * a[jj][j] % mod);
	
	for(int x = 0; x <= B; x++) for(int k = 0; k < n; k++) for(int j = 0; (1 << j) < n; j++) for(int i = 0; i < n; i++) if(i >> j & 1) Add(f[x][i ^ (1 << j)][k], f[x][i][k]), Add(g[x][k][i ^ (1 << j)], g[x][k][i]);
	for(int d = 1; d <= m; d++) {
		int x = d / B, y = d - x * B;
		for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) Add(ans[d][i], f[x][i][k] * g[y][k][i] % mod);
	}
	
	for(int i = 0; i < n; i++) {
		poly g;
		g.resize(m + 1);
		g[0] = 1;
		for(ll j = 1; j <= m; j++) g[j] = dec(0, ans[j][i]);
		g = g.Inv();
		for(ll j = 1; j <= m; j++) ans[j][i] = g[j];
	}
	for(int t = 1; t <= m; t++) for(int j = 0; (1 << j) < n; j++) for(int i = 0; i < n; i++) if(i >> j & 1) Dec(ans[t][i ^ (1 << j)], ans[t][i]);
	int Ans = 0;
	for(int i = 1; i <= m; i++) for(int j = 0; j < n; j++) Ans ^= ans[i][j];//, printf("?? %lld %lld %lld\n", i, j, ans[i][j]);
	write(Ans), putchar('\n');
    return 0;
}
/*
*/

詳細信息

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 24ms
memory: 64308kb

input:

4 20
53674686 128460215 363694167 120271218
578912024 941426068 993595265 587468617
731649477 694107878 355552389 226535630
99325151 243772822 66420647 578481511

output:

588479706

result:

ok 1 number(s): "588479706"

Test #2:

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

input:

16 2000
315391385 70546806 184749201 528239002 741286788 146241680 165603053 41114445 572984599 227056916 305263327 980588113 367160763 155832001 212041467 995977944
491801679 569182307 859668874 327536237 778338213 762819679 11238663 728941676 307395331 62905643 662320291 849065607 550529700 282249...

output:

808196376

result:

ok 1 number(s): "808196376"

Test #3:

score: 0
Accepted
time: 29ms
memory: 65424kb

input:

8 100
681016308 947980964 71683807 222166989 633911431 994577572 50784856 298319502
40710797 455891003 503120116 503880841 988981490 34455718 806388934 589433205
327802386 18831411 193642391 916990555 375690304 69587142 72759137 6300182
494361154 892873815 205578968 352463324 154675154 301940078 523...

output:

625872426

result:

ok 1 number(s): "625872426"

Test #4:

score: 0
Accepted
time: 27ms
memory: 65452kb

input:

8 123
42141734 119453053 338794033 469472517 896943474 997318263 463090940 539752993
498132275 425586204 10331275 799002923 314685843 769975525 214134323 412654359
293167153 22579811 116636410 566990382 581484192 102682042 582694943 865977998
241553124 317584926 931548048 157765288 390446073 1855087...

output:

365380190

result:

ok 1 number(s): "365380190"

Test #5:

score: 0
Accepted
time: 22ms
memory: 65268kb

input:

16 5
157021390 252497011 468873864 892465002 392136945 867902344 634574021 416807938 771790989 545264217 666014055 30318904 997001481 92030626 658131204 234369349
43307846 497204529 460391395 44581806 107577365 871932521 470029953 149175762 27325626 819200707 411063821 891562850 191893364 790514504 ...

output:

85280541

result:

ok 1 number(s): "85280541"

Test #6:

score: 0
Accepted
time: 23ms
memory: 64584kb

input:

16 1
905581565 803883371 222387735 113243327 962846914 170270764 908119897 643672711 951948550 443390704 345262472 285268917 716661556 492805236 516049466 646586240
717205802 712046214 204789431 592343665 608834746 958679690 85385338 156417764 101326890 777140727 427162035 294565259 28802739 8285324...

output:

17305742

result:

ok 1 number(s): "17305742"

Test #7:

score: 0
Accepted
time: 56ms
memory: 66972kb

input:

16 1889
291592828 902768692 198687222 265645285 254788066 848949408 683064381 678157787 474168528 862103895 415053306 909831425 935938735 21752343 43155905 228914827
364068446 273045932 507519451 796711939 166902447 72879739 611394755 843648198 3964648 56114938 95672745 864116356 549815108 867090999...

output:

1000245565

result:

ok 1 number(s): "1000245565"

Test #8:

score: 0
Accepted
time: 50ms
memory: 66720kb

input:

16 1538
462407755 549251277 397837861 275994586 415476819 756356324 34904944 520197632 412094442 727727503 875452091 754767133 581156730 826224521 313192343 54965862
57572067 254043810 294905166 657621093 929264117 362049084 974381916 63383415 506826999 577114576 490305008 452699725 907812132 906157...

output:

141964726

result:

ok 1 number(s): "141964726"

Test #9:

score: 0
Accepted
time: 45ms
memory: 65972kb

input:

16 1234
344382827 816941878 819839652 144225696 371171347 966266104 884665589 169825013 765791827 40228758 652684236 893817865 725991829 758836428 252384190 124837650
871491255 654941544 640590098 175202200 748370570 752347597 100539461 38637304 762795606 419148404 537316998 134122726 29051987 94573...

output:

19530996

result:

ok 1 number(s): "19530996"

Test #10:

score: 0
Accepted
time: 46ms
memory: 67032kb

input:

16 1999
12949977 632196974 390885234 944145973 121838884 405002460 237547721 700781753 461518861 947091309 820524334 253274565 296734976 893264350 934506037 438497421
658309595 402128381 470963494 423098778 698061936 170098990 137416574 542917450 696307461 580493544 236741484 982061646 908169428 985...

output:

162533703

result:

ok 1 number(s): "162533703"

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 15
Accepted
time: 30ms
memory: 65376kb

input:

16 15
314601745 720760464 91785724 114888585 26836821 376536402 313090153 826230415 346734724 333924807 863460032 368340108 245372320 36392298 788713548 515760462
298875827 24627338 31898175 284907313 548032583 57534741 75385967 913412369 336300896 498149570 737179693 974479561 859718707 297256598 3...

output:

407303714

result:

ok 1 number(s): "407303714"

Test #12:

score: 0
Accepted
time: 421ms
memory: 74776kb

input:

32 10000
761517608 533611175 252111851 40247028 679296910 479128630 648063750 922719043 15905318 450067426 673017960 429004044 149250097 455699505 781122302 247622532 8960746 139853274 715899414 341830718 10123661 958972771 98773785 523065821 813633478 25481882 318862349 244623710 119270736 59145995...

output:

807722853

result:

ok 1 number(s): "807722853"

Test #13:

score: 0
Accepted
time: 91ms
memory: 66992kb

input:

32 1357
321954818 61258364 443769502 627726057 577984222 31067437 471030721 456785680 899823567 428940817 921238219 804535628 668867012 78750695 982200891 387928209 411806976 435420237 876420011 945079305 839002423 438946076 548079677 475785723 548284753 712759055 517364800 735798756 948763903 81555...

output:

512286475

result:

ok 1 number(s): "512286475"

Test #14:

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

input:

32 1024
934392183 278139969 946579473 404491033 120629005 736209902 839111219 891890038 147168834 726438981 379448297 349343648 888543489 398955818 91414843 460378381 720916808 485962846 92217516 88982970 894439810 677159472 350046012 746702922 908587590 702246537 685838472 411925085 380074941 68975...

output:

337041603

result:

ok 1 number(s): "337041603"

Test #15:

score: 0
Accepted
time: 36ms
memory: 65416kb

input:

32 8
837464609 53515561 24494092 954419559 538819329 215817794 44847447 557152755 311569172 386498461 978050662 953219718 194456091 857047823 966804131 200271001 662278544 873214841 562896362 46085582 976480847 935118668 490627953 405249905 90676824 444770133 132087962 554258181 870642467 293836206 ...

output:

386491936

result:

ok 1 number(s): "386491936"

Test #16:

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

input:

32 4329
574037069 402057855 471584436 536257468 210791614 335509873 350594515 331998672 619093586 234310158 72138003 640585660 992343322 649961161 435859755 715691054 54901302 186990850 897062441 60958965 397463946 94834577 114023959 124090510 486344869 100418631 317644038 885906296 414631710 391332...

output:

425277770

result:

ok 1 number(s): "425277770"

Test #17:

score: 0
Accepted
time: 235ms
memory: 69596kb

input:

32 5524
730589344 194589124 525976166 64781638 879967066 492669642 53399017 620041854 368209111 251911426 86983444 514701073 959368417 29776594 495435365 25651998 315331723 488137423 120545591 185405324 348174064 360725983 37633884 719538793 105796816 12328479 874514161 464366183 860724464 139507398...

output:

623220909

result:

ok 1 number(s): "623220909"

Test #18:

score: 0
Accepted
time: 240ms
memory: 71288kb

input:

32 6257
880226659 330483877 423871717 175591073 127434348 611932518 366082571 563944372 477260589 992476913 802786709 328672404 193010567 661448005 520335137 82252515 944511007 58280839 388765258 670185858 885749417 709317639 620145777 529001942 892659121 546946701 99505158 979528505 595220956 34078...

output:

128478743

result:

ok 1 number(s): "128478743"

Test #19:

score: 0
Accepted
time: 441ms
memory: 73436kb

input:

32 8735
245435032 953640748 241783478 331441343 87510154 136596437 138578112 967064517 314673925 833034581 212111516 834025854 882925777 582922306 314475903 638063273 171513018 434981897 367101943 378334119 3056692 809430030 4804474 70065939 593225082 236099112 574535154 887825463 386722056 88252308...

output:

405695280

result:

ok 1 number(s): "405695280"

Test #20:

score: 0
Accepted
time: 437ms
memory: 75252kb

input:

32 9999
53543452 138507371 910144777 42784030 948244479 58617879 66647526 302774961 733742236 400462082 844467039 406358748 119257486 496264675 263552002 80384519 286161937 524071888 460654447 2670531 971129382 108374548 371716781 826606146 332228173 362583611 352144250 932076012 344642595 435600511...

output:

800761072

result:

ok 1 number(s): "800761072"

Subtask #3:

score: 35
Accepted

Test #21:

score: 35
Accepted
time: 389ms
memory: 82264kb

input:

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

output:

97601915

result:

ok 1 number(s): "97601915"

Test #22:

score: 0
Accepted
time: 2171ms
memory: 86168kb

input:

64 20000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30 33 32 35 34 37 36 39 38...

output:

709377491

result:

ok 1 number(s): "709377491"

Test #23:

score: 0
Accepted
time: 859ms
memory: 83260kb

input:

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

output:

815101292

result:

ok 1 number(s): "815101292"

Test #24:

score: 0
Accepted
time: 42ms
memory: 65344kb

input:

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

output:

929945084

result:

ok 1 number(s): "929945084"

Test #25:

score: 0
Accepted
time: 38ms
memory: 64676kb

input:

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

output:

4544

result:

ok 1 number(s): "4544"

Test #26:

score: 0
Accepted
time: 829ms
memory: 83068kb

input:

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

output:

779867277

result:

ok 1 number(s): "779867277"

Test #27:

score: 0
Accepted
time: 844ms
memory: 81528kb

input:

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

output:

81759333

result:

ok 1 number(s): "81759333"

Test #28:

score: 0
Accepted
time: 410ms
memory: 76812kb

input:

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

output:

274188773

result:

ok 1 number(s): "274188773"

Test #29:

score: 0
Accepted
time: 1265ms
memory: 78216kb

input:

64 12345
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30 33 32 35 34 37 36 39 38...

output:

138978484

result:

ok 1 number(s): "138978484"

Test #30:

score: 0
Accepted
time: 1355ms
memory: 79972kb

input:

64 15000
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
1 0 3 2 5 4 7 6 9 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30 33 32 35 34 37 36 39 38...

output:

348469384

result:

ok 1 number(s): "348469384"

Subtask #4:

score: 35
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #31:

score: 35
Accepted
time: 49ms
memory: 64588kb

input:

64 10
330733194 211925460 697333428 773824183 152865381 800966232 558518744 174801774 428804887 14681848 645105345 678951716 691845643 371836272 347386373 967242767 823512095 277748366 957700075 4989366 705431076 554782390 21088496 577619322 5572962 369756766 851924547 134432521 245788690 811718290 ...

output:

244344009

result:

ok 1 number(s): "244344009"

Test #32:

score: 0
Accepted
time: 2165ms
memory: 86176kb

input:

64 20000
625297172 486817894 40178069 41872987 190096117 303418665 398493423 16242434 870358798 404601960 888960880 329383688 420993225 188527583 733887402 224276641 166330628 308684892 59806695 302087000 357193872 614415939 312380579 990919818 32308404 373160458 569750285 151222248 856097708 774553...

output:

823474169

result:

ok 1 number(s): "823474169"

Test #33:

score: 0
Accepted
time: 31ms
memory: 65332kb

input:

64 1
828609278 204824288 45986081 79397261 354091244 540235288 40529048 948545848 153074738 24593900 608561750 290951266 966768186 237193240 351803118 143177025 663417826 791233898 621495976 602954589 332597755 495900230 170498561 521376788 850258381 799666978 299971112 476813079 651230609 778269963...

output:

931742973

result:

ok 1 number(s): "931742973"

Test #34:

score: 0
Accepted
time: 2066ms
memory: 82756kb

input:

64 16384
386948977 331928556 451656591 592983139 689588083 413677016 579458906 782753538 11582797 168744161 706190827 37254560 302121577 236755648 490490839 527124083 637496229 365215814 419497317 336913667 94002642 571190742 454146834 599405230 755407416 289975270 955964941 953399077 117168912 8790...

output:

761669331

result:

ok 1 number(s): "761669331"

Test #35:

score: 0
Accepted
time: 836ms
memory: 83212kb

input:

32 20000
79526884 593205496 68785659 167032633 85548538 421389720 254382619 751199436 4296296 447099861 938025345 991472351 845487768 370523496 763351232 47032228 745812840 73403170 351704098 205045418 65044905 780752230 871967779 811639112 794794659 988296363 672455154 490481459 791054479 40215035 ...

output:

52640439

result:

ok 1 number(s): "52640439"

Test #36:

score: 0
Accepted
time: 1353ms
memory: 80580kb

input:

64 15000
258500481 8450747 738547991 819693679 861460508 175852040 630324555 562931391 526763823 403428370 782102246 647030958 834533924 156507794 22064762 457572466 491866585 155616857 926164050 662857107 353541919 317233098 628294887 684350831 62242621 51396443 656082284 597054391 812738671 388385...

output:

995262208

result:

ok 1 number(s): "995262208"

Test #37:

score: 0
Accepted
time: 2238ms
memory: 85052kb

input:

64 19000
924133364 437550024 716347268 24612677 156734115 351288777 741415948 162279561 418823242 849573638 376428155 158376428 203471443 458065210 655660900 606627236 499529116 31593782 220862223 161891129 148465398 694518618 408639992 527454217 975784 841944096 808805713 838780869 312228334 791137...

output:

668805927

result:

ok 1 number(s): "668805927"

Test #38:

score: 0
Accepted
time: 854ms
memory: 83772kb

input:

32 20000
650262631 2577619 828417521 437544475 659954986 660963721 986778318 969542227 445055334 356182522 104926736 877734698 780388994 893828067 425250893 889887446 641429855 41776146 723507660 868937951 77627086 132333290 323157770 504795811 73881619 768518372 21927222 140938195 21420908 25432039...

output:

422060200

result:

ok 1 number(s): "422060200"

Test #39:

score: 0
Accepted
time: 849ms
memory: 83712kb

input:

32 20000
32325892 759968663 374085133 33246288 907433036 29526776 431571710 991002950 707499820 119557943 360040565 13188601 777790222 755302925 287947527 50555042 664282320 467956809 98375419 194227401 986831171 281159246 222078158 587203530 4053423 636909717 416624047 725683543 51492940 677981223 ...

output:

202303214

result:

ok 1 number(s): "202303214"

Test #40:

score: 0
Accepted
time: 2237ms
memory: 85124kb

input:

64 20000
160972448 795946842 263686952 425877382 22388846 866144617 488710190 81380664 105898483 696652148 422201307 482426313 179622042 625198391 226101953 813417327 360009025 97194368 890951978 467441074 763611321 975293106 733409170 812237296 219385930 245245254 618367784 647723994 484207149 3628...

output:

500517361

result:

ok 1 number(s): "500517361"