QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#112799#2788. Horsesminhcool100 ✓580ms38448kbC++173.6kb2023-06-13 16:43:292023-06-14 23:10: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-06-14 23:10:26]
  • 评测
  • 测评结果:100
  • 用时:580ms
  • 内存:38448kb
  • [2023-06-13 16:43:29]
  • 提交

answer

//#define local
#ifndef local
#include "horses.h"
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef pair<ii, ii> iiii;

const ll N = 1e6 + 5;

const ll oo = 1e18 + 7, mod = 1e9 + 7;

mt19937 rng(1);

ll rnd(ll l, ll r){
	ll temp = rng() % (r - l + 1);
	return abs(temp) + l;
}

ll n;
ll x[N], y[N];

ll tol[N << 2], maxi[N << 2];
 
ll get1[35], get2[35];

void upd(ll id, ll l, ll r, ll pos, ll val, ll type){
	if(l == r){
		if(type == 1) tol[id] = (x[pos] > 1);
		else maxi[id] = val;
		return;
	}
	ll mid = (l + r) >> 1;
	if(pos <= mid) upd(id << 1, l, mid, pos, val, type);
	else upd(id << 1 | 1, mid + 1, r, pos, val, type);
	tol[id] = tol[id << 1] + tol[id << 1 | 1];
	maxi[id] = max(maxi[id << 1], maxi[id << 1 | 1]);
}

ll get_pos(ll id, ll l, ll r, ll cnt){
	if(l == r){
		if(tol[id] < cnt) return -1;
		return l;
	}
	ll mid = (l + r) >> 1;
	if(tol[id << 1 | 1] >= cnt) return get_pos(id << 1 | 1, mid + 1, r, cnt);
	else return get_pos(id << 1, l, mid, cnt - tol[id << 1 | 1]);
}

ll maxii(ll id, ll l, ll r, ll L, ll R){
	if(l > R || r < L) return -oo;
	if(l >= L && r <= R) return maxi[id];                                 
	ll mid = (l + r) >> 1;
	return max(maxii(id << 1, l, mid, L, R), maxii(id << 1 | 1, mid + 1, r, L, R));
}

ll binpw(ll base, ll pw){
	ll ans = 1;
	while(pw){
		if(pw & 1) ans = (ans * base) % mod;
		base = (base * base) % mod;
		pw >>= 1;
	}
	return ans;
}

ll total = 1;

ll cal(){
	ll cnt = 0, lst_pos = n + 1, tol = 1;
	//for(int i = 0; i < n; i++) cout << x[i] << " ";
	//cout << "\n";
	//for(int i = 0; i < n; i++) cout << y[i] << " ";
	//cout << "\n";
	while(1){
		cnt++;
		ll temp = get_pos(1, 0, n - 1, cnt);
		//if(temp < 0) break;
		temp = max(temp, 0LL);
		get1[cnt] = x[temp], get2[cnt] = maxii(1, 0, n - 1, temp, lst_pos - 1);
	//	cout << cnt << " " << get1[cnt] << " " << get2[cnt] << "\n";
		lst_pos = temp;
		tol *= x[temp];
		if(!temp) break;
		if(tol > 1e9) break;
	}
	if(tol > 1e9){
		tol /= get1[cnt];
	//	cnt--;
	}
	assert(tol <= 1e9);
	ii mx = {-1, -1};
	ll num1 = tol;
	for(ll i = 1; i <= cnt; i++){
		mx = max(mx, {num1 * get2[i], i});
		num1 /= get1[i];
	}
//	cout << total << " " << tol << " " << mx.fi << "\n";
    mx.fi %= mod;
	ll temp = (total * binpw(tol, mod - 2)) % mod;
	temp = (temp * mx.fi) % mod;
	return temp;
}

int init(int N, int X[], int Y[]) {
	n = N;
	for(ll i = 0; i < n; i++) x[i] = X[i];
	for(ll i = 0; i < n; i++) y[i] = Y[i];
	for(ll i = 0; i < n; i++) upd(1, 0, n - 1, i, x[i], 1);
	for(ll i = 0; i < n; i++) upd(1, 0, n - 1, i, y[i], 2);
	for(ll i = 0; i < n; i++) total = (total * x[i]) % mod;
	return (int)cal();
}

int updateX(int pos, int val) {	
	total = (total * binpw(x[pos], mod - 2)) % mod;
	total = (total * val) % mod;
	x[pos] = val;
	upd(1, 0, n - 1, pos, val, 1);
	//update1(pos, val);
	return cal();
}

int updateY(int pos, int val) {
	y[pos] = val;
	upd(1, 0, n - 1, pos, val, 2);
	//update2(pos, val);
	return cal();
}


#ifdef local
void process(){
	ll n;
	cin >> n;
	int x[n], y[n];
	for(ll i = 0; i < n; i++) cin >> x[i];
	for(ll i = 0; i < n; i++) cin >> y[i];
	cout << init(n, x, y) << "\n";
	ll m;
	cin >> m;
	while(m--){
		ll a, b, c;
		cin >> a >> b >> c;
		if(a == 1) cout << updateX(b, c) << "\n";
		else cout << updateY(b, c) << "\n";
	}
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	process();
}
#endif

详细

Subtask #1:

score: 17
Accepted

Test #1:

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

input:

1
2
3
0

output:

6

result:

ok single line: '6'

Test #2:

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

input:

10
2 1 1 5 2 1 1 10 5 1
3 5 7 9 4 1 4 10 10 9
0

output:

10000

result:

ok single line: '10000'

Test #3:

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

input:

10
10 10 10 1 1 1 1 1 1 1
2 3 4 2 7 6 5 4 3 2
0

output:

7000

result:

ok single line: '7000'

Test #4:

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

input:

10
9 1 1 1 1 1 1 1 1 2
4 1 1 1 1 1 1 1 1 2
0

output:

36

result:

ok single line: '36'

Test #5:

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

input:

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

output:

10

result:

ok single line: '10'

Test #6:

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

input:

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

output:

10

result:

ok single line: '10'

Test #7:

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

input:

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

output:

9000

result:

ok single line: '9000'

Test #8:

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

input:

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

output:

9000

result:

ok single line: '9000'

Test #9:

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

input:

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

output:

8

result:

ok single line: '8'

Test #10:

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

input:

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

output:

9

result:

ok single line: '9'

Test #11:

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

input:

2
2 5
9 7
0

output:

70

result:

ok single line: '70'

Test #12:

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

input:

1
1
1
0

output:

1

result:

ok single line: '1'

Test #13:

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

input:

7
7 1 1 6 2 3 2
7 6 5 4 3 7 1
0

output:

1764

result:

ok single line: '1764'

Test #14:

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

input:

1
10
10
0

output:

100

result:

ok single line: '100'

Test #15:

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

input:

2
1 4
7 2
0

output:

8

result:

ok single line: '8'

Test #16:

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

input:

10
1 10 1 10 1 1 10 1 1 1
7 3 10 10 4 10 1 4 5 10
0

output:

10000

result:

ok single line: '10000'

Test #17:

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

input:

6
1 1 1 1 1 1
1 1 1 1 1 1
0

output:

1

result:

ok single line: '1'

Test #18:

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

input:

4
1 2 4 8
8 4 2 1
0

output:

64

result:

ok single line: '64'

Test #19:

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

input:

6
1 2 2 3 1 1
7 1 1 2 1 1
0

output:

24

result:

ok single line: '24'

Test #20:

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

input:

10
2 1 1 5 2 1 1 10 5 1
3 5 7 9 4 1 4 10 7 9
0

output:

9000

result:

ok single line: '9000'

Subtask #2:

score: 17
Accepted

Dependency #1:

100%
Accepted

Test #21:

score: 17
Accepted
time: 2ms
memory: 9960kb

input:

10
10 10 10 10 10 10 1 1 1 1
1 1 1 1 9 5 4 7 3 2
5
1 5 1
2 5 123456789
1 5 1
1 8 987654321
1 9 777777777

output:

7000000
900000
678813585
678813585
294225928
75803567

result:

ok 6 lines

Test #22:

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

input:

10
3 2 7 5 11 13 107 23 51 3
1 1 1 1 1000000000 1 1 1 1 1
16
1 1 1
1 2 1
1 0 1
1 8 1
1 7 1
1 9 1
1 1 25
1 8 123456789
1 4 1
1 6 1
1 3 1
1 5 1
1 5 12345
1 6 123456
1 7 1234567
2 4 3

output:

999983837
999991922
999998852
999999622
999999622
999999622
999999622
999990382
539408243
49037113
617280725
123456145
999999832
851238418
489396978
354709175
354709175

result:

ok 17 lines

Test #23:

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

input:

1000
179278145 423054674 671968267 409599985 828900464 393298292 569389961 360810107 205374067 618910650 76768983 62623743 225944805 498579132 917750714 600860488 642568763 21949846 852642376 283772010 299085842 669257630 544180666 249770466 320727298 612199337 15873453 726595389 219129403 876893450...

output:

394559852
394559852
394559852
394559852
868802752
868802752
868802752
868802752
165967503
244287754
244287754
270995710
270995710
270995710
247981131
247981131
237849527
24662481
24662481
451435926
989677577
989677577
704081481
704081481
704081481
704081481
704081481
631761803
631761803
631761803
80...

result:

ok 1001 lines

Test #24:

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

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

858314903
362189740
362189740
362189740
362189740
362189740
347762296
347762296
347762296
347762296
347762296
347762296
297139175
297139175
56337247
56337247
56337247
919555391
919555391
223551221
223551221
223551221
674943421
674943421
674943421
674943421
674943421
160231649
160231649
242692758
242...

result:

ok 1001 lines

Test #25:

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

input:

1000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

426490853
426490853
426490853
426490853
224787023
224787023
110744712
110744712
110744712
682644373
841322190
841322190
594096835
973115198
7681374
712091041
712091041
712091041
712091041
712091041
712091041
712091041
326844140
326844140
163422070
326844140
326844140
326844140
163422070
163422070
16...

result:

ok 1001 lines

Test #26:

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

input:

1000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...

output:

426490853
224787023
110744712
110744712
110744712
110744712
110744712
110744712
110744712
110744712
841322190
188193663
188193663
973115198
973115198
486557599
486557599
486557599
501920347
501920347
214011381
214011381
214011381
214011381
214011381
214011381
214011381
214011381
540855521
81711035
8...

result:

ok 1001 lines

Test #27:

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

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
111838200
111838200
141345155
141345155
141345155
347215940
347215940
462493672
462493672
462493672
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
47524696...

result:

ok 1001 lines

Test #28:

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

input:

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

output:

894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
894825221
...

result:

ok 1001 lines

Test #29:

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

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
2
2
4
8
16
16
32
32
16
8
4
2
2
2
2
4
4
4
8
8
8
8
4
2
4
4
8
16
32
32
16
16
8
4
2
2
2
2
2
2
4
2
2
2
2
2
2
4
4
4
2
4
4
8
16
32
32
16
8
4
4
2
2
4
4
2
2
4
4
4
8
16
16
8
16
16
16
8
16
8
4
2
2
2
4
8
16
32
32
16
16
16
8
4
8
8
4
4
4
2
1
1
1
1
1
2
2
4
4
8
8
8
8
16
16
16
32
16
8
8
4
2
4
4
2
2
4
2
4
4
8
8
8
4...

result:

ok 1001 lines

Test #30:

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

input:

1000
449878747 910674510 165143519 796141357 640922692 573949623 473255861 694971928 923936963 520980628 407779878 356558322 959023188 533793940 402247935 460440718 261337138 763084309 477743089 457285505 21664165 849032387 495576190 421984304 467773902 838138184 169975811 805107419 502174869 375370...

output:

392927667
3019699
252703129
967234835
690465334
745063314
648310471
594657147
797483498
960494972
217493779
741093774
398194406
336083786
400370081
595436661
30471347
875039519
60963593
516858978
480652068
726643394
673856666
237413719
45909014
783589282
600072636
214213285
409343465
506112870
19369...

result:

ok 1001 lines

Test #31:

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

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
536870912
536870912
536870912
536870912
536...

result:

ok 1001 lines

Test #32:

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

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
9999...

result:

ok 1001 lines

Subtask #3:

score: 20
Accepted

Test #33:

score: 20
Accepted
time: 519ms
memory: 38124kb

input:

500000
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

967631222
967631222
795463654
885679347
618832158
618832158
618832158
618832158
618832158
582471866
864166718
864166718
864166718
864166718
864166718
813424701
813424701
813424701
813424701
813424701
815547130
815547130
815547130
815547130
815547130
715585103
715585103
715585103
715585103
715585103
...

result:

ok 100001 lines

Test #34:

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

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

764523385
560650427
560650427
711685442
711685442
711685442
630166054
630166054
630166054
604940491
56866480
384893091
501798659
560422885
560422885
18199764
63591615
212319888
212319888
39499230
828983454
828983454
634555752
4896305
181214713
231675794
231675794
966365836
181367397
181367397
987190...

result:

ok 100001 lines

Test #35:

score: 0
Accepted
time: 230ms
memory: 36208kb

input:

500000
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

967631222
192947708
884245369
884245369
884245369
884245369
884245369
649885822
981487169
321173457
159089267
159089267
159089267
747556995
964496384
964496384
964496384
928334020
928334020
928334020
928334020
459124375
459124375
404955269
251629123
80789828
80789828
463250667
463250667
120836466
57...

result:

ok 100001 lines

Test #36:

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

input:

500000
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

628833504
223286077
463897870
972304401
127408916
377483838
722400213
221924185
818717195
473021697
502484429
318341012
230123148
522240493
607202268
818940989
569566927
384659940
448632730
578079312
667605482
963648869
939506632
965323855
498894254
695643284
699407581
168605135
70361400
795950777
1...

result:

ok 100001 lines

Subtask #4:

score: 23
Accepted

Dependency #2:

100%
Accepted

Test #37:

score: 23
Accepted
time: 129ms
memory: 38220kb

input:

500000
179278145 423054674 671968267 409599985 828900464 393298292 569389961 360810107 205374067 618910650 76768983 62623743 225944805 498579132 917750714 600860488 642568763 21949846 852642376 283772010 299085842 669257630 544180666 249770466 320727298 612199337 15873453 726595389 219129403 8768934...

output:

394559852
394559852
394559852
394559852
394559852
394559852
394559852
394559852
394559852
647269906
647269906
574999978
474915344
553750431
154074481
141866780
571605103
254682947
491792611
491792611
924773703
259172085
310674079
310674079
310674079
310674079
310674079
787939311
607650198
607650198
...

result:

ok 10001 lines

Test #38:

score: 0
Accepted
time: 138ms
memory: 36204kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

981371950
981371950
981371950
981371950
731349784
986666155
233780009
233780009
233780009
709099409
709099409
709099409
709099409
709099409
873258370
873258370
858142799
858142799
858142799
858142799
708831607
708831607
708831607
708831607
708831607
604002837
604002837
409237230
925360574
925360574
...

result:

ok 10001 lines

Test #39:

score: 0
Accepted
time: 150ms
memory: 36404kb

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

764523385
764523385
764523385
764523385
462210949
462210949
362541296
362541296
362541296
467845348
233922674
233922674
109439619
397302969
886484873
461004327
461004327
461004327
461004327
461004327
461004327
461004327
934142246
934142246
467071123
934142246
934142246
934142246
467071123
467071123
...

result:

ok 10001 lines

Test #40:

score: 0
Accepted
time: 137ms
memory: 38396kb

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

764523385
462210949
362541296
362541296
362541296
362541296
362541296
362541296
362541296
362541296
233922674
218879238
218879238
397302969
397302969
698651488
698651488
698651488
471621220
471621220
932625547
932625547
932625547
932625547
932625547
932625547
932625547
932625547
866767786
733535565
...

result:

ok 10001 lines

Test #41:

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

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
111838200
111838200
141345155
141345155
141345155
347215940
347215940
462493672
462493672
462493672
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
47524696...

result:

ok 10001 lines

Test #42:

score: 0
Accepted
time: 118ms
memory: 36140kb

input:

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

output:

6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020...

result:

ok 10001 lines

Test #43:

score: 0
Accepted
time: 120ms
memory: 38248kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
2
2
4
8
16
16
32
32
16
8
4
2
2
2
2
4
4
4
8
8
8
8
4
2
4
4
8
16
32
32
16
16
8
4
2
2
2
2
2
2
4
2
2
2
2
2
2
4
4
4
2
4
4
8
16
32
32
16
8
4
4
2
2
4
4
2
2
4
4
4
8
16
16
8
16
16
16
8
16
8
4
2
2
2
4
8
16
32
32
16
16
16
8
4
8
8
4
4
4
2
1
1
1
1
1
2
2
4
4
8
8
8
8
16
16
16
32
16
8
8
4
2
4
4
2
2
4
2
4
4
8
8
8
4...

result:

ok 10001 lines

Test #44:

score: 0
Accepted
time: 134ms
memory: 38248kb

input:

500000
449878747 910674510 165143519 796141357 640922692 573949623 473255861 694971928 923936963 520980628 407779878 356558322 959023188 533793940 402247935 460440718 261337138 763084309 477743089 457285505 21664165 849032387 495576190 421984304 467773902 838138184 169975811 805107419 502174869 3753...

output:

894951954
971686433
899098570
86599296
692272710
576670050
25769293
322050104
70969013
594386575
942524454
196540045
526338485
22430967
587913922
907618506
664401257
97212286
331804416
467244333
243494370
604725263
813178346
739290120
429729609
546873727
539044437
824432313
217620000
710282645
44867...

result:

ok 10001 lines

Test #45:

score: 0
Accepted
time: 137ms
memory: 36224kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
536870912
536870912
536870912
536870912
536...

result:

ok 10001 lines

Test #46:

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

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
9999...

result:

ok 10001 lines

Test #47:

score: 0
Accepted
time: 124ms
memory: 38264kb

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

306436104
854947293
160421705
611910523
160421705
15368991
160421705
611910523
160421705
15368991
160421705
611910523
160421705
15368991
160421705
611910523
160421705
15368991
160421705
611910523
160421705
15368991
160421705
611910523
160421705
15368991
160421705
611910523
160421705
15368991
1604217...

result:

ok 1001 lines

Test #48:

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

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

306436104
854947293
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
...

result:

ok 1001 lines

Test #49:

score: 0
Accepted
time: 127ms
memory: 38396kb

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

306436104
854947293
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
611910523
699326312
611910523
160421705
...

result:

ok 1001 lines

Subtask #5:

score: 23
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #50:

score: 23
Accepted
time: 210ms
memory: 38400kb

input:

500000
179278145 423054674 671968267 409599985 828900464 393298292 569389961 360810107 205374067 618910650 76768983 62623743 225944805 498579132 917750714 600860488 642568763 21949846 852642376 283772010 299085842 669257630 544180666 249770466 320727298 612199337 15873453 726595389 219129403 8768934...

output:

394559852
394559852
394559852
394559852
394559852
394559852
394559852
394559852
394559852
647269906
647269906
574999978
474915344
553750431
154074481
141866780
571605103
254682947
491792611
491792611
924773703
259172085
310674079
310674079
310674079
310674079
310674079
787939311
607650198
607650198
...

result:

ok 100001 lines

Test #51:

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

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

981371950
981371950
981371950
981371950
731349784
986666155
233780009
233780009
233780009
709099409
709099409
709099409
709099409
709099409
873258370
873258370
858142799
858142799
858142799
858142799
708831607
708831607
708831607
708831607
708831607
604002837
604002837
409237230
925360574
925360574
...

result:

ok 100001 lines

Test #52:

score: 0
Accepted
time: 264ms
memory: 38396kb

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

764523385
764523385
764523385
764523385
462210949
462210949
362541296
362541296
362541296
467845348
233922674
233922674
109439619
397302969
886484873
461004327
461004327
461004327
461004327
461004327
461004327
461004327
934142246
934142246
467071123
934142246
934142246
934142246
467071123
467071123
...

result:

ok 100001 lines

Test #53:

score: 0
Accepted
time: 189ms
memory: 38208kb

input:

500000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

764523385
462210949
362541296
362541296
362541296
362541296
362541296
362541296
362541296
362541296
233922674
218879238
218879238
397302969
397302969
698651488
698651488
698651488
471621220
471621220
932625547
932625547
932625547
932625547
932625547
932625547
932625547
932625547
866767786
733535565
...

result:

ok 100001 lines

Test #54:

score: 0
Accepted
time: 580ms
memory: 38124kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
111838200
111838200
141345155
141345155
141345155
347215940
347215940
462493672
462493672
462493672
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
475246965
47524696...

result:

ok 100001 lines

Test #55:

score: 0
Accepted
time: 286ms
memory: 38248kb

input:

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

output:

6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020158
6020...

result:

ok 100001 lines

Test #56:

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

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1
2
2
4
8
16
16
32
32
16
8
4
2
2
2
2
4
4
4
8
8
8
8
4
2
4
4
8
16
32
32
16
16
8
4
2
2
2
2
2
2
4
2
2
2
2
2
2
4
4
4
2
4
4
8
16
32
32
16
8
4
4
2
2
4
4
2
2
4
4
4
8
16
16
8
16
16
16
8
16
8
4
2
2
2
4
8
16
32
32
16
16
16
8
4
8
8
4
4
4
2
1
1
1
1
1
2
2
4
4
8
8
8
8
16
16
16
32
16
8
8
4
2
4
4
2
2
4
2
4
4
8
8
8
4...

result:

ok 100001 lines

Test #57:

score: 0
Accepted
time: 192ms
memory: 38340kb

input:

500000
449878747 910674510 165143519 796141357 640922692 573949623 473255861 694971928 923936963 520980628 407779878 356558322 959023188 533793940 402247935 460440718 261337138 763084309 477743089 457285505 21664165 849032387 495576190 421984304 467773902 838138184 169975811 805107419 502174869 3753...

output:

894951954
971686433
899098570
86599296
692272710
576670050
25769293
322050104
70969013
594386575
942524454
196540045
526338485
22430967
587913922
907618506
664401257
97212286
331804416
467244333
243494370
604725263
813178346
739290120
429729609
546873727
539044437
824432313
217620000
710282645
44867...

result:

ok 100001 lines

Test #58:

score: 0
Accepted
time: 400ms
memory: 38280kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
536870912
536870912
536870912
536870912
536...

result:

ok 100001 lines

Test #59:

score: 0
Accepted
time: 546ms
memory: 38192kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
999999993
1000000000
1000000000
73741817
9999...

result:

ok 100001 lines