QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#382826#7901. Basic Substring StructureEBeasonWA 208ms162320kbC++208.1kb2024-04-08 19:32:132024-04-08 19:32:13

Judging History

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

  • [2024-04-08 19:32:13]
  • 评测
  • 测评结果:WA
  • 用时:208ms
  • 内存:162320kb
  • [2024-04-08 19:32:13]
  • 提交

answer

#pragma GCC optimize(1, 2, 3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
// #define int ll
#define ls p << 1
#define rs p << 1 | 1
#define lowbit(x) ((x) & (-x))
#define endl '\n'
#define ld long double
#define MULTI_CASES
const int MaxN = 1e6 + 100;
const int INF = 1e9;
int T, N, M, K;
int ans[MaxN];
vector<int> a;
struct Sa {
	int sa[MaxN], rk[MaxN], oldrk[MaxN << 1], id[MaxN], key1[MaxN], cnt[MaxN], height[MaxN];
	int st[MaxN][25], logn[MaxN];
	int n;
	vector<int> s;
	void clear() {
		for (int i = 0; i <= n + 1; i++) {
			sa[i] = 0;
			rk[i] = 0;
			oldrk[i] = 0;
			id[i] = 0;
			key1[i] = 0;
			cnt[i] = 0;
			height[i] = 0;
		}
	}
	void init(int _n) {
		n = _n;
		for (int i = 0; i <= n + 1; i++) {
			sa[i] = 0;
			rk[i] = 0;
			oldrk[i] = 0;
			id[i] = 0;
			key1[i] = 0;
			cnt[i] = 0;
			height[i] = 0;
		}
		getsa();
		getheight();
	}
	bool cmp(int x, int y, int w) {
		return oldrk[x] == oldrk[y] && oldrk[x + w] == oldrk[y + w];
	}
	inline void getsa() {
		int i, m = n + 1, p, w;
		// sa[i]表示后缀排序第i小的编号
		// rk[i]表示后缀i的排名
		for (i = 1; i <= n; ++i) ++cnt[rk[i] = s[i]];
		for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
		for (i = n; i >= 1; --i) sa[cnt[rk[i]]--] = i;

		for (w = 1;; w <<= 1, m = p) { // m=p 就是优化计数排序值域
			for (p = 0, i = n; i > n - w; --i) id[++p] = i;
			for (i = 1; i <= n; ++i) 
				if (sa[i] > w) id[++p] = sa[i] - w;
			memset(cnt, 0, (m + 1) * sizeof(int));
			for (i = 1; i <= n; ++i) ++cnt[key1[i] = rk[id[i]]];
			// 注意这里px[i] != i,因为rk没有更新,是上一轮的排名数组

			for (i = 1; i <= m; ++i) cnt[i] += cnt[i - 1];
			for (i = n; i >= 1; --i) sa[cnt[key1[i]]--] = id[i];
			memcpy(oldrk + 1, rk + 1, n * sizeof(int));
			for (p = 0, i = 1; i <= n; ++i) rk[sa[i]] = cmp(sa[i], sa[i - 1], w) ? p : ++p;
			if (p == n) break;
		}
	}
	inline void getheight(){ 
		// height[i] = lcp(sa[i], sa[i-1])
		int i, k;
		for (i = 1, k = 0; i <= n; ++i) {
			if (rk[i] == 0) continue;
			if (k) --k;
			while (i + k <= n && sa[rk[i] - 1] + k <= n && s[i + k] == s[sa[rk[i] - 1] + k]) ++k;
			height[rk[i]] = k;
		}
		// for (int i = 1; i <= N; i++) {
		// 	cerr << rk[i] << ' ';

		// }
		// cerr << endl;
		// for (int i = 1; i <= N; i++) {
		// 	cerr << height[i] << ' ';
		// }
	}
	inline void pre() {
		logn[0] = -1;
		int LogN = 20;
		for (int i = 1; i <= n; i++) logn[i] = logn[i / 2] + 1;
		for (int i = 1; i <= n; i++) st[i][0] = height[i];
		for (int j = 1; j <= LogN; j++) {
			int pj = 1 << (j - 1);
			for (int i = 1; i <= n; i++) {
				if (i + pj <= n)
					st[i][j] = min(st[i][j - 1], st[i + pj][j - 1]);
				else
					st[i][j] = st[i][j - 1];
			}
		}
	}
	inline int lcp(int l, int r) {
		if (l == r) return n - l + 1;
		l = rk[l];
		r = rk[r];
		if (l > r) swap(l, r);
		l++;
		int lp = r - l + 1;
		int n = 1 << logn[lp];
		return min(st[l][logn[lp]], st[r - n + 1][logn[lp]]);
	}
} SA;
struct Tt {
	ll a[MaxN];
	struct Point {
		ll sum, lan;
	} tree[MaxN << 2], ts;
	void js(int p, int x, int y, int z) {
		tree[p].sum += (y - x + 1) * z;
		tree[p].lan += z;
	}
	void pushdown(int p,int l, int r) {
		int mid = (l + r) >> 1;
		js(ls, l, mid, tree[p].lan);
		js(rs, mid + 1, r, tree[p].lan);
		tree[p].lan = 0;
	}
	inline Point pushup(Point L, Point R) {
		Point now = Point();
		now.sum = L.sum + R.sum;
		now.lan = 0;
		return now;
	}
	void build(int p, int l, int r) {
		tree[p].sum = tree[p].lan = 0;
		if (l == r) {
			tree[p].sum = a[l];
			tree[p].lan = 0;
			return;
		}
		pushdown(p, l, r);
		int mid = (l + r) >> 1;
		build(ls, l, mid);
		build(rs, mid + 1, r);
		tree[p] = pushup(tree[ls], tree[rs]);
	}
	void change(int p, int l, int r, int x, int y, int z) {
		if (x > y || x > N || y > N) return;
		if (x < 1 || y < 1) return;
		if (l >= x && r <= y) {
			js(p, l, r, z);
			return;
		}
		pushdown(p, l, r);
		int mid = (l + r) >> 1;
		if (mid >= x) change(ls, l, mid, x, y, z);
		if (mid < y) change(rs, mid + 1, r ,x ,y, z);
		tree[p] = pushup(tree[ls], tree[rs]);
	}
	Point query(int p, int l, int r, int x, int y) {
		if (l >= x && r <= y) {
			return tree[p];
		}
		pushdown(p, l, r);
		int mid = (l + r) >> 1;
		if (mid >= x && mid < y) {
			return pushup(query(ls, l, mid, x, y), query(rs, mid + 1, r, x, y));
		}
		if (mid >= x) return query(ls, l, mid, x, y);
		if (mid < y) return query(rs, mid + 1, r, x, y);
		return Point();
	}
} TT;
ll g[MaxN], b[MaxN];
void updata(int l, int r, int k, int d) {
	if (l > r) return;
	TT.change(1, 1, N, l + 1, r, 1);
	TT.change(1, 1, N, l, l, k);
	TT.change(1, 1, N, r + 1, r + 1, -k - d * (r - l));
}
struct my_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
unordered_map<int ,ll, my_hash> mp[MaxN];
int js(int x, int y) {
	// if (a[x] == a[1]) return 0;
	int t = 1;
	if (y < N) {
		t += SA.lcp(x + 1, y + 1);
	}
	
	if (x + t >= y) {
		int len = y - x;
		t = len;
		if (x <= N && y + len <= N && a[x] == a[y + len]) {
			t += SA.lcp(x + len + 1, y + len + 1) + 1;
		}
		return t;
	} else { 
		return t;
	}
}
inline void Solve() {
	// Sa _;
	// SA = _;
	// Tt tttt;
	// TT = tttt;
	cin >> N;
	a.assign(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= N + 1; i++) {
		mp[i].clear();
	}
	SA.s = a;
	SA.init(N);
	SA.pre();
	for (int i = 1; i <= N; i++) {
		g[i] = SA.lcp(1, i);
		// cerr << g[i] << ' ';
	}
	int sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += g[i];
		TT.a[i] = 0;
		// cerr << g[i] << ' ';
	}

	TT.a[1] = sum;
	TT.build(1, 1, N);
	for (int i = 1; i <= N; i++) {
		int l = 1, r = g[i];
		int x = i, y = x + g[i] - 1;
		if (i == 1) continue;
		if (r < x) {
			updata(l, r, -g[i], 1);
			updata(x, y, -g[i], 1);
		} else if (x <= r) {
			updata(l, x - 1, -g[i], 1);
			updata(x, y, -g[i], 1);
		}
		// for (int i = 1; i <= N; i++) {
		// 	b[i] = b[i - 1];
		// 	b[i] += TT.query(1, 1, N, i, i).sum;
		// 	cerr << b[i] << ' ';
		// } cerr << endl;
	}
	// updata(1, 2, -2, 1);
	// for (int i = 1; i <= 4 * N; i++) {
	// 	cerr << TT.tree[i].sum << ' ';
	// }
	// cerr << endl;
	for (int i = 1; i <= N; i++) {
		b[i] = b[i - 1];
		b[i] += TT.query(1, 1, N, i, i).sum;
		// cerr << b[i] << ' ';
		// cerr << TT.query(1, 1, N, i, i).sum << ' ';
	}
	// cerr << endl;
	for (int i = 1; i <= N; i++) {
		int x = g[i] + 1, y = i + g[i];
		if (y <= N && x <= N) {
			if (x >= i) {
				
			} else {
				if (y < N) mp[x][a[y]] += SA.lcp(x + 1, y + 1) + 1;
				else if (y == N) mp[x][a[y]] += 1;
			}
			
			mp[y][a[x]] += js(x, y);
			// cerr << x << ' ';
			// cerr << a[y] << ' ';
			// cerr << y << ' ';
			// cerr << a[x] << endl;
		}

	}
	ll jg = 0;
	for (int i = 1; i <= N; i++) {
		ans[i] = b[i];
		// int id = 0;
		for (auto it : mp[i]) {
			int ts = b[i] + it.second;
			if (it.first == a[i]) continue;
			if (ts > ans[i]) {
				ans[i] = ts;
				// id = it.first;
			}
			ans[i] = max(ans[i], ts);
			// cerr << i << ' ';
			// cerr << it.first << ' ';
			// cerr << it.second << endl;
		}
		jg += (1ll * ans[i]) ^ i;
		// cerr << id << ' ';
	}
	// cerr << endl;
	// for (int i = 1; i <= N; i++) {
	// 	cerr << b[i] << ' ';
	// } cerr << endl;
	// for (int i = 1; i <= N; i++) {
	// 	cerr << ans[i] << ' '; 
	// }
	// cerr << endl;
	cout << jg << endl;
	// SA.clear();
}
signed main() {
	// ld be, ed;
	// be = clock();
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	srand(time(NULL));
#ifdef MULTI_CASES
	int T;
	cin >> T;
	while (T--)
#endif
		Solve();
	// ed = clock();
	// cerr << (ed - be) / CLOCKS_PER_SEC << endl;
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 87232kb

input:

2
4
2 1 1 2
12
1 1 4 5 1 4 1 9 1 9 8 10

output:

15
217

result:

ok 2 lines

Test #2:

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

input:

10000
8
2 1 2 1 1 1 2 2
9
2 2 1 2 1 2 1 2 1
15
2 1 2 1 1 1 1 2 2 1 2 1 2 2 1
2
1 1
10
2 1 1 1 2 2 1 1 2 2
3
2 1 2
11
1 2 2 1 1 2 1 2 2 1 1
14
2 1 1 1 1 2 1 1 1 2 2 1 2 1
12
2 2 2 1 2 2 2 1 1 2 1 2
4
2 1 1 2
8
1 2 2 2 1 2 1 1
8
1 1 2 1 2 1 1 1
6
2 1 1 1 2 2
14
2 2 1 1 1 1 2 2 2 1 2 2 1 1
10
1 2 2 1 1...

output:

94
128
347
3
211
9
265
363
278
15
95
114
58
348
225
3
335
364
377
316
3
19
122
66
15
83
36
258
11
63
28
90
85
103
252
191
21
48
303
63
102
20
24
68
316
362
266
309
355
281
326
281
231
312
3
330
54
328
3
69
32
147
322
39
338
90
242
3
165
346
245
20
155
3
404
393
392
81
269
360
20
54
21
279
3
17
351
3...

result:

ok 10000 lines

Test #3:

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

input:

10000
17
1 2 2 2 2 2 2 2 1 1 2 2 1 2 1 2 2
17
2 1 1 1 1 2 2 2 1 1 1 1 1 2 2 2 2
13
2 2 2 1 2 2 2 2 1 1 1 1 1
12
2 2 1 2 1 2 2 1 1 1 1 1
13
2 2 2 1 1 1 1 2 2 2 2 1 1
20
2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 2 1 2 1 1
13
1 2 1 2 2 2 1 2 1 2 1 1 1
20
2 1 1 2 2 1 2 2 1 1 2 1 2 2 2 2 2 1 2 2
12
2 1 2 1 1 2 2 1 2...

output:

392
434
308
252
302
895
343
867
282
249
717
194
252
350
230
427
439
279
340
384
380
292
218
312
271
810
275
211
460
388
365
342
773
203
238
857
720
497
514
443
618
777
372
242
337
232
324
837
289
480
366
681
358
281
320
529
451
309
250
326
315
744
307
841
133
214
411
788
332
365
488
157
760
278
421
...

result:

ok 10000 lines

Test #4:

score: 0
Accepted
time: 48ms
memory: 85356kb

input:

10000
10
3 3 1 2 2 3 3 3 2 3
13
1 2 1 2 1 1 3 1 2 2 1 3 1
14
1 2 1 2 3 3 2 3 1 2 2 2 3 3
10
1 1 1 1 1 1 3 2 1 2
19
1 3 3 3 1 3 3 2 1 1 1 3 2 2 1 2 1 3 2
12
1 3 1 3 1 1 3 2 3 3 2 3
11
1 1 1 2 2 3 1 1 3 1 1
12
3 2 2 1 3 3 2 1 1 3 3 2
11
2 2 3 2 3 1 3 1 2 1 1
20
3 1 2 2 3 1 3 3 1 3 3 2 3 3 3 2 3 1 1 2
...

output:

191
285
325
207
420
281
215
280
151
754
365
199
94
418
318
377
414
285
373
362
111
358
332
117
185
326
89
404
229
386
307
285
421
232
321
329
506
372
386
364
153
582
313
356
152
129
424
366
382
280
363
370
273
294
388
389
807
388
459
280
114
310
211
368
150
166
793
211
793
393
102
427
399
408
584
38...

result:

ok 10000 lines

Test #5:

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

input:

10000
14
9 9 13 6 3 8 7 10 5 9 14 2 12 5
15
9 12 2 2 8 4 2 11 4 4 8 3 8 13 15
19
5 7 1 2 9 2 16 9 15 8 19 9 3 18 8 8 1 12 6
14
9 8 2 11 7 2 12 5 14 14 10 5 7 2
11
4 4 2 9 9 11 10 3 3 2 2
14
8 2 9 10 10 11 6 9 12 5 5 4 9 2
20
4 5 3 13 15 18 12 6 2 8 11 12 6 10 14 14 10 14 13 12
14
11 9 7 5 12 12 5 3 ...

output:

307
362
380
107
97
137
380
108
135
299
312
265
99
362
379
361
332
380
129
367
97
380
97
107
363
107
132
367
97
88
363
314
100
382
354
349
383
95
359
306
340
133
382
106
395
361
374
105
292
385
360
359
365
381
378
107
374
111
357
105
365
319
379
102
364
89
107
374
128
101
360
115
363
107
106
116
92
3...

result:

ok 10000 lines

Test #6:

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

input:

1331
128
1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 2 1 2 2 1 1 2 1 2 1 2 1 2 2 1 2 1 2 2 2 1 2 1 2 2 2 2 2 1 2 1 2 2 1 1 2 2 1 1 1 1 2 2 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 1 2 1 2 1 2 2 1 1 2 1 1 2 2 2 1 1 2 2 2 1 2 2 2 1 2 1 1 1 2 2 1 1 1 2 1 1 1 1 1 1 1 2 2 2 2
115
1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1...

output:

41073
22779
19964
77764
77960
62759
68522
21651
24781
42049
74437
19840
74378
68878
20605
34809
20231
20004
50820
29156
52217
53156
23540
67367
57400
46500
19870
60423
66032
51371
59540
51300
48277
22751
77712
65779
21946
37124
65635
40091
27911
55656
54005
18564
25013
64077
46260
21753
62329
69899
...

result:

ok 1331 lines

Test #7:

score: 0
Accepted
time: 81ms
memory: 88348kb

input:

131
1471
2 3 2 3 1 2 2 1 1 1 1 2 1 3 2 1 1 1 2 2 2 2 2 2 3 1 3 2 1 2 3 2 3 1 3 1 2 1 3 1 3 1 3 2 2 1 3 3 3 1 1 1 3 2 2 2 1 2 1 3 1 3 3 1 2 2 1 2 3 1 3 1 3 3 2 1 3 3 2 3 2 2 2 1 3 2 1 2 2 1 3 1 1 3 2 3 1 1 2 1 2 3 2 1 3 3 2 2 2 2 1 1 1 2 3 1 1 3 3 2 3 2 1 3 1 3 3 2 2 1 2 1 1 2 1 3 2 1 2 2 3 2 2 1 1 3...

output:

4103972
1822893
4056671
4581950
1797128
5452459
5578024
6135700
4325429
1769997
1239977
1589696
5346072
1818448
5380837
3882106
3814365
1823901
4911982
5946018
5208392
4261893
1767953
5781183
4624024
1795249
1600563
1677098
4679442
4113663
1685240
1576241
5128042
1618422
4440641
4326472
5703872
3748...

result:

ok 131 lines

Test #8:

score: 0
Accepted
time: 59ms
memory: 85736kb

input:

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

output:

1585911
1671116
2074604
2071604
2066710
1571959
1699180
1597972
1573443
2062834
1968749
1670339
1696389
1700722
1574014
1673122
6093159
1965764
1966052
2084891
1597710
1989656
2054890
1659456
1601397
1982947
1675608
2075393
1694022
1992153
6012239
1675824
1987812
1589514
2063346
1986943
1571712
1671...

result:

ok 131 lines

Test #9:

score: 0
Accepted
time: 74ms
memory: 93936kb

input:

14
554
232 178 169 417 93 38 93 537 212 211 313 227 432 269 475 489 459 286 318 534 118 160 223 534 275 382 482 331 3 279 73 513 403 277 34 497 462 397 280 218 395 498 201 548 8 520 495 397 545 528 401 58 418 3 494 260 251 496 212 552 243 151 78 385 441 73 271 337 283 39 162 1 501 357 126 452 416 34...

output:

394027
127388087
408947528
132597056
403149770
403022905
410881136
404226176
134192573
106965642
108543004
108541542
109002658
408924618

result:

ok 14 lines

Test #10:

score: 0
Accepted
time: 125ms
memory: 162320kb

input:

1
200000
86045 57533 29508 181370 17680 186294 134595 82393 109229 189798 133533 194579 11412 112604 572 32659 76824 177596 106427 60375 98302 93821 34541 125615 108609 22507 166292 195457 151376 54630 166314 85832 192590 85410 149595 46737 54738 198246 56457 189628 135013 63949 28359 65601 162502 4...

output:

32219923494

result:

ok single line: '32219923494'

Test #11:

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

input:

14
11651
1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 2...

output:

638847269
762853260
1772624286
1459420676
912238973
902965748
1461240613
1591772671
978996498
1450864204
913255377
276655999
898402422
1129219843

result:

ok 14 lines

Test #12:

score: 0
Accepted
time: 185ms
memory: 152076kb

input:

1
200000
1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 2...

output:

241162217617

result:

ok single line: '241162217617'

Test #13:

score: 0
Accepted
time: 164ms
memory: 148560kb

input:

1
200000
1 2 3 2 3 1 3 1 2 2 3 1 3 1 2 1 2 3 3 1 2 1 2 3 2 3 1 2 3 1 3 1 2 1 2 3 3 1 2 1 2 3 2 3 1 1 2 3 2 3 1 3 1 2 3 1 2 1 2 3 2 3 1 1 2 3 2 3 1 3 1 2 2 3 1 3 1 2 1 2 3 2 3 1 3 1 2 1 2 3 3 1 2 1 2 3 2 3 1 1 2 3 2 3 1 3 1 2 3 1 2 1 2 3 2 3 1 1 2 3 2 3 1 3 1 2 2 3 1 3 1 2 1 2 3 1 2 3 2 3 1 3 1 2 2 3...

output:

179830061352

result:

ok single line: '179830061352'

Test #14:

score: 0
Accepted
time: 191ms
memory: 132156kb

input:

2
147441
101973 109734 101973 101973 109734 101973 109734 101973 101973 109734 101973 101973 109734 101973 109734 101973 101973 109734 101973 109734 101973 101973 109734 101973 101973 109734 101973 109734 101973 101973 109734 101973 101973 109734 101973 109734 101973 101973 109734 101973 109734 1019...

output:

319151712710
36323502547

result:

ok 2 lines

Test #15:

score: 0
Accepted
time: 208ms
memory: 147144kb

input:

1
200000
90579 86359 90579 90579 86359 90579 86359 90579 90579 86359 90579 90579 86359 90579 86359 90579 90579 86359 90579 86359 90579 90579 86359 90579 90579 86359 90579 86359 90579 90579 86359 90579 90579 86359 90579 86359 90579 90579 86359 90579 86359 90579 90579 86359 90579 90579 86359 90579 863...

output:

605969434886

result:

ok single line: '605969434886'

Test #16:

score: 0
Accepted
time: 187ms
memory: 148244kb

input:

1
200000
1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 2 1 1 2 1...

output:

142983226845641

result:

ok single line: '142983226845641'

Test #17:

score: -100
Wrong Answer
time: 190ms
memory: 142896kb

input:

1
200000
1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2...

output:

-33696818069283

result:

wrong answer 1st lines differ - expected: '666704973725917', found: '-33696818069283'