QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140028#1241. RaidXY_ElevenTL 2355ms162988kbC++234.9kb2023-08-14 23:31:322023-08-14 23:31:33

Judging History

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

  • [2023-08-14 23:31:33]
  • 评测
  • 测评结果:TL
  • 用时:2355ms
  • 内存:162988kb
  • [2023-08-14 23:31:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define pii pair<int,int>
#define pil pair<int,LL>
#define mii map<int,int>
#define miig map<int,int,greater<int> >
#define mil map<int,LL>
#define in128 __int128
#define cint const int
#define cLL const LL
#define cDB const DB
#define cchar const char
#define invoid inline void
#define inLL inline LL
#define inlint inline int
#define inbool inline bool
#define inl128 inline __int128
#define inDB inline double
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) ((LL)(e))
#define pb push_back
#define ft first
#define sc second
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define x0 x00
#define y1 y11
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define fout fflush(stdout)
invoid input(int &N_,int A_[],bool F_)
{
    if(F_) inint(N_);
    For(i,1,N_) inint(A_[i]);
}
template <typename Type>
inline Type md(Type w1,const Type w2)
{
    w1%=w2; if(w1<0) w1+=w2;
    return w1;
}
template <typename Type>
invoid add(Type &w1,const Type w2,const Type M_)
{ w1=md(w1+w2,M_); }
invoid mul(LL &w1,cLL w2,cLL M_)
{ w1=md(w1*w2,M_); }
inLL gcd(LL X_,LL Y_)
{
    LL R_=X_%Y_;
    while(R_)
    { X_=Y_; Y_=R_; R_=X_%Y_; }
    return Y_;
}
invoid ex_gcd(LL &X_,LL &Y_,LL A_,LL B_)
{
    if(!B_)
    {
        X_=1ll; Y_=0ll;
        return ;
    }
    ex_gcd(Y_,X_,B_,A_%B_);
    X_=md(X_,B_); Y_=(1ll-X_*A_)/B_;
}
inLL inv(LL A_,LL B_)
{
    LL X_=0ll,Y_=0ll;
    ex_gcd(X_,Y_,A_,B_);
    return X_;
}
inLL pw(LL X_,LL Y_,LL M_)
{
    LL S_=1ll;
    while(Y_)
    {
        if(Y_&1) mul(S_,X_,M_);
        Y_>>=1;
        mul(X_,X_,M_);
    }
    return S_;
}
template <typename Type>
invoid get_min(Type &w1,const Type w2)
{ if(w2<w1) w1=w2; }
template <typename Type>
invoid get_max(Type &w1,const Type w2)
{ if(w2>w1) w1=w2; }
//inLL A(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*d2[N_-M_],mod):0ll); }
//inLL C(cint N_,cint M_)
//{ return (N_>=M_?md(d1[N_]*md(d2[M_]*d2[N_-M_],mod),mod):0ll); }
//mt19937 gen(time(NULL));
//mt19937_64 gen(time(NULL));
//cLL base[]={166686661,188868881},mod[]={1686688681,1666868881};
cLL base[]={166686661,188868881},mod[]={1686688681,1666868881},inter=1861;
//cLL mod[]={1e9+7,1e9+9,1e9+21,1e9+33};
//cLL mod=998244353;
cint N=50;
int n;
int a[N],rk[N][N];
struct hashfun
{
    size_t operator() (const LL &w) const
    {
        return hash<LL>()(w);
    }
};
unordered_map <LL,pair<int,LL>,hashfun> dp[N];
unordered_map <LL,vector<int>,hashfun> mp;
vector <int> c,t;
inLL f()
{
    LL d[2]={0ll,0ll},z;
    For(k,0,1)
        for(auto i:t)
            d[k]=(d[k]*base[k]+ll(i)^inter)%mod[k];
    z=d[0]^(d[1]<<31);
    mp[z]=t;
    return z;
}
int main()
{
    inint(n);
    For(i,1,n) inint(a[i]),a[i]=n-a[i]+1;
//    n=40;
//    For(i,1,n) a[i]=i,swap(a[i],a[rand()%i+1]);
    For(i,1,n) For(j,i,n) For(k,j+1,n)
        rk[i][j]+=(a[k]<a[j]);
    For(i,0,n) t.pb(0);
    dp[0][f()]={0ll,1ll};
    int ans=1e9;
    LL sum=0ll;
    For(v,1,n)
    {
//        debug(v);
        for(auto [x,g]:dp[v-1])
        {
//            puts("start");
            t=mp[x];
            For(i,n+2-(int)t.size(),n)
            {
//                debug(i);
                c=t; t.clear();
                int s=g.ft+c[rk[i][i]];
                For_(j,0,rk[i][i])
                    t.pb(c[j]),
                    s+=c[j];
//                debug(s);
                t.pb(c[rk[i][i]]+c[rk[i][i]+1]+1);
                int siz=(int)c.size();
                For_(j,rk[i][i]+2,siz)
                    t.pb(c[j]);
                LL d=f();
//                debug(d);
//                debug(t.size());
                if(dp[v].find(d)==dp[v].end()||
                   dp[v][d].ft>s)
                    dp[v][d]={s,g.sc};
                else if(dp[v][d].ft==s)
                    dp[v][d].sc+=g.sc;
                t[rk[i][i]]--;
            }
        }
        ans=1e9;
        sum=0ll;
//        for(auto [x,g]:dp[v])
//            printf("# %d %lld\n",g.ft,g.sc);
        for(auto [x,g]:dp[v])
            if(g.ft<ans) ans=g.ft,sum=g.sc;
            else if(g.ft==ans) sum+=g.sc;
        printf("%d %lld\n",ans,sum);
    }
    return 0;
}
/*

*/

詳細信息

Test #1:

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

input:

5
5 3 1 4 2

output:

0 5
0 3
1 2
3 1
7 1

result:

ok 10 numbers

Test #2:

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

input:

1
1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #3:

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

input:

2
1 2

output:

0 2
0 1

result:

ok 4 number(s): "0 2 0 1"

Test #4:

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

input:

3
2 1 3

output:

0 3
0 2
1 1

result:

ok 6 numbers

Test #5:

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

input:

4
3 1 2 4

output:

0 4
0 4
0 1
2 1

result:

ok 8 numbers

Test #6:

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

input:

5
1 2 5 4 3

output:

0 5
0 7
0 3
1 3
3 1

result:

ok 10 numbers

Test #7:

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

input:

18
4 11 17 12 2 8 9 16 14 1 15 3 10 7 6 13 5 18

output:

0 18
0 78
0 132
0 104
0 38
0 5
1 2
3 6
5 1
9 8
12 1
17 1
25 4
33 5
41 2
50 1
61 1
75 1

result:

ok 36 numbers

Test #8:

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

input:

18
14 1 15 10 17 2 3 9 16 6 11 7 13 18 5 12 4 8

output:

0 18
0 76
0 141
0 139
0 78
0 24
0 3
1 2
3 3
5 1
10 3
15 1
22 1
30 1
40 1
52 3
64 2
77 1

result:

ok 36 numbers

Test #9:

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

input:

18
18 10 6 12 3 8 1 7 9 11 13 5 2 16 17 4 14 15

output:

0 18
0 86
0 190
0 223
0 154
0 60
0 10
1 12
2 2
4 4
6 1
9 1
15 3
21 1
29 1
39 1
50 1
67 1

result:

ok 36 numbers

Test #10:

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

input:

18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

output:

0 18
0 153
0 816
0 3060
0 8568
0 18564
0 31824
0 43758
0 48620
0 43758
0 31824
0 18564
0 8568
0 3060
0 816
0 153
0 18
0 1

result:

ok 36 numbers

Test #11:

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

input:

18
18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 18
1 153
3 816
6 3060
10 8568
15 18564
21 31824
28 43758
36 48620
45 43758
55 31824
66 18564
78 8568
91 3060
105 816
120 153
136 18
153 1

result:

ok 36 numbers

Test #12:

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

input:

18
4 6 15 10 1 8 17 12 13 2 18 7 3 16 11 5 14 9

output:

0 18
0 85
0 150
0 115
0 42
0 6
1 9
2 3
4 1
7 1
11 2
16 2
22 2
29 2
37 2
46 2
56 1
68 1

result:

ok 36 numbers

Test #13:

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

input:

18
9 14 4 7 16 11 2 17 12 6 13 18 10 15 5 8 3 1

output:

0 18
0 64
0 89
0 55
0 16
0 2
1 1
3 1
6 1
10 2
15 5
20 1
27 1
35 1
45 1
57 1
72 1
89 1

result:

ok 36 numbers

Test #14:

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

input:

18
5 9 13 1 17 3 14 2 10 18 4 12 7 16 6 11 15 8

output:

0 18
0 88
0 163
0 127
0 43
0 4
1 4
2 1
4 1
7 1
11 2
15 1
20 1
27 1
35 3
43 1
53 1
65 1

result:

ok 36 numbers

Test #15:

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

input:

18
17 7 14 3 10 15 6 16 1 13 9 4 18 2 11 5 12 8

output:

0 18
0 67
0 83
0 36
0 4
1 2
3 2
6 5
9 2
13 3
18 3
24 3
31 3
39 3
48 2
58 1
70 1
86 1

result:

ok 36 numbers

Test #16:

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

input:

18
2 1 3 4 6 5 7 8 10 9 12 11 14 13 16 15 17 18

output:

0 18
0 147
0 720
0 2355
0 5418
0 8989
0 10836
0 9420
0 5760
0 2352
0 576
0 64
1 192
2 240
3 160
4 60
5 12
6 1

result:

ok 36 numbers

Test #17:

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

input:

18
1 10 2 11 3 12 4 13 5 14 6 15 7 16 8 17 9 18

output:

0 18
0 117
0 408
0 882
0 1260
0 1218
0 792
0 333
0 82
0 9
1 8
3 7
6 6
10 5
15 4
21 3
28 2
36 1

result:

ok 36 numbers

Test #18:

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

input:

18
17 15 13 11 9 7 5 3 1 18 16 14 12 10 8 6 4 2

output:

0 18
0 45
1 240
2 210
4 504
6 210
9 240
12 45
16 20
20 1
26 2
33 1
42 2
52 1
64 2
77 1
92 2
108 1

result:

ok 36 numbers

Test #19:

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

input:

18
9 14 10 15 11 16 12 17 13 18 2 1 4 3 6 5 8 7

output:

0 18
0 59
0 92
0 71
0 26
0 5
1 4
3 3
6 2
10 1
20 8
30 24
40 32
50 16
61 36
71 3
82 2
94 1

result:

ok 36 numbers

Test #20:

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

input:

18
11 15 12 16 13 17 14 18 2 1 4 3 6 5 8 7 10 9

output:

0 18
0 62
0 108
0 97
0 36
1 83
2 80
3 40
4 10
5 1
15 8
25 22
35 28
45 17
55 4
66 3
78 2
91 1

result:

ok 36 numbers

Test #21:

score: 0
Accepted
time: 14ms
memory: 6344kb

input:

23
9 4 12 20 21 23 1 8 6 10 5 17 15 18 14 3 2 19 13 7 16 22 11

output:

0 23
0 135
0 324
0 384
0 235
0 70
0 8
1 12
2 6
3 1
6 4
9 4
12 1
17 4
22 4
27 1
36 1
46 1
57 2
69 1
85 2
101 1
118 1

result:

ok 46 numbers

Test #22:

score: 0
Accepted
time: 4ms
memory: 4492kb

input:

23
13 20 19 16 7 15 5 6 23 9 12 4 14 11 17 10 2 21 18 3 22 8 1

output:

0 23
0 105
0 204
0 237
0 171
0 75
0 19
0 2
1 1
3 2
5 1
9 1
14 1
22 2
30 1
40 2
50 1
63 3
77 4
92 3
108 1
126 1
148 1

result:

ok 46 numbers

Test #23:

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

input:

23
9 5 12 7 6 3 10 2 4 8 23 1 14 11 21 18 20 22 17 15 13 19 16

output:

0 23
0 174
0 515
0 714
0 486
0 146
0 12
1 16
2 7
3 1
5 2
8 5
11 3
15 7
19 4
24 8
29 4
35 3
42 4
49 1
57 1
67 1
79 1

result:

ok 46 numbers

Test #24:

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

input:

23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

output:

0 23
0 253
0 1771
0 8855
0 33649
0 100947
0 245157
0 490314
0 817190
0 1144066
0 1352078
0 1352078
0 1144066
0 817190
0 490314
0 245157
0 100947
0 33649
0 8855
0 1771
0 253
0 23
0 1

result:

ok 46 numbers

Test #25:

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

input:

23
23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 23
1 253
3 1771
6 8855
10 33649
15 100947
21 245157
28 490314
36 817190
45 1144066
55 1352078
66 1352078
78 1144066
91 817190
105 490314
120 245157
136 100947
153 33649
171 8855
190 1771
210 253
231 23
253 1

result:

ok 46 numbers

Test #26:

score: 0
Accepted
time: 14ms
memory: 7452kb

input:

23
5 1 7 11 14 19 23 16 4 2 8 10 13 20 22 17 15 3 9 21 18 6 12

output:

0 23
0 149
0 422
0 622
0 501
0 210
0 36
1 70
2 40
3 5
5 4
8 8
11 4
15 9
19 4
24 3
30 1
39 3
48 1
59 1
73 2
88 2
104 1

result:

ok 46 numbers

Test #27:

score: 0
Accepted
time: 16ms
memory: 6696kb

input:

23
12 18 6 21 3 9 15 23 20 16 14 7 10 4 1 19 13 22 17 8 11 5 2

output:

0 23
0 104
0 164
0 109
0 30
0 2
1 1
3 6
5 3
8 7
11 1
16 3
21 1
28 1
37 4
46 1
57 4
68 1
81 1
95 1
110 1
128 1
149 1

result:

ok 46 numbers

Test #28:

score: 0
Accepted
time: 11ms
memory: 5756kb

input:

23
6 9 17 2 10 21 3 11 19 14 4 23 7 12 18 1 13 22 5 15 20 8 16

output:

0 23
0 148
0 407
0 578
0 454
0 197
0 44
0 4
1 2
3 3
5 1
8 4
11 4
14 1
18 1
23 1
31 2
39 1
50 1
62 1
76 4
90 2
105 1

result:

ok 46 numbers

Test #29:

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

input:

23
23 15 6 19 12 2 22 14 4 10 20 1 18 13 7 17 11 3 16 9 5 21 8

output:

0 23
0 107
0 178
0 124
0 36
0 4
1 3
3 7
5 5
7 1
11 1
16 3
22 7
28 2
35 1
44 1
55 3
66 1
78 1
92 1
108 2
124 1
146 1

result:

ok 46 numbers

Test #30:

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

input:

23
23 22 20 21 19 18 16 17 15 14 12 13 11 10 9 8 6 7 5 4 2 3 1

output:

0 23
0 5
2 105
4 10
8 190
12 10
18 170
24 5
32 75
40 1
50 13
61 78
73 286
86 715
100 1287
115 1716
131 1716
148 1287
166 715
185 286
205 78
226 13
248 1

result:

ok 46 numbers

Test #31:

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

input:

23
1 13 2 14 3 15 4 16 5 17 6 18 7 19 8 20 9 21 10 22 11 23 12

output:

0 23
0 187
0 825
0 2310
0 4422
0 6006
0 5874
0 4125
0 2035
0 671
0 133
0 12
1 11
3 10
6 9
10 8
15 7
21 6
28 5
36 4
45 3
55 2
66 1

result:

ok 46 numbers

Test #32:

score: 0
Accepted
time: 12ms
memory: 6268kb

input:

23
23 21 19 17 15 13 11 9 7 5 3 1 22 20 18 16 14 12 10 8 6 4 2

output:

0 23
0 66
1 440
2 495
4 1584
6 924
9 1584
12 495
16 440
20 66
25 24
30 1
37 2
45 1
55 2
66 1
79 2
93 1
109 2
126 1
145 2
165 1
187 1

result:

ok 46 numbers

Test #33:

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

input:

23
12 18 13 19 14 20 15 21 16 22 17 23 2 1 4 3 6 5 8 7 10 9 11

output:

0 23
0 101
0 230
0 295
0 208
0 69
0 6
1 5
3 44
4 10
5 1
15 1
27 62
38 110
49 135
60 96
71 37
82 6
94 5
107 4
121 3
136 2
152 1

result:

ok 46 numbers

Test #34:

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

input:

23
14 19 15 20 16 21 17 22 18 23 2 1 4 3 6 5 8 7 10 9 12 11 13

output:

0 23
0 107
0 280
0 455
0 458
0 261
0 64
1 192
2 240
3 160
4 60
5 12
6 1
19 10
32 35
45 60
58 55
71 26
84 5
98 4
113 3
129 2
146 1

result:

ok 46 numbers

Test #35:

score: 0
Accepted
time: 19ms
memory: 6556kb

input:

26
7 2 16 21 23 4 1 5 12 24 13 14 8 18 10 3 11 6 22 17 19 20 9 15 25 26

output:

0 26
0 210
0 814
0 1800
0 2503
0 2326
0 1495
0 667
0 199
0 36
0 3
1 1
3 1
6 2
9 1
13 3
17 3
21 1
26 1
34 1
43 1
53 1
66 1
80 1
97 1
115 1

result:

ok 52 numbers

Test #36:

score: 0
Accepted
time: 17ms
memory: 6308kb

input:

26
23 19 21 18 2 4 7 8 5 9 16 12 11 25 20 17 10 26 24 6 15 3 14 1 22 13

output:

0 26
0 161
0 478
0 865
0 947
0 600
0 201
0 27
1 71
2 49
3 9
5 15
7 7
9 1
13 1
19 5
25 3
32 1
41 1
53 1
68 2
84 2
101 1
120 1
141 1
164 1

result:

ok 52 numbers

Test #37:

score: 0
Accepted
time: 9ms
memory: 5308kb

input:

26
5 10 2 17 19 7 8 6 20 11 1 3 22 4 23 14 24 16 9 12 15 25 26 18 21 13

output:

0 26
0 219
0 809
0 1570
0 1760
0 1185
0 477
0 112
0 15
0 1
2 2
4 1
7 1
10 2
13 1
18 3
23 1
29 2
35 1
42 1
50 2
58 1
68 2
79 1
92 1
106 1

result:

ok 52 numbers

Test #38:

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

input:

26
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

output:

0 26
0 325
0 2600
0 14950
0 65780
0 230230
0 657800
0 1562275
0 3124550
0 5311735
0 7726160
0 9657700
0 10400600
0 9657700
0 7726160
0 5311735
0 3124550
0 1562275
0 657800
0 230230
0 65780
0 14950
0 2600
0 325
0 26
0 1

result:

ok 52 numbers

Test #39:

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

input:

26
26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

0 26
1 325
3 2600
6 14950
10 65780
15 230230
21 657800
28 1562275
36 3124550
45 5311735
55 7726160
66 9657700
78 10400600
91 9657700
105 7726160
120 5311735
136 3124550
153 1562275
171 657800
190 230230
210 65780
231 14950
253 2600
276 325
300 26
325 1

result:

ok 52 numbers

Test #40:

score: 0
Accepted
time: 109ms
memory: 18392kb

input:

26
7 2 9 11 4 14 16 26 24 18 21 1 5 12 19 22 25 8 15 3 10 17 23 6 20 13

output:

0 26
0 188
0 595
0 999
0 999
0 637
0 262
0 66
0 8
1 12
2 6
3 1
6 1
10 2
14 1
19 1
25 1
32 1
41 1
51 2
61 1
72 1
86 1
102 2
119 2
137 1

result:

ok 52 numbers

Test #41:

score: 0
Accepted
time: 51ms
memory: 10368kb

input:

26
14 7 20 11 23 3 17 25 5 9 21 18 16 1 13 24 19 26 22 15 10 4 12 8 2 6

output:

0 26
0 139
0 273
0 254
0 105
0 14
1 21
2 6
4 11
6 6
8 1
11 1
15 4
19 1
25 1
33 1
43 4
53 2
64 1
77 1
91 1
106 1
124 1
143 1
163 1
186 1

result:

ok 52 numbers

Test #42:

score: 0
Accepted
time: 24ms
memory: 7520kb

input:

26
2 13 21 1 19 6 25 12 3 23 7 17 4 26 11 14 20 5 15 24 8 16 22 9 18 10

output:

0 26
0 184
0 560
0 885
0 793
0 408
0 110
0 12
1 20
2 11
3 2
5 1
8 4
11 1
15 1
20 1
27 4
34 1
43 2
53 3
64 2
76 1
90 1
105 1
123 2
141 1

result:

ok 52 numbers

Test #43:

score: 0
Accepted
time: 21ms
memory: 8264kb

input:

26
14 26 7 22 15 3 24 10 25 5 12 23 1 19 8 21 6 18 13 2 20 11 4 17 9 16

output:

0 26
0 138
0 238
0 156
0 33
1 66
2 33
3 1
5 1
8 6
11 2
15 3
19 1
24 1
31 3
38 1
47 2
57 2
68 2
80 1
94 1
109 1
126 1
144 1
163 1
187 1

result:

ok 52 numbers

Test #44:

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

input:

26
1 25 13 19 7 16 10 4 22 23 2 14 8 11 17 26 5 20 3 15 18 21 12 9 24 6

output:

0 26
0 171
0 495
0 765
0 690
0 373
0 114
0 15
1 25
2 10
4 23
6 15
8 3
11 1
16 1
22 1
29 1
38 5
47 2
58 5
69 1
82 1
97 3
112 1
131 1
154 1

result:

ok 52 numbers

Test #45:

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

input:

26
20 24 2 12 16 14 8 22 26 10 6 18 4 13 7 25 5 21 19 3 11 15 17 9 1 23

output:

0 26
0 146
0 320
0 335
0 176
0 45
0 5
1 3
3 4
6 16
9 15
12 2
16 1
21 1
28 11
34 2
41 1
50 2
60 1
72 2
85 1
100 2
116 1
134 1
155 1
179 1

result:

ok 52 numbers

Test #46:

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

input:

26
2 1 3 4 5 6 8 7 9 10 12 11 13 14 16 15 17 18 19 20 22 21 24 23 26 25

output:

0 26
0 318
0 2432
0 13039
0 52074
0 160664
0 391912
0 767103
0 1215566
0 1566070
0 1640640
0 1392065
0 948430
0 511380
0 213272
0 66352
0 14496
0 1984
0 128
1 448
2 672
3 560
4 280
5 84
6 14
7 1

result:

ok 52 numbers

Test #47:

score: 0
Accepted
time: 69ms
memory: 14292kb

input:

26
1 4 7 10 13 16 19 22 25 2 5 8 11 14 17 20 23 26 3 6 9 12 15 18 21 24

output:

0 26
0 217
0 920
0 2338
0 3836
0 4186
0 3032
0 1405
0 378
0 45
1 72
2 28
4 42
6 15
9 20
12 6
16 6
20 1
26 2
33 1
42 2
52 1
64 2
77 1
92 2
108 1

result:

ok 52 numbers

Test #48:

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

input:

26
1 14 2 15 3 16 4 17 5 18 6 19 7 20 8 21 9 22 10 23 11 24 12 25 13 26

output:

0 26
0 247
0 1300
0 4433
0 10582
0 18447
0 24024
0 23595
0 17446
0 9581
0 3796
0 1027
0 170
0 13
1 12
3 11
6 10
10 9
15 8
21 7
28 6
36 5
45 4
55 3
66 2
78 1

result:

ok 52 numbers

Test #49:

score: 0
Accepted
time: 55ms
memory: 11268kb

input:

26
25 23 21 19 17 15 13 11 9 7 5 3 1 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

0 26
0 91
1 728
2 1001
4 4004
6 3003
9 6864
12 3003
16 4004
20 1001
25 728
30 91
36 28
42 1
50 2
59 1
70 2
82 1
96 2
111 1
128 2
146 1
166 2
187 1
210 2
234 1

result:

ok 52 numbers

Test #50:

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

input:

26
13 20 14 21 15 22 16 23 17 24 18 25 19 26 2 1 4 3 6 5 8 7 10 9 12 11

output:

0 26
0 130
0 342
0 520
0 458
0 218
0 50
0 7
1 6
3 5
5 12
6 1
15 2
21 1
35 12
49 60
63 160
77 240
90 50
102 7
115 6
129 5
144 4
160 3
177 2
195 1

result:

ok 52 numbers

Test #51:

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

input:

26
15 21 16 22 17 23 18 24 19 25 20 26 2 1 4 3 6 5 8 7 10 9 12 11 14 13

output:

0 26
0 135
0 390
0 695
0 768
0 485
0 134
1 453
2 672
3 560
4 280
5 84
6 14
7 1
21 12
35 51
49 110
63 135
77 96
91 37
105 6
120 5
136 4
153 3
171 2
190 1

result:

ok 52 numbers

Test #52:

score: 0
Accepted
time: 129ms
memory: 19288kb

input:

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

output:

0 30
0 176
0 467
0 659
0 517
0 222
0 48
0 4
1 4
2 1
4 2
6 1
9 1
13 1
19 2
25 1
33 2
42 3
52 4
63 4
75 3
88 1
103 4
118 1
137 1
159 3
181 1
205 1
231 1
259 1

result:

ok 60 numbers

Test #53:

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

input:

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

output:

0 30
0 191
0 417
0 435
0 274
0 108
0 23
0 2
2 12
4 23
6 15
8 2
11 1
15 1
21 2
27 1
35 1
44 1
54 3
64 1
76 1
89 2
103 1
119 3
135 1
153 1
174 2
195 1
219 1
244 1

result:

ok 60 numbers

Test #54:

score: 0
Accepted
time: 32ms
memory: 9172kb

input:

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

output:

0 30
0 171
0 348
0 284
0 108
0 14
1 20
2 6
4 11
6 3
9 3
12 1
16 2
20 1
26 1
35 3
45 6
56 10
67 1
79 9
90 1
103 2
117 1
133 1
151 1
170 2
190 1
213 1
237 1
264 1

result:

ok 60 numbers

Test #55:

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

input:

30
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

output:

0 30
0 435
0 4060
0 27405
0 142506
0 593775
0 2035800
0 5852925
0 14307150
0 30045015
0 54627300
0 86493225
0 119759850
0 145422675
0 155117520
0 145422675
0 119759850
0 86493225
0 54627300
0 30045015
0 14307150
0 5852925
0 2035800
0 593775
0 142506
0 27405
0 4060
0 435
0 30
0 1

result:

ok 60 numbers

Test #56:

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

input:

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

output:

0 30
1 435
3 4060
6 27405
10 142506
15 593775
21 2035800
28 5852925
36 14307150
45 30045015
55 54627300
66 86493225
78 119759850
91 145422675
105 155117520
120 145422675
136 119759850
153 86493225
171 54627300
190 30045015
210 14307150
231 5852925
253 2035800
276 593775
300 142506
325 27405
351 4060...

result:

ok 60 numbers

Test #57:

score: 0
Accepted
time: 898ms
memory: 75256kb

input:

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

output:

0 30
0 255
0 979
0 2043
0 2490
0 1786
0 728
0 150
0 12
1 24
2 15
3 3
5 7
7 5
9 1
12 1
17 3
22 4
27 1
34 1
43 2
52 1
63 1
75 1
88 1
102 1
118 1
137 1
158 1
180 1

result:

ok 60 numbers

Test #58:

score: 0
Accepted
time: 269ms
memory: 29448kb

input:

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

output:

0 30
0 175
0 345
0 267
0 101
0 23
0 2
1 1
3 3
6 4
10 17
14 15
18 4
23 1
30 21
36 3
43 2
51 1
61 2
72 2
84 2
97 1
112 3
127 1
145 2
163 1
182 1
207 1
233 1
260 1

result:

ok 60 numbers

Test #59:

score: 0
Accepted
time: 33ms
memory: 7908kb

input:

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

output:

0 30
0 263
0 1040
0 2193
0 2665
0 1925
0 824
0 204
0 29
0 2
1 1
3 3
5 2
8 6
11 7
14 4
17 1
22 1
28 3
34 2
41 1
50 2
59 1
70 1
84 2
98 1
113 1
129 1
150 1
172 1

result:

ok 60 numbers

Test #60:

score: 0
Accepted
time: 24ms
memory: 9720kb

input:

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

output:

0 30
0 176
0 330
0 266
0 94
0 13
1 14
2 2
4 1
7 14
10 13
13 2
17 1
22 1
28 3
34 1
43 2
52 1
63 2
74 1
86 1
100 1
116 5
132 2
150 6
168 1
188 2
209 1
232 1
259 1

result:

ok 60 numbers

Test #61:

score: 0
Accepted
time: 457ms
memory: 49052kb

input:

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

output:

0 30
0 209
0 609
0 871
0 675
0 314
0 91
0 15
0 1
2 3
4 3
6 1
9 2
12 1
16 2
20 1
26 1
34 4
42 2
51 2
61 2
72 1
85 1
101 3
117 1
134 1
153 1
175 1
199 1
226 1

result:

ok 60 numbers

Test #62:

score: 0
Accepted
time: 527ms
memory: 47764kb

input:

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

output:

0 30
0 227
0 733
0 1315
0 1481
0 1115
0 575
0 199
0 42
0 4
1 4
2 1
4 1
7 1
11 1
16 1
22 2
29 1
38 4
47 2
57 2
68 2
80 1
94 1
109 3
124 1
143 2
163 1
185 1
208 1

result:

ok 60 numbers

Test #63:

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

input:

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

output:

0 30
0 429
0 3892
0 25152
0 123240
0 475780
0 1484640
0 3811230
0 8149460
0 14640774
0 22225800
0 28605356
0 31249128
0 28949028
0 22672832
0 14930505
0 8197758
0 3707509
0 1357284
0 392172
0 86080
0 13488
0 1344
0 64
1 192
2 240
3 160
4 60
5 12
6 1

result:

ok 60 numbers

Test #64:

score: 0
Accepted
time: 959ms
memory: 78280kb

input:

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

output:

0 30
0 255
0 1020
0 2316
0 3226
0 2822
0 1525
0 482
0 83
0 6
1 7
2 2
4 5
6 4
8 1
11 4
14 2
18 1
24 1
31 1
40 3
49 1
60 1
73 3
86 2
100 1
118 1
137 1
157 1
180 1

result:

ok 60 numbers

Test #65:

score: 0
Accepted
time: 310ms
memory: 31532kb

input:

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

output:

0 30
0 179
0 384
0 355
0 156
0 31
0 2
2 12
4 16
6 4
9 12
12 7
15 1
20 4
25 3
31 3
38 1
47 6
55 1
64 1
75 1
89 1
104 1
121 1
139 1
158 1
179 1
203 1
228 1
256 1

result:

ok 60 numbers

Test #66:

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

input:

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

output:

0 30
0 253
0 937
0 1840
0 2148
0 1555
0 679
0 162
0 16
1 18
2 7
3 1
5 1
8 2
11 1
15 2
19 1
25 2
31 1
38 1
47 2
56 1
66 1
77 1
91 1
106 1
122 1
141 1
161 1
182 1

result:

ok 60 numbers

Test #67:

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

input:

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

output:

0 30
0 176
0 343
0 231
0 64
0 6
1 3
3 10
5 7
8 15
11 7
15 11
19 2
24 2
30 4
36 2
43 1
51 1
60 1
70 1
82 1
95 1
110 1
126 1
143 1
161 1
180 1
204 1
231 1
259 1

result:

ok 60 numbers

Test #68:

score: 0
Accepted
time: 756ms
memory: 67652kb

input:

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

output:

0 30
0 223
0 638
0 847
0 553
0 157
1 535
2 672
3 377
4 92
5 8
7 4
10 16
13 20
16 8
19 1
26 1
34 4
42 6
50 4
58 1
70 1
83 2
96 1
113 3
130 1
149 2
169 2
190 2
212 1

result:

ok 60 numbers

Test #69:

score: 0
Accepted
time: 3ms
memory: 4132kb

input:

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

output:

0 30
0 330
0 2030
0 8190
0 23478
0 50050
0 81510
0 102960
0 101530
0 78078
0 46410
0 20930
0 6930
0 1590
0 226
0 15
1 14
3 13
6 12
10 11
15 10
21 9
28 8
36 7
45 6
55 5
66 4
78 3
91 2
105 1

result:

ok 60 numbers

Test #70:

score: 0
Accepted
time: 345ms
memory: 35736kb

input:

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

output:

0 30
0 120
1 1120
2 1820
4 8736
6 8008
9 22880
12 12870
16 22880
20 8008
25 8736
30 1820
36 1120
42 120
49 32
56 1
65 2
75 1
87 2
100 1
115 2
131 1
149 2
168 1
189 2
211 1
235 2
260 1
287 2
315 1

result:

ok 60 numbers

Test #71:

score: 0
Accepted
time: 3ms
memory: 4044kb

input:

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

output:

0 30
0 177
0 568
0 1122
0 1452
0 1282
0 792
0 333
0 82
0 9
1 8
3 7
6 6
10 5
15 4
21 3
28 2
36 1
54 12
72 60
90 160
108 240
126 192
144 64
163 192
182 240
201 164
219 3
238 2
258 1

result:

ok 60 numbers

Test #72:

score: 0
Accepted
time: 3ms
memory: 4052kb

input:

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

output:

0 30
0 176
0 560
0 1078
0 1288
0 924
0 360
0 65
0 8
1 7
3 6
5 84
6 14
7 1
21 18
28 1
44 14
60 84
76 280
91 476
105 232
119 65
133 8
148 7
164 6
181 5
199 4
218 3
238 2
259 1

result:

ok 60 numbers

Test #73:

score: 0
Accepted
time: 193ms
memory: 26796kb

input:

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

output:

0 32
0 278
0 1020
0 1890
0 1877
0 988
0 250
0 24
1 34
2 15
3 2
5 5
7 4
9 1
13 6
17 9
21 2
26 10
31 12
36 4
42 5
48 1
57 1
69 3
81 1
95 3
110 3
126 1
144 1
163 1
190 1
218 1

result:

ok 64 numbers

Test #74:

score: 0
Accepted
time: 287ms
memory: 32308kb

input:

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

output:

0 32
0 210
0 515
0 593
0 341
0 109
0 25
0 3
1 3
3 4
5 1
9 4
13 1
18 1
24 2
31 4
38 1
46 1
55 3
64 1
75 1
87 1
100 1
114 1
130 2
147 1
166 1
187 2
208 1
233 2
258 1
286 1

result:

ok 64 numbers

Test #75:

score: 0
Accepted
time: 37ms
memory: 9204kb

input:

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

output:

0 32
0 298
0 1336
0 3401
0 5290
0 5197
0 3237
0 1239
0 265
0 24
1 48
2 30
3 6
5 17
7 11
9 2
12 1
16 6
20 5
24 1
29 1
36 2
44 2
53 1
64 2
76 1
90 1
106 1
126 2
147 1
171 1
198 1

result:

ok 64 numbers

Test #76:

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

input:

32
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

output:

0 32
0 496
0 4960
0 35960
0 201376
0 906192
0 3365856
0 10518300
0 28048800
0 64512240
0 129024480
0 225792840
0 347373600
0 471435600
0 565722720
0 601080390
0 565722720
0 471435600
0 347373600
0 225792840
0 129024480
0 64512240
0 28048800
0 10518300
0 3365856
0 906192
0 201376
0 35960
0 4960
0 496...

result:

ok 64 numbers

Test #77:

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

input:

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

output:

0 32
1 496
3 4960
6 35960
10 201376
15 906192
21 3365856
28 10518300
36 28048800
45 64512240
55 129024480
66 225792840
78 347373600
91 471435600
105 565722720
120 601080390
136 565722720
153 471435600
171 347373600
190 225792840
210 129024480
231 64512240
253 28048800
276 10518300
300 3365856
325 90...

result:

ok 64 numbers

Test #78:

score: 0
Accepted
time: 2124ms
memory: 157268kb

input:

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

output:

0 32
0 300
0 1337
0 3528
0 6284
0 8125
0 7858
0 5704
0 3070
0 1192
0 317
0 52
0 4
1 4
2 1
5 2
9 5
13 3
18 3
24 3
31 3
39 2
48 1
59 1
72 3
85 1
100 3
115 1
133 2
152 1
174 2
196 1

result:

ok 64 numbers

Test #79:

score: 0
Accepted
time: 781ms
memory: 61248kb

input:

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

output:

0 32
0 188
0 359
0 270
0 69
1 180
2 137
3 30
5 43
7 11
10 10
13 1
17 1
22 3
27 1
34 1
42 1
51 1
61 3
71 2
82 2
94 1
108 1
124 1
141 3
158 1
178 1
199 1
222 1
248 1
277 1
308 1

result:

ok 64 numbers

Test #80:

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

input:

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

output:

0 32
0 307
0 1442
0 4066
0 7566
0 9642
0 8471
0 5056
0 1970
0 456
0 48
1 120
2 116
3 54
4 12
5 1
8 5
11 5
14 1
19 1
26 1
34 1
43 1
53 3
63 1
75 1
91 2
107 1
126 2
145 1
167 2
189 1

result:

ok 64 numbers

Test #81:

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

input:

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

output:

0 32
0 189
0 374
0 315
0 123
0 20
0 1
2 8
4 13
6 5
9 5
13 13
17 7
21 1
27 2
34 2
42 2
51 4
60 2
70 2
81 1
94 1
109 5
124 3
140 1
158 3
176 1
198 1
223 1
250 1
278 1
307 1

result:

ok 64 numbers

Test #82:

score: 0
Accepted
time: 1410ms
memory: 112704kb

input:

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

output:

0 32
0 245
0 778
0 1313
0 1283
0 729
0 225
0 29
1 51
2 25
3 3
5 1
8 6
11 4
15 19
19 16
23 3
28 2
34 1
41 1
51 1
63 3
75 1
90 2
106 2
123 5
140 5
157 1
177 1
200 1
224 1
251 1

result:

ok 64 numbers

Test #83:

score: 0
Accepted
time: 1164ms
memory: 84488kb

input:

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

output:

0 32
0 259
0 872
0 1581
0 1739
0 1196
0 502
0 118
0 12
1 10
2 2
5 20
7 1
10 1
14 5
18 5
22 1
28 2
35 2
43 2
52 1
63 4
74 1
87 1
101 1
115 1
131 2
147 1
166 1
187 1
211 1
237 1

result:

ok 64 numbers

Test #84:

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

input:

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

output:

0 32
0 489
0 4750
0 32936
0 173544
0 722260
0 2436200
0 6780510
0 15771920
0 30939694
0 51507348
0 73056956
0 88459840
0 91447284
0 80570888
0 60276169
0 38058768
0 20103025
0 8772302
0 3106740
0 870424
0 185648
0 28320
0 2752
0 128
1 448
2 672
3 560
4 280
5 84
6 14
7 1

result:

ok 64 numbers

Test #85:

score: 0
Accepted
time: 2355ms
memory: 162988kb

input:

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

output:

0 32
0 290
0 1207
0 2884
0 4440
0 4529
0 3026
0 1283
0 323
0 42
0 2
1 1
3 6
5 9
7 2
10 1
14 7
18 5
23 4
29 3
36 2
44 1
54 1
66 1
79 1
93 1
109 1
126 3
143 4
160 1
183 2
206 1

result:

ok 64 numbers

Test #86:

score: 0
Accepted
time: 667ms
memory: 57852kb

input:

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

output:

0 32
0 205
0 527
0 669
0 446
0 153
0 24
0 1
2 7
4 8
6 2
9 5
12 2
16 3
20 1
26 5
32 1
40 3
48 2
58 7
68 6
78 1
93 3
108 1
124 1
142 1
161 1
184 2
207 1
232 1
260 1
291 1

result:

ok 64 numbers

Test #87:

score: 0
Accepted
time: 160ms
memory: 21620kb

input:

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

output:

0 32
0 283
0 1084
0 2248
0 2863
0 2359
0 1260
0 417
0 77
0 6
1 4
3 16
5 17
7 5
10 4
14 4
19 7
24 3
30 1
37 1
45 1
54 3
63 1
74 1
86 3
98 1
113 1
130 1
148 1
168 1
190 1
213 1

result:

ok 64 numbers

Test #88:

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

input:

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

output:

0 32
0 210
0 526
0 617
0 346
0 98
0 16
1 40
2 28
3 6
5 4
8 9
11 2
15 4
19 1
24 1
30 1
38 3
46 1
55 3
64 1
76 1
90 1
106 5
122 2
140 4
158 1
180 1
204 2
228 1
255 1
286 1

result:

ok 64 numbers

Test #89:

score: 0
Accepted
time: 1304ms
memory: 106736kb

input:

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

output:

0 32
0 331
0 1770
0 5820
0 12792
0 19614
0 21372
0 16545
0 8920
0 3191
0 682
0 66
1 110
2 45
4 72
6 28
9 42
12 15
16 20
20 6
25 6
30 1
37 2
45 1
55 2
66 1
79 2
93 1
109 2
126 1
145 2
165 1

result:

ok 64 numbers

Test #90:

score: 0
Accepted
time: 1259ms
memory: 89380kb

input:

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

output:

0 32
0 248
0 560
0 784
0 728
0 448
0 176
0 40
0 4
1 2
3 2
6 2
10 2
15 2
21 2
28 2
36 2
45 2
55 2
66 2
78 2
91 2
105 2
120 2
136 16
152 56
168 112
184 140
200 112
216 56
232 16
248 1

result:

ok 64 numbers

Test #91:

score: 0
Accepted
time: 2252ms
memory: 157192kb

input:

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

output:

0 32
0 248
0 734
0 979
0 616
0 167
1 552
2 680
3 378
4 92
5 8
7 4
10 16
13 20
16 8
19 1
26 2
34 9
42 12
50 8
58 2
70 4
82 2
95 6
108 6
121 1
140 4
159 2
180 6
201 1
224 2
248 1

result:

ok 64 numbers

Test #92:

score: 0
Accepted
time: 4ms
memory: 4216kb

input:

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

output:

0 32
0 376
0 2480
0 10780
0 33488
0 77896
0 139568
0 195910
0 217360
0 191048
0 132496
0 71708
0 29680
0 9080
0 1936
0 257
0 16
1 15
3 14
6 13
10 12
15 11
21 10
28 9
36 8
45 7
55 6
66 5
78 4
91 3
105 2
120 1

result:

ok 64 numbers

Test #93:

score: 0
Accepted
time: 911ms
memory: 69536kb

input:

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

output:

0 32
0 136
1 1360
2 2380
4 12376
6 12376
9 38896
12 24310
16 48620
20 19448
25 24752
30 6188
36 4760
42 680
49 272
56 17
64 2
73 1
84 2
96 1
110 2
125 1
142 2
160 1
180 2
201 1
224 2
248 1
274 2
301 1
330 2
360 1

result:

ok 64 numbers

Test #94:

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

input:

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

output:

0 32
0 201
0 688
0 1442
0 1932
0 1666
0 920
0 333
0 82
0 9
1 8
3 7
6 20
7 1
15 4
21 3
28 2
36 1
54 14
72 84
90 280
108 560
126 672
144 448
162 136
178 7
195 6
213 5
232 4
252 3
273 2
295 1

result:

ok 64 numbers

Test #95:

score: 0
Accepted
time: 3ms
memory: 4184kb

input:

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

output:

0 32
0 204
0 728
0 1638
0 2408
0 2268
0 1256
0 321
0 8
1 7
3 1798
4 1120
5 448
6 112
7 16
8 1
24 16
40 92
56 280
72 518
88 616
104 476
120 232
136 65
152 8
169 7
187 6
206 5
226 4
247 3
269 2
292 1

result:

ok 64 numbers

Test #96:

score: 0
Accepted
time: 310ms
memory: 35352kb

input:

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

output:

0 34
0 255
0 808
0 1339
0 1285
0 747
0 268
0 58
0 6
1 7
2 2
4 1
7 4
10 3
14 11
18 9
22 1
27 1
33 1
40 1
48 1
57 1
70 1
84 1
100 1
118 3
136 3
154 1
173 1
197 1
223 2
250 4
277 1
306 1

result:

ok 68 numbers

Test #97:

score: 0
Accepted
time: 817ms
memory: 84120kb

input:

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

output:

0 34
0 313
0 1129
0 2027
0 2097
0 1369
0 594
0 158
0 20
1 44
2 33
3 10
4 1
7 2
10 1
14 2
18 1
24 2
30 1
37 4
44 5
51 1
59 1
68 1
78 2
89 2
101 1
119 3
137 1
157 2
178 2
200 2
223 1
248 1

result:

ok 68 numbers

Test #98:

score: 0
Accepted
time: 872ms
memory: 67488kb

input:

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

output:

0 34
0 248
0 818
0 1480
0 1598
0 1065
0 434
0 100
0 10
1 15
2 3
4 4
6 1
9 3
12 1
17 2
23 1
31 4
39 15
46 4
54 3
63 1
74 1
86 1
102 1
119 1
137 1
157 1
178 3
199 1
224 1
250 1
280 1
313 1

result:

ok 68 numbers

Test #99:

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

input:

34
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

output:

0 34
0 561
0 5984
0 46376
0 278256
0 1344904
0 5379616
0 18156204
0 52451256
0 131128140
0 286097760
0 548354040
0 927983760
0 1391975640
0 1855967520
0 2203961430
0 2333606220
0 2203961430
0 1855967520
0 1391975640
0 927983760
0 548354040
0 286097760
0 131128140
0 52451256
0 18156204
0 5379616
0 13...

result:

ok 68 numbers

Test #100:

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

input:

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

output:

0 34
1 561
3 5984
6 46376
10 278256
15 1344904
21 5379616
28 18156204
36 52451256
45 131128140
55 286097760
66 548354040
78 927983760
91 1391975640
105 1855967520
120 2203961430
136 2333606220
153 2203961430
171 1855967520
190 1391975640
210 927983760
231 548354040
253 286097760
276 131128140
300 52...

result:

ok 68 numbers

Test #101:

score: -100
Time Limit Exceeded

input:

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

output:


result: