QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#55922#2836. Permutation Patternforeverlasting#AC ✓331ms79852kbC++173.5kb2022-10-15 17:14:462022-10-15 17:14:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-15 17:14:47]
  • 评测
  • 测评结果:AC
  • 用时:331ms
  • 内存:79852kb
  • [2022-10-15 17:14:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define gc getchar
#define pb push_back
#define fi first
#define se second
#define Pair pair<int,int>
inline int read(){
	int s=0,w=1,ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')w=-1;
		ch=gc();
	}
	while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
	return s*w;
}
template<int kcz>
struct ModInt {
#define T (*this)
	int x;
	ModInt() : x(0) {}
	ModInt(int y) : x(y >= 0 ? y : y + kcz) {}
	ModInt(LL y) : x(y >= 0 ? y % kcz : (kcz - (-y) % kcz) % kcz) {}
	inline int inc(const int &v) {
		return v >= kcz ? v - kcz : v;
	}
	inline int dec(const int &v) {
		return v < 0 ? v + kcz : v;
	}
	inline ModInt &operator+=(const ModInt &p) {
		x = inc(x + p.x);
		return T;
	}
	inline ModInt &operator-=(const ModInt &p) {
		x = dec(x - p.x);
		return T;
	}
	inline ModInt &operator*=(const ModInt &p) {
		x = (int)((LL)x * p.x % kcz);
		return T;
	}
	inline ModInt inverse() const {
		int a = x, b = kcz, u = 1, v = 0, t;
		while (b > 0)t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
		return u;
	}
	inline ModInt &operator/=(const ModInt &p) {
		T *= p.inverse();
		return T;
	}
	inline ModInt operator-() const {
		return -x;
	}
	inline friend ModInt operator+(const ModInt &lhs, const ModInt &rhs) {
		return ModInt(lhs) += rhs;
	}
	inline friend ModInt operator-(const ModInt &lhs, const ModInt &rhs) {
		return ModInt(lhs) -= rhs;
	}
	inline friend ModInt operator*(const ModInt &lhs, const ModInt &rhs) {
		return ModInt(lhs) *= rhs;
	}
	inline friend ModInt operator/(const ModInt &lhs, const ModInt &rhs) {
		return ModInt(lhs) /= rhs;
	}
	inline bool operator==(const ModInt &p) const {
		return x == p.x;
	}
	inline bool operator!=(const ModInt &p) const {
		return x != p.x;
	}
	ModInt qpow(LL n) const {
		ModInt ret(1), mul(x);
		while (n > 0) {
			if (n & 1)ret *= mul;
			mul *= mul, n >>= 1;
		}
		return ret;
	}
	inline friend ostream &operator<<(ostream &os, const ModInt &p) {
		return os << p.x;
	}
	inline friend istream &operator>>(istream &is, ModInt &a) {
		LL t;
		is >> t, a = ModInt<kcz>(t);
		return is;
	}
	static int get_mod() {
		return kcz;
	}
#undef T
};
const int kcz=998244353;
using Z = ModInt<kcz>;
const int N=50+10;
LL f[N][N][N][N],pre[N];
int p[N];
inline void solve(){
	int n;
	while(scanf("%d",&n)==1){
		for(int i=1;i<=n;i++)p[i]=read();
		for(int i=0;i<=n+1;i++)for(int j=0;j<=n+1;j++)for(int k=0;k<=n+1;k++)for(int l=0;l<=n+1;l++)f[i][j][k][l]=0;
		for(int len=1;len<=n;len++){
			for(int l=1,r=l+len-1;r<=n;l++,r++){
				for(int k=l;k<=r;k++){
					f[l][r][k][k]++;
					if(k!=l){
						for(int i=l;i<k;i++){
							for(int j=l;j<k;j++){
								if(p[j]<p[k])f[l][r][i][k]+=f[l][k-1][i][j];
							}
						}
					}
					if(k!=r){
						for(int i=k+1;i<=r;i++){
							for(int j=k+1;j<=r;j++){
								if(p[j]<p[k])f[l][r][i][k]+=f[k+1][r][i][j];
							}
						}
					}
					if(k!=l&&k!=r){
						for(int i=0;i<=n+1;i++)pre[i]=0;
						for(int i=k+1;i<=r;i++){
							for(int j=k+1;j<=r;j++){
								if(p[j]<p[k])pre[p[i]]+=f[k+1][r][i][j];
							}
						}
						for(int i=1;i<=n;i++)pre[i]+=pre[i-1];
						for(int i=l;i<k;i++){
							for(int j=l;j<k;j++){
								if(p[j]<p[k]){
									f[l][r][i][k]+=f[l][k-1][i][j]*(pre[n]-pre[p[j]]);
								}
							}
						}
					}
				}
			}
		}
		LL ans=0;
		for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)ans+=f[1][n][i][j];
		printf("%lld\n",ans);
	}
}
int main(){
	int T=1;
	while(T--)solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 4024kb

input:

2
2 1
3
1 2 3
4
2 3 4 1

output:

3
7
11

result:

ok 3 lines

Test #2:

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

input:

1
1
2
1 2
2
2 1
3
1 2 3
3
1 3 2
3
2 1 3
3
2 3 1
3
3 1 2
3
3 2 1

output:

1
3
3
7
7
7
6
7
7

result:

ok 9 lines

Test #3:

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

input:

5
4 5 2 1 3
5
2 5 1 4 3
5
1 2 5 3 4
5
2 4 5 3 1
5
3 4 2 1 5
5
1 3 5 2 4
5
3 4 2 1 5
5
5 1 4 3 2
5
1 5 4 2 3
5
5 2 1 3 4
5
4 5 1 2 3
5
5 2 1 4 3
5
5 3 1 4 2
5
5 1 2 3 4
5
3 2 1 4 5
5
4 3 1 2 5
5
1 3 4 2 5
5
5 4 2 3 1
5
2 4 1 5 3
5
3 5 1 4 2
5
4 2 3 1 5
5
1 5 2 3 4
5
3 2 1 4 5
5
4 5 2 1 3
5
3 2 4 5 1
...

output:

24
27
31
20
25
27
25
31
31
31
24
31
27
31
31
31
27
27
24
23
27
31
31
24
21
25
21
27
24
25
31
31
25
24
20
31
27
21
21
31
27
31
21
31
21
31
24
22
31
25
25
27
25
27
27
27
31
31
31
22
25
31
27
25
31
22
31
27
25
20
27
22
31
31
25
20
31
31
25
31
27
27
25
20
31
31
31
27
31
31
22
21
25
31
25
27
19
31
27
23

result:

ok 100 lines

Test #4:

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

input:

4
1 2 3 4
4
1 2 4 3
4
1 3 2 4
4
1 3 4 2
4
1 4 2 3
4
1 4 3 2
4
2 1 3 4
4
2 1 4 3
4
2 3 1 4
4
2 3 4 1
4
2 4 1 3
4
2 4 3 1
4
3 1 2 4
4
3 1 4 2
4
3 2 1 4
4
3 2 4 1
4
3 4 1 2
4
3 4 2 1
4
4 1 2 3
4
4 1 3 2
4
4 2 1 3
4
4 2 3 1
4
4 3 1 2
4
4 3 2 1

output:

15
15
15
13
15
15
15
15
13
11
13
12
15
13
15
12
12
12
15
15
15
13
15
15

result:

ok 24 lines

Test #5:

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

input:

5
1 2 3 4 5
5
1 2 3 5 4
5
1 2 4 3 5
5
1 2 4 5 3
5
1 2 5 3 4
5
1 2 5 4 3
5
1 3 2 4 5
5
1 3 2 5 4
5
1 3 4 2 5
5
1 3 4 5 2
5
1 3 5 2 4
5
1 3 5 4 2
5
1 4 2 3 5
5
1 4 2 5 3
5
1 4 3 2 5
5
1 4 3 5 2
5
1 4 5 2 3
5
1 4 5 3 2
5
1 5 2 3 4
5
1 5 2 4 3
5
1 5 3 2 4
5
1 5 3 4 2
5
1 5 4 2 3
5
1 5 4 3 2
5
2 1 3 4 5
...

output:

31
31
31
27
31
31
31
31
27
23
27
25
31
27
31
25
25
25
31
31
31
27
31
31
31
31
31
27
31
31
27
27
23
20
23
21
27
24
25
21
21
20
27
27
25
22
25
24
31
31
27
23
27
25
31
31
25
21
25
22
25
21
25
20
19
19
25
23
25
21
22
22
31
27
31
25
25
25
31
27
27
22
23
21
31
25
31
24
22
22
24
24
24
21
24
24
31
31
31
27

result:

ok 100 lines

Test #6:

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

input:

5
5 1 4 2 3
5
5 1 4 3 2
5
5 2 1 3 4
5
5 2 1 4 3
5
5 2 3 1 4
5
5 2 3 4 1
5
5 2 4 1 3
5
5 2 4 3 1
5
5 3 1 2 4
5
5 3 1 4 2
5
5 3 2 1 4
5
5 3 2 4 1
5
5 3 4 1 2
5
5 3 4 2 1
5
5 4 1 2 3
5
5 4 1 3 2
5
5 4 2 1 3
5
5 4 2 3 1
5
5 4 3 1 2
5
5 4 3 2 1

output:

31
31
31
31
27
23
27
25
31
27
31
25
25
25
31
31
31
27
31
31

result:

ok 20 lines

Test #7:

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

input:

6
3 4 5 1 6 2
6
3 4 5 6 1 2
6
4 2 5 6 3 1
6
3 5 2 6 4 1
6
3 2 4 1 5 6
6
5 1 4 3 2 6
6
4 6 3 2 1 5
6
3 4 6 5 1 2
6
5 1 2 6 4 3
6
3 5 2 6 1 4
6
6 5 4 1 2 3
6
1 3 2 5 4 6
6
2 3 1 5 4 6
6
1 4 6 3 5 2
6
3 2 4 5 6 1
6
1 2 6 3 4 5
6
5 4 6 1 2 3
6
4 1 2 5 3 6
6
4 1 3 5 2 6
6
6 1 5 2 4 3
6
2 3 1 5 6 4
6
1 4 ...

output:

33
30
33
34
51
63
49
33
51
38
63
63
55
43
38
63
42
55
51
63
48
39
39
51
45
63
46
51
51
63
55
63
42
55
63
45
63
40
47
40
47
51
55
39
51
55
44
49
63
42
63
63
37
36
63
63
39
40
49
63
63
51
51
47
47
45
39
36
63
55
55
63
51
51
37
42
51
55
51
49
39
43
55

result:

ok 83 lines

Test #8:

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

input:

7
2 1 4 3 5 7 6
7
5 4 7 6 3 2 1
7
7 2 5 3 6 4 1
7
6 3 1 5 4 2 7
7
6 5 4 7 2 1 3
7
4 1 7 2 5 3 6
7
5 3 1 6 2 7 4
7
3 7 1 6 5 4 2
7
6 2 1 5 4 3 7
7
4 7 6 3 1 2 5
7
4 6 3 7 1 2 5
7
6 5 2 1 7 3 4
7
4 1 2 6 3 7 5
7
3 1 6 7 5 2 4
7
4 7 3 6 1 5 2
7
3 6 5 4 7 1 2
7
1 7 2 4 3 5 6
7
2 6 1 3 5 7 4
7
1 2 7 4 6 ...

output:

127
64
73
103
78
95
81
89
127
85
66
91
99
79
67
61
127
91
111
83
67
60
127
85
57
66
111
99
111
53
64
99
89
91
73
99
75
83
103
81
72
75
69
99
64
99
91
91
95
85
66
60
79
103
64
64
91
83
67
87
75
91
75
103
95
75
71
54
89
68
65

result:

ok 71 lines

Test #9:

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

input:

8
4 1 2 7 8 5 6 3
8
7 2 8 6 4 5 1 3
8
2 3 4 8 6 5 1 7
8
5 8 3 6 2 1 4 7
8
2 4 3 8 1 7 5 6
8
5 7 8 4 6 3 1 2
8
1 4 2 7 5 3 8 6
8
6 7 8 4 3 1 2 5
8
7 2 5 1 6 4 8 3
8
8 1 4 7 2 5 6 3
8
6 8 7 3 2 1 5 4
8
7 6 8 2 1 3 5 4
8
1 5 6 4 2 7 3 8
8
6 3 2 7 8 4 1 5
8
6 2 3 7 4 5 8 1
8
4 5 7 1 8 3 2 6
8
7 4 1 6 5 ...

output:

143
125
149
143
175
98
183
131
147
167
162
162
159
107
117
102
183
135
129
155
80
191
135
165
155
171
103
255
169
125
111
102
114
90
255
111
107
255
95
139
167
159
171
168
83
191
91
90
165
115
207
109
159
141
223
100
159
97
101
167
103
132

result:

ok 62 lines

Test #10:

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

input:

9
2 3 7 8 9 6 1 5 4
9
1 6 3 4 2 9 8 7 5
9
1 9 2 6 7 3 4 5 8
9
4 2 1 5 6 3 9 7 8
9
5 1 2 4 3 8 6 9 7
9
5 3 6 2 9 8 7 1 4
9
2 1 9 8 5 3 6 4 7
9
5 4 1 7 8 3 9 6 2
9
2 1 9 6 5 4 8 3 7
9
5 3 6 4 9 2 7 1 8
9
3 7 1 4 6 9 8 5 2
9
5 1 9 4 8 7 3 2 6
9
5 8 7 4 9 6 3 2 1
9
5 7 2 1 3 9 4 6 8
9
9 8 5 1 4 6 7 3 2
...

output:

183
349
399
383
447
176
447
173
399
187
197
255
154
309
271
224
239
177
107
351
183
271
279
161
175
267
263
213
155
319
223
219
215
181
259
271
225
112
337
195
175
199
337
195
279
511
212
182
217
180
353
205
279
271
259

result:

ok 55 lines

Test #11:

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

input:

10
3 8 6 9 7 5 2 1 4 10
10
9 4 6 10 2 5 3 1 8 7
10
7 8 5 10 2 9 3 1 4 6
10
8 6 9 10 7 3 4 5 2 1
10
5 2 4 3 8 6 1 7 9 10
10
1 2 8 4 5 7 10 9 6 3
10
8 3 4 6 5 10 9 7 2 1
10
3 9 10 4 5 1 2 8 6 7
10
4 8 2 3 9 10 5 6 1 7
10
2 3 4 1 8 7 9 5 10 6
10
4 10 6 2 3 1 8 5 7 9
10
8 7 6 2 4 9 10 1 5 3
10
1 9 6 5 1...

output:

355
367
271
213
615
439
267
433
292
455
543
319
331
671
895
279
523
623
291
319
387
513
367
383
1023
424
283
583
341
407
355
291
575
373
316
297
412
603
565
431
575
306
341
267
367
421
300
383
735
511

result:

ok 50 lines

Test #12:

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

input:

2
2 1
8
3 8 1 6 2 7 4 5
2
2 1
3
2 1 3
6
3 4 6 5 1 2
1
1
4
2 4 3 1
1
1
6
1 3 4 2 6 5
9
5 8 9 2 1 3 7 4 6
2
1 2
9
4 3 7 9 1 2 5 6 8
6
4 6 1 5 3 2
4
3 1 4 2
6
2 1 3 6 4 5
2
1 2
2
1 2
7
4 7 2 3 5 1 6
2
2 1
1
1
7
2 7 6 5 1 4 3
2
2 1
4
3 1 2 4
8
7 8 2 6 5 1 4 3
9
4 5 1 2 6 3 7 9 8
10
1 3 2 9 5 7 8 10 6 4
...

output:

3
158
3
7
33
1
12
1
55
249
3
247
43
13
63
3
3
73
3
1
99
3
15
156
335
495
53
15
135
7
3
318
7
1
27
135
1
287
138
205
1
103
895
15
15
27
175
75
73
175

result:

ok 50 lines

Test #13:

score: 0
Accepted
time: 331ms
memory: 79780kb

input:

50
3 50 12 35 11 7 17 49 1 9 41 5 4 27 6 22 8 20 44 43 10 13 15 42 38 16 18 19 30 2 23 21 34 24 32 25 45 39 40 48 26 28 37 36 33 31 29 47 46 14
50
41 21 40 37 36 31 30 3 2 1 34 27 8 4 5 9 28 17 10 11 7 12 15 38 13 14 6 18 20 25 24 16 22 29 26 35 32 33 46 45 50 42 47 48 49 23 43 39 44 19
50
41 38 23 ...

output:

71786596197
925094043175
15360313400319
83273752556543
599976015791
6320724096624
5783738400607
487480246255
307563605
419463685996543

result:

ok 10 lines

Test #14:

score: 0
Accepted
time: 309ms
memory: 79808kb

input:

50
34 20 49 44 4 16 7 24 26 46 31 12 22 47 17 21 29 14 23 9 11 2 30 33 18 8 19 13 38 15 39 28 48 27 35 3 40 42 37 6 25 32 43 10 45 1 50 41 5 36
50
2 29 24 7 1 3 8 4 12 5 6 10 9 26 11 23 13 44 14 16 41 37 15 19 20 34 33 32 21 45 40 22 17 28 25 27 18 30 31 35 38 36 39 43 42 50 46 49 47 48
50
28 19 18 ...

output:

469303887
3708187017215
320672525975551
2384027442511
7802888619
54571757666
12111593784831
124903382056959
22915448657023
181636580245503

result:

ok 10 lines

Test #15:

score: 0
Accepted
time: 313ms
memory: 79748kb

input:

50
1 2 3 16 5 4 6 12 10 9 8 7 11 14 13 15 42 41 40 21 17 19 18 20 26 25 22 24 23 28 27 39 29 36 32 31 30 33 35 34 38 37 43 45 44 50 46 47 48 49
50
24 30 13 12 44 9 8 6 26 1 5 3 10 11 23 15 14 16 18 17 21 19 22 37 25 33 27 2 32 31 28 29 40 36 20 34 50 47 41 4 38 42 43 46 45 48 39 35 7 49
50
45 44 25 ...

output:

1125899906842623
1973544596971
20464777601
145970369134591
1125899906842623
27103062537
492677980225535
611302507087
9436138365023
16901739359823

result:

ok 10 lines

Test #16:

score: 0
Accepted
time: 318ms
memory: 79740kb

input:

50
16 15 13 12 11 4 3 2 1 5 10 30 27 8 6 7 9 22 38 20 19 14 17 37 31 29 23 21 26 24 25 33 32 36 34 39 41 28 40 45 44 43 35 18 42 46 48 47 49 50
50
49 48 43 42 41 24 23 22 29 5 39 3 2 1 4 21 19 8 33 7 9 10 17 12 11 14 13 15 6 16 18 20 40 26 25 37 31 30 28 27 35 34 32 36 38 47 44 46 45 50
50
26 25 24 ...

output:

16941091848191
76454653671423
1125899906842623
281482263953919
1853535582743
11131049930979
914793674309631
109343881936895
323479068999679
226499395534975

result:

ok 10 lines

Test #17:

score: 0
Accepted
time: 331ms
memory: 79792kb

input:

50
48 47 46 45 44 30 35 24 3 16 12 10 4 2 1 9 8 7 6 15 13 14 31 28 27 18 19 20 17 11 25 21 26 5 23 43 29 34 32 33 37 38 36 39 40 22 42 41 49 50
50
50 13 47 44 43 49 42 34 32 31 30 28 27 26 25 14 9 8 7 5 24 3 1 4 12 6 10 2 16 15 11 21 20 18 17 19 22 23 29 33 35 37 36 39 38 40 41 46 45 48
50
46 43 25 ...

output:

13401186994175
58470124486783
3963515139491
18417882639247
1483926119947
74820097933311
76869894769151
138492980779
86510044435583
986103193471

result:

ok 10 lines

Test #18:

score: 0
Accepted
time: 321ms
memory: 79808kb

input:

50
50 49 48 47 45 42 41 40 39 38 18 17 16 1 15 14 5 4 2 3 7 6 8 13 11 10 9 12 32 27 26 25 24 19 20 23 21 22 28 29 31 30 37 33 36 35 34 43 44 46
50
3 1 2 5 4 11 6 33 43 19 8 21 18 17 9 13 10 34 12 15 16 20 31 29 22 24 25 26 28 7 30 42 41 32 35 38 27 37 36 40 39 44 45 23 46 49 48 47 14 50
50
46 45 44 ...

output:

1125899906842623
11503392639871
268613428707327
15555678637567
9233630159167
22814306219679
170131707658239
633318697600255
774159265169407
143738636705815

result:

ok 10 lines

Test #19:

score: 0
Accepted
time: 321ms
memory: 79792kb

input:

50
33 30 29 39 28 50 27 24 23 22 21 20 19 18 15 4 7 2 3 25 5 8 1 6 14 11 9 10 32 12 13 16 17 26 31 37 34 35 36 40 38 41 42 43 45 44 46 49 47 48
50
37 36 32 25 22 21 20 19 12 9 7 3 2 1 4 5 6 8 10 11 18 17 15 13 14 16 24 23 26 27 29 28 30 31 35 34 33 38 39 40 41 46 42 44 43 45 50 47 48 49
50
8 7 6 5 1...

output:

38933422040063
1125899906842623
562950014763007
44651459044351
26429508299007
22574688062335
50191439772447
48552580405247
976228746199
286807572873215

result:

ok 10 lines

Test #20:

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

input:

50
2 12 3 6 5 4 11 8 10 39 9 15 13 14 25 34 31 38 32 29 19 17 16 18 28 7 27 20 22 21 23 26 24 30 40 37 35 41 33 1 49 43 42 36 48 47 44 45 46 50
50
49 45 43 39 24 38 28 27 25 23 22 20 19 18 3 2 1 17 6 13 4 15 14 29 11 7 8 12 21 37 36 35 26 9 34 32 44 31 30 33 10 42 41 16 40 48 46 47 50 5
50
6 5 4 3 2...

output:

17351472343295
4556477881839
2463120461823
10732306780233
1125899906842623
1125899906842623
914793674309631
360661339078655
56122596884479
1125899906842623

result:

ok 10 lines

Test #21:

score: 0
Accepted
time: 327ms
memory: 79828kb

input:

50
13 11 10 7 12 6 5 2 1 3 4 9 8 14 15 16 18 17 20 19 26 22 21 25 24 23 27 28 29 30 32 31 35 34 33 36 40 39 37 38 41 42 44 43 46 45 47 48 49 50
50
33 5 4 3 2 1 31 27 10 9 6 8 7 25 24 12 15 13 14 23 22 20 19 16 18 17 21 26 29 28 30 32 34 43 37 39 35 36 38 42 40 11 41 44 46 45 47 48 50 49
50
12 9 4 2 ...

output:

636067476668415
457397606285311
562949953748991
193106020401151
156758753177599
562950161039359
1125899906842623
174067508416955
12327032671235
130364051111935

result:

ok 10 lines

Test #22:

score: 0
Accepted
time: 302ms
memory: 79852kb

input:

50
23 22 21 20 30 19 18 17 6 24 5 1 2 3 4 7 8 15 9 27 10 14 12 11 13 16 28 26 34 41 32 31 29 35 33 40 39 36 37 38 42 49 47 25 43 44 46 45 48 50
50
44 40 39 29 45 20 6 16 1 2 4 3 5 18 11 7 8 10 9 15 13 12 14 17 19 25 21 22 23 35 24 26 28 27 30 37 36 34 32 31 33 38 41 42 46 43 49 48 47 50
50
22 21 18 ...

output:

52374859921919
183793727635071
1125899906842623
164982120296479
291112892864703
84576527974399
149606796066815
1125899906842623
1125899906842623
26141702275847

result:

ok 10 lines

Test #23:

score: 0
Accepted
time: 319ms
memory: 79816kb

input:

50
19 27 40 18 49 41 4 42 23 44 13 12 6 14 20 17 28 35 43 21 15 29 34 2 38 48 10 9 32 31 22 11 3 50 36 45 8 25 30 37 1 5 24 16 26 7 33 39 46 47
50
12 26 47 33 38 49 1 20 39 17 42 18 37 6 30 19 22 23 5 31 45 41 9 16 34 10 7 35 46 50 2 24 11 40 4 32 27 13 48 14 36 3 43 44 8 25 28 21 29 15
50
22 32 36 ...

output:

247169890
56493847
155005117
61848536
421559517
201522429
133241515
63264935
97358485
652628926

result:

ok 10 lines

Test #24:

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

input:

50
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

output:

1125899906842623

result:

ok single line: '1125899906842623'