QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#112796#2788. Horsesminhcool17 4ms9844kbC++173.4kb2023-06-13 16:33:292023-06-13 16:33:32

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-13 16:33:32]
  • 评测
  • 测评结果:17
  • 用时:4ms
  • 内存:9844kb
  • [2023-06-13 16:33: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 = 3e5 + 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;
	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);
		lst_pos = temp;
		tol *= x[temp];
		if(!temp) break;
		if(tol > 1e9) break;
	}
	if(tol > 1e9){
		tol /= get1[cnt];
		cnt--;
	}
	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";
	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: 9636kb

input:

1
2
3
0

output:

6

result:

ok single line: '6'

Test #2:

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

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: 9784kb

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: 0ms
memory: 9624kb

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: 3ms
memory: 9820kb

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: 1ms
memory: 9844kb

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: 3ms
memory: 9656kb

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: 1ms
memory: 9584kb

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: 3ms
memory: 9820kb

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: 3ms
memory: 9844kb

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: 1ms
memory: 9816kb

input:

2
2 5
9 7
0

output:

70

result:

ok single line: '70'

Test #12:

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

input:

1
1
1
0

output:

1

result:

ok single line: '1'

Test #13:

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

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: 0ms
memory: 9644kb

input:

1
10
10
0

output:

100

result:

ok single line: '100'

Test #15:

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

input:

2
1 4
7 2
0

output:

8

result:

ok single line: '8'

Test #16:

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

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: 1ms
memory: 9624kb

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: 2ms
memory: 9636kb

input:

4
1 2 4 8
8 4 2 1
0

output:

64

result:

ok single line: '64'

Test #19:

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

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: 3ms
memory: 9652kb

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: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #21:

score: 17
Accepted
time: 1ms
memory: 9628kb

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: -17
Wrong Answer
time: 4ms
memory: 9636kb

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
86419704
851238418
489396978
354709175
354709175

result:

wrong answer 13th lines differ - expected: '999999832', found: '86419704'

Subtask #3:

score: 0
Runtime Error

Test #33:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%