Submission #91523

# Submission time Handle Problem Language Result Execution time Memory
91523 2018-12-28T05:38:54 Z turbat Horses (IOI15_horses) C++14
100 / 100
531 ms 201768 KB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
#define M 500005
int n, x[M], y[M];
long long tmp, mod = 1e9 + 7;
struct segment{
	int ans, mul;
	double a = 0, m = 0;
} s[4 * M];
void update(int node, int l, int r, int idx, int valx, int valy){
	if (idx < l || r < idx) return;
	if (l == r){
		if (valx) x[l] = valx;
		if (valy) y[l] = valy;
		tmp = (1ll * x[l] * y[l]) % mod;
		s[node].ans = int(tmp);
		s[node].mul = x[l];
		s[node].m = log10(x[l]);
		s[node].a = log10(1ll * x[l] * y[l]);
		return;
	}
	int mid = (l + r)/2;
	update(node * 2, l, mid, idx, valx, valy);
	update(node * 2 + 1, mid + 1, r, idx, valx, valy);
	s[node].m = s[node * 2].m + s[node * 2 + 1].m;
	tmp = (1ll * s[node * 2].mul * s[node * 2 + 1].mul) % mod;
	s[node].mul = int(tmp);
	if (s[node * 2].a > s[node * 2 + 1].a + s[node * 2].m){
		s[node].ans = s[node * 2].ans;
		s[node].a = s[node * 2].a;
	}
	else{
		tmp = (1ll * s[node * 2 + 1].ans * s[node * 2].mul ) % mod;
		s[node].ans = int(tmp);
		s[node].a =  s[node * 2 + 1].a + s[node * 2].m;
	}
}
int init(int N, int X[], int Y[]) {
	n = N;
	for (int i = 0;i < n;i++)
		update(1, 0, n - 1, i, X[i], Y[i]);
	return s[1].ans;
}
int updateX(int pos, int val) {	
	update(1, 0, n - 1, pos, val, 0);
	return s[1].ans;
}
int updateY(int pos, int val) {
	update(1, 0, n - 1, pos, 0, val);
	return s[1].ans;
}
# Verdict Execution time Memory Grader output
1 Correct 36 ms 47352 KB Output is correct
2 Correct 36 ms 47460 KB Output is correct
3 Correct 37 ms 47460 KB Output is correct
4 Correct 36 ms 47492 KB Output is correct
5 Correct 31 ms 47492 KB Output is correct
6 Correct 31 ms 47592 KB Output is correct
7 Correct 37 ms 47592 KB Output is correct
8 Correct 37 ms 47592 KB Output is correct
9 Correct 36 ms 47592 KB Output is correct
10 Correct 32 ms 47592 KB Output is correct
11 Correct 31 ms 47592 KB Output is correct
12 Correct 32 ms 47592 KB Output is correct
13 Correct 31 ms 47612 KB Output is correct
14 Correct 36 ms 47612 KB Output is correct
15 Correct 31 ms 47612 KB Output is correct
16 Correct 38 ms 47612 KB Output is correct
17 Correct 37 ms 47632 KB Output is correct
18 Correct 37 ms 47632 KB Output is correct
19 Correct 35 ms 47676 KB Output is correct
20 Correct 37 ms 47676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 47684 KB Output is correct
2 Correct 39 ms 47684 KB Output is correct
3 Correct 37 ms 47684 KB Output is correct
4 Correct 36 ms 47684 KB Output is correct
5 Correct 37 ms 47684 KB Output is correct
6 Correct 37 ms 47684 KB Output is correct
7 Correct 37 ms 47696 KB Output is correct
8 Correct 38 ms 47696 KB Output is correct
9 Correct 37 ms 47696 KB Output is correct
10 Correct 37 ms 47708 KB Output is correct
11 Correct 36 ms 47708 KB Output is correct
12 Correct 37 ms 47708 KB Output is correct
13 Correct 36 ms 47708 KB Output is correct
14 Correct 38 ms 47724 KB Output is correct
15 Correct 36 ms 47724 KB Output is correct
16 Correct 37 ms 47724 KB Output is correct
17 Correct 37 ms 47724 KB Output is correct
18 Correct 37 ms 47724 KB Output is correct
19 Correct 37 ms 47724 KB Output is correct
20 Correct 38 ms 47724 KB Output is correct
21 Correct 37 ms 47724 KB Output is correct
22 Correct 38 ms 47724 KB Output is correct
23 Correct 32 ms 47760 KB Output is correct
24 Correct 32 ms 47780 KB Output is correct
25 Correct 49 ms 47816 KB Output is correct
26 Correct 32 ms 47892 KB Output is correct
27 Correct 32 ms 47892 KB Output is correct
28 Correct 32 ms 47924 KB Output is correct
29 Correct 32 ms 47940 KB Output is correct
30 Correct 36 ms 47940 KB Output is correct
31 Correct 32 ms 47972 KB Output is correct
32 Correct 32 ms 48004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 421 ms 56808 KB Output is correct
2 Correct 531 ms 69524 KB Output is correct
3 Correct 465 ms 73064 KB Output is correct
4 Correct 463 ms 80752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 80752 KB Output is correct
2 Correct 37 ms 80752 KB Output is correct
3 Correct 39 ms 80752 KB Output is correct
4 Correct 38 ms 80752 KB Output is correct
5 Correct 37 ms 80752 KB Output is correct
6 Correct 36 ms 80752 KB Output is correct
7 Correct 36 ms 80752 KB Output is correct
8 Correct 31 ms 80752 KB Output is correct
9 Correct 37 ms 80752 KB Output is correct
10 Correct 36 ms 80752 KB Output is correct
11 Correct 36 ms 80752 KB Output is correct
12 Correct 37 ms 80752 KB Output is correct
13 Correct 36 ms 80752 KB Output is correct
14 Correct 31 ms 80752 KB Output is correct
15 Correct 36 ms 80752 KB Output is correct
16 Correct 37 ms 80752 KB Output is correct
17 Correct 37 ms 80752 KB Output is correct
18 Correct 37 ms 80752 KB Output is correct
19 Correct 37 ms 80752 KB Output is correct
20 Correct 38 ms 80752 KB Output is correct
21 Correct 37 ms 80752 KB Output is correct
22 Correct 31 ms 80752 KB Output is correct
23 Correct 32 ms 80752 KB Output is correct
24 Correct 40 ms 80752 KB Output is correct
25 Correct 38 ms 80752 KB Output is correct
26 Correct 38 ms 80752 KB Output is correct
27 Correct 38 ms 80752 KB Output is correct
28 Correct 38 ms 80752 KB Output is correct
29 Correct 37 ms 80752 KB Output is correct
30 Correct 38 ms 80752 KB Output is correct
31 Correct 38 ms 80752 KB Output is correct
32 Correct 37 ms 80752 KB Output is correct
33 Correct 327 ms 84108 KB Output is correct
34 Correct 325 ms 87976 KB Output is correct
35 Correct 363 ms 99128 KB Output is correct
36 Correct 369 ms 109668 KB Output is correct
37 Correct 364 ms 111764 KB Output is correct
38 Correct 322 ms 114712 KB Output is correct
39 Correct 345 ms 116876 KB Output is correct
40 Correct 383 ms 122772 KB Output is correct
41 Correct 354 ms 124832 KB Output is correct
42 Correct 342 ms 126888 KB Output is correct
43 Correct 381 ms 133052 KB Output is correct
44 Correct 383 ms 139268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 139268 KB Output is correct
2 Correct 39 ms 139268 KB Output is correct
3 Correct 43 ms 139268 KB Output is correct
4 Correct 36 ms 139268 KB Output is correct
5 Correct 37 ms 139268 KB Output is correct
6 Correct 37 ms 139268 KB Output is correct
7 Correct 37 ms 139268 KB Output is correct
8 Correct 36 ms 139268 KB Output is correct
9 Correct 37 ms 139268 KB Output is correct
10 Correct 37 ms 139268 KB Output is correct
11 Correct 36 ms 139268 KB Output is correct
12 Correct 36 ms 139268 KB Output is correct
13 Correct 36 ms 139268 KB Output is correct
14 Correct 36 ms 139268 KB Output is correct
15 Correct 37 ms 139268 KB Output is correct
16 Correct 33 ms 139268 KB Output is correct
17 Correct 36 ms 139268 KB Output is correct
18 Correct 36 ms 139268 KB Output is correct
19 Correct 34 ms 139268 KB Output is correct
20 Correct 31 ms 139268 KB Output is correct
21 Correct 32 ms 139268 KB Output is correct
22 Correct 31 ms 139268 KB Output is correct
23 Correct 38 ms 139268 KB Output is correct
24 Correct 36 ms 139268 KB Output is correct
25 Correct 32 ms 139268 KB Output is correct
26 Correct 33 ms 139268 KB Output is correct
27 Correct 32 ms 139268 KB Output is correct
28 Correct 38 ms 139268 KB Output is correct
29 Correct 37 ms 139268 KB Output is correct
30 Correct 37 ms 139268 KB Output is correct
31 Correct 38 ms 139268 KB Output is correct
32 Correct 38 ms 139268 KB Output is correct
33 Correct 421 ms 143744 KB Output is correct
34 Correct 527 ms 156108 KB Output is correct
35 Correct 521 ms 159604 KB Output is correct
36 Correct 509 ms 166776 KB Output is correct
37 Correct 334 ms 169372 KB Output is correct
38 Correct 335 ms 173032 KB Output is correct
39 Correct 371 ms 183312 KB Output is correct
40 Correct 361 ms 193248 KB Output is correct
41 Correct 351 ms 195184 KB Output is correct
42 Correct 324 ms 198036 KB Output is correct
43 Correct 346 ms 199892 KB Output is correct
44 Correct 372 ms 200740 KB Output is correct
45 Correct 343 ms 200780 KB Output is correct
46 Correct 333 ms 200780 KB Output is correct
47 Correct 371 ms 200780 KB Output is correct
48 Correct 365 ms 200780 KB Output is correct
49 Correct 458 ms 201768 KB Output is correct
50 Correct 470 ms 201768 KB Output is correct
51 Correct 415 ms 201768 KB Output is correct
52 Correct 430 ms 201768 KB Output is correct
53 Correct 505 ms 201768 KB Output is correct
54 Correct 411 ms 201768 KB Output is correct
55 Correct 420 ms 201768 KB Output is correct
56 Correct 452 ms 201768 KB Output is correct
57 Correct 410 ms 201768 KB Output is correct
58 Correct 412 ms 201768 KB Output is correct
59 Correct 381 ms 201768 KB Output is correct