# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
785152 |
2023-07-17T06:17:29 Z |
ymm |
말 (IOI15_horses) |
C++17 |
|
243 ms |
66668 KB |
#include "horses.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
namespace seg {
const int mod = 1e9+7;
const int N = 500010;
int sz;
struct {
ll Xs, mxXs, mx;
ll mxy;
bool of;
} t[N*4];
ll X[N], Y[N];
void merge(int i) {
auto &t = seg::t[i], &l = seg::t[2*i+1], &r = seg::t[2*i+2];
t.Xs = l.Xs * r.Xs % mod;
if (r.of) {
t.of = 1;
t.mx = l.Xs * r.mx % mod;
t.mxXs = r.mxXs;
t.mxy = r.mxy;
return;
}
if (l.mxy < l.mxXs * r.mx) {
t.mx = l.Xs * r.mx;
t.of = t.mx >= mod || l.of;
t.mx %= mod;
t.mxXs = r.mxXs;
t.mxy = r.mxy;
} else {
t.mx = l.mx;
t.of = l.of;
t.mxXs = l.mxXs * r.Xs;
t.mxy = l.mxy;
}
}
void init(int i, int b, int e) {
t[i].mx = t[i].Xs = t[i].mxXs = t[i].mxy = 1;
t[i].of = 0;
if (e-b == 1) {
X[b] = Y[b] = 1;
} else {
init(2*i+1, b, (b+e)/2);
init(2*i+2, (b+e)/2, e);
}
}
void init(int n) { sz = n; init(0, 0, n); }
void up(int p, int i, int b, int e) {
if (e-b == 1) {
t[i].Xs = X[b];
t[i].mxXs = 1;
t[i].mxy = Y[b];
t[i].mx = X[b] * Y[b];
t[i].of = t[i].mx >= mod;
t[i].mx %= mod;
return;
}
if (p < (b+e)/2)
up(p, 2*i+1, b, (b+e)/2);
else
up(p, 2*i+2, (b+e)/2, e);
merge(i);
}
void up(int p) { up(p, 0, 0, sz); }
}
int init(int N, int X[], int Y[]) {
seg::init(N);
Loop (i,0,N) {
seg::X[i] = X[i];
seg::Y[i] = Y[i];
seg::up(i);
}
return seg::t[0].mx;
}
int updateX(int pos, int val) {
seg::X[pos] = val;
seg::up(pos);
return seg::t[0].mx;
}
int updateY(int pos, int val) {
seg::Y[pos] = val;
seg::up(pos);
return seg::t[0].mx;
}
Compilation message
horses.cpp: In function 'void seg::merge(int)':
horses.cpp:19:9: warning: declaration of 't' shadows a global declaration [-Wshadow]
19 | auto &t = seg::t[i], &l = seg::t[2*i+1], &r = seg::t[2*i+2];
| ^
horses.cpp:15:4: note: shadowed declaration is here
15 | } t[N*4];
| ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:78:11: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
78 | seg::up(i);
| ^
horses.cpp:80:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
80 | return seg::t[0].mx;
| ~~~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:86:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
86 | return seg::t[0].mx;
| ~~~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:92:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
92 | return seg::t[0].mx;
| ~~~~~~~~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
216 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
316 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
216 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
308 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
444 KB |
Output is correct |
25 |
Correct |
1 ms |
444 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
155 ms |
57868 KB |
Output is correct |
2 |
Correct |
243 ms |
66576 KB |
Output is correct |
3 |
Correct |
191 ms |
57772 KB |
Output is correct |
4 |
Correct |
218 ms |
61616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
308 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
316 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
141 ms |
57036 KB |
Output is correct |
34 |
Correct |
153 ms |
57020 KB |
Output is correct |
35 |
Correct |
183 ms |
63960 KB |
Output is correct |
36 |
Correct |
158 ms |
63888 KB |
Output is correct |
37 |
Correct |
132 ms |
55304 KB |
Output is correct |
38 |
Correct |
132 ms |
56120 KB |
Output is correct |
39 |
Correct |
127 ms |
55132 KB |
Output is correct |
40 |
Correct |
144 ms |
59016 KB |
Output is correct |
41 |
Correct |
124 ms |
55252 KB |
Output is correct |
42 |
Correct |
141 ms |
55160 KB |
Output is correct |
43 |
Correct |
140 ms |
59452 KB |
Output is correct |
44 |
Correct |
141 ms |
59452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
304 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
304 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
308 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
452 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
448 KB |
Output is correct |
31 |
Correct |
1 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
155 ms |
57884 KB |
Output is correct |
34 |
Correct |
240 ms |
66668 KB |
Output is correct |
35 |
Correct |
216 ms |
57848 KB |
Output is correct |
36 |
Correct |
203 ms |
61640 KB |
Output is correct |
37 |
Correct |
158 ms |
57008 KB |
Output is correct |
38 |
Correct |
147 ms |
57032 KB |
Output is correct |
39 |
Correct |
167 ms |
63932 KB |
Output is correct |
40 |
Correct |
170 ms |
63888 KB |
Output is correct |
41 |
Correct |
138 ms |
55168 KB |
Output is correct |
42 |
Correct |
131 ms |
56136 KB |
Output is correct |
43 |
Correct |
134 ms |
55148 KB |
Output is correct |
44 |
Correct |
140 ms |
58980 KB |
Output is correct |
45 |
Correct |
126 ms |
55124 KB |
Output is correct |
46 |
Correct |
126 ms |
55240 KB |
Output is correct |
47 |
Correct |
139 ms |
59404 KB |
Output is correct |
48 |
Correct |
146 ms |
59452 KB |
Output is correct |
49 |
Correct |
204 ms |
59000 KB |
Output is correct |
50 |
Correct |
224 ms |
59084 KB |
Output is correct |
51 |
Correct |
189 ms |
65848 KB |
Output is correct |
52 |
Correct |
191 ms |
65404 KB |
Output is correct |
53 |
Correct |
209 ms |
57356 KB |
Output is correct |
54 |
Correct |
170 ms |
57932 KB |
Output is correct |
55 |
Correct |
149 ms |
56144 KB |
Output is correct |
56 |
Correct |
171 ms |
60904 KB |
Output is correct |
57 |
Correct |
151 ms |
56776 KB |
Output is correct |
58 |
Correct |
155 ms |
57304 KB |
Output is correct |
59 |
Correct |
143 ms |
59452 KB |
Output is correct |