답안 #367959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367959 2021-02-19T02:13:15 Z dennisstar 말 (IOI15_horses) C++17
100 / 100
347 ms 67180 KB
#include "horses.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

struct {
	ll v, x, y;
	double dv, dx, dy;
}st[1<<20];

void upd(int i, int s, int e, int t, int x, int y) {
	auto &n=st[i];
	if (s==e) {
		if (x) n.x=x, n.dx=log(x);
		if (y) n.y=y, n.dy=log(y);
		n.v=n.x*n.y%MOD;
		n.dv=n.dx+n.dy;
		return ;
	}

	int m=(s+e)/2;
	if (t<=m) upd(i*2, s, m, t, x, y);
	else upd(i*2+1, m+1, e, t, x, y);

	auto &l=st[i*2], &r=st[i*2+1];
	n.x=l.x*r.x%MOD;
	n.dx=l.dx+r.dx;
	tie(n.dv, n.v)=
		max(pair<double, ll>(l.dv, l.v),
		pair<double, ll>(l.dx+r.dv, l.x*r.v%MOD));
}

int n;

int init(int n, int *x, int *y) {
	::n=n;
	for (int i=0; i<n; i++)
		upd(1, 0, n-1, i, x[i], y[i]);
	return st[1].v;
}

int updateX(int p, int v) {
	upd(1, 0, n-1, p, v, 0);
	return st[1].v;
}

int updateY(int p, int v) {
	upd(1, 0, n-1, p, 0, v);
	return st[1].v;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:38:31: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   38 | int init(int n, int *x, int *y) {
      |                               ^
horses.cpp:36:5: note: shadowed declaration is here
   36 | int n;
      |     ^
horses.cpp:42:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   42 |  return st[1].v;
      |         ~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:47:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   47 |  return st[1].v;
      |         ~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:52:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   52 |  return st[1].v;
      |         ~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 380 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 312 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 255 ms 58348 KB Output is correct
2 Correct 346 ms 67180 KB Output is correct
3 Correct 301 ms 58220 KB Output is correct
4 Correct 336 ms 62316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 238 ms 57708 KB Output is correct
34 Correct 236 ms 57588 KB Output is correct
35 Correct 262 ms 64492 KB Output is correct
36 Correct 259 ms 64364 KB Output is correct
37 Correct 201 ms 55660 KB Output is correct
38 Correct 232 ms 56556 KB Output is correct
39 Correct 198 ms 55532 KB Output is correct
40 Correct 230 ms 59500 KB Output is correct
41 Correct 201 ms 55660 KB Output is correct
42 Correct 195 ms 55660 KB Output is correct
43 Correct 238 ms 59884 KB Output is correct
44 Correct 226 ms 59884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 253 ms 58288 KB Output is correct
34 Correct 347 ms 67052 KB Output is correct
35 Correct 296 ms 58220 KB Output is correct
36 Correct 332 ms 62316 KB Output is correct
37 Correct 232 ms 57580 KB Output is correct
38 Correct 232 ms 57580 KB Output is correct
39 Correct 259 ms 64552 KB Output is correct
40 Correct 255 ms 64364 KB Output is correct
41 Correct 204 ms 55660 KB Output is correct
42 Correct 231 ms 56556 KB Output is correct
43 Correct 197 ms 55576 KB Output is correct
44 Correct 231 ms 59628 KB Output is correct
45 Correct 199 ms 55660 KB Output is correct
46 Correct 196 ms 55660 KB Output is correct
47 Correct 222 ms 59884 KB Output is correct
48 Correct 220 ms 60012 KB Output is correct
49 Correct 316 ms 59500 KB Output is correct
50 Correct 314 ms 59628 KB Output is correct
51 Correct 304 ms 66340 KB Output is correct
52 Correct 297 ms 65900 KB Output is correct
53 Correct 287 ms 57836 KB Output is correct
54 Correct 279 ms 58604 KB Output is correct
55 Correct 236 ms 56684 KB Output is correct
56 Correct 274 ms 61420 KB Output is correct
57 Correct 239 ms 57324 KB Output is correct
58 Correct 239 ms 57836 KB Output is correct
59 Correct 220 ms 59884 KB Output is correct