# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
431695 |
2021-06-17T14:33:11 Z |
arayi |
말 (IOI15_horses) |
C++17 |
|
1261 ms |
54568 KB |
#include "horses.h"
#include <bits/stdc++.h>
#define lli long long
using namespace std;
const int N = 5e5 + 30;
const lli mod = 1e9 + 7;
int n;
lli x[N], y[N];
lli t[4*N], t1[4*N];
set <int> fp;
void upd(int q, lli v, int l = 0, int r = n - 1, int nd = 1)
{
if(q > r || q < l) return;
if(l == r)
{
t[nd] = v;
return;
}
int md = (l + r) / 2;
upd(q, v, l, md, nd * 2);
upd(q, v, md + 1, r, nd * 2 + 1);
t[nd] = max(t[nd*2], t[nd*2+1]);
}
lli qry(int l, int r, int nl = 0, int nr = n - 1, int nd = 1)
{
if(l > nr || r < nl) return 0;
if(nl==l&&r==nr) return t[nd];
int md = (nl + nr)/2;
return max(qry(l, min(md, r), nl, md, nd*2), qry(max(md + 1, l), r, md + 1, nr, nd * 2 + 1));
}
void upd1(int q, lli v, int l = 0, int r = n - 1, int nd = 1)
{
if(q > r || q < l) return;
if(l == r)
{
t1[nd] = v;
return;
}
int md = (l + r) / 2;
upd1(q, v, l, md, nd * 2);
upd1(q, v, md + 1, r, nd * 2 + 1);
t1[nd] = (t1[nd*2] * t1[nd*2+1]) % mod;
}
lli qry1(int l, int r, int nl = 0, int nr = n - 1, int nd = 1)
{
if(l > nr || r < nl) return 1;
if(nl==l&&r==nr) return t1[nd];
int md = (nl + nr)/2;
return (qry1(l, min(md, r), nl, md, nd*2) * qry1(max(md + 1, l), r, md + 1, nr, nd * 2 + 1))%mod;
}
lli slv()
{
auto i1 = fp.end();
int nx = n - 1;
lli mx = 0;
do
{
--i1;
//cout << *i1 << "<-" << endl;
mx = max(mx, qry(*i1, nx));
mx *= x[*i1];
nx = (*i1) - 1;
if(mx > mod) break;
} while (i1 != fp.begin());
mx %= mod;
return (mx * qry1(0, nx))%mod;
}
int init(int N, int X[], int Y[])
{
n = N;
fp.insert(0);
for (int i = 0; i < n; i++)
{
x[i]=X[i], y[i]=Y[i];
if(x[i] > 1) fp.insert(i);
upd(i, y[i]);
upd1(i, x[i]);
}
return slv();
}
int updateX(int pos, int val)
{
if(x[pos] > 1 && pos) fp.erase(pos);
x[pos] = val;
if(x[pos] > 1) fp.insert(pos);
upd1(pos, val);
return slv();
}
int updateY(int pos, int val)
{
y[pos] = val;
upd(pos, val);
return slv();
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:71:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
71 | int init(int N, int X[], int Y[])
| ~~~~^
horses.cpp:6:11: note: shadowed declaration is here
6 | const int N = 5e5 + 30;
| ^
horses.cpp:82:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
82 | return slv();
| ~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:91:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
91 | return slv();
| ~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:98:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
98 | return slv();
| ~~~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
4 ms |
332 KB |
Output is correct |
28 |
Correct |
3 ms |
332 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
3 ms |
332 KB |
Output is correct |
31 |
Correct |
3 ms |
332 KB |
Output is correct |
32 |
Correct |
5 ms |
392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1014 ms |
52940 KB |
Output is correct |
2 |
Correct |
691 ms |
52972 KB |
Output is correct |
3 |
Correct |
749 ms |
52884 KB |
Output is correct |
4 |
Correct |
772 ms |
52884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
4 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
408 KB |
Output is correct |
29 |
Correct |
2 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
3 ms |
332 KB |
Output is correct |
32 |
Correct |
6 ms |
388 KB |
Output is correct |
33 |
Correct |
324 ms |
32108 KB |
Output is correct |
34 |
Correct |
318 ms |
28636 KB |
Output is correct |
35 |
Correct |
496 ms |
51952 KB |
Output is correct |
36 |
Correct |
523 ms |
51944 KB |
Output is correct |
37 |
Correct |
398 ms |
28704 KB |
Output is correct |
38 |
Correct |
406 ms |
40460 KB |
Output is correct |
39 |
Correct |
310 ms |
28432 KB |
Output is correct |
40 |
Correct |
492 ms |
52112 KB |
Output is correct |
41 |
Correct |
335 ms |
28536 KB |
Output is correct |
42 |
Correct |
364 ms |
28664 KB |
Output is correct |
43 |
Correct |
455 ms |
51908 KB |
Output is correct |
44 |
Correct |
465 ms |
51880 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
260 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
1 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
4 ms |
332 KB |
Output is correct |
28 |
Correct |
2 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
2 ms |
332 KB |
Output is correct |
31 |
Correct |
3 ms |
332 KB |
Output is correct |
32 |
Correct |
6 ms |
332 KB |
Output is correct |
33 |
Correct |
1029 ms |
54568 KB |
Output is correct |
34 |
Correct |
729 ms |
52836 KB |
Output is correct |
35 |
Correct |
724 ms |
52820 KB |
Output is correct |
36 |
Correct |
750 ms |
52912 KB |
Output is correct |
37 |
Correct |
323 ms |
28620 KB |
Output is correct |
38 |
Correct |
314 ms |
28652 KB |
Output is correct |
39 |
Correct |
492 ms |
52220 KB |
Output is correct |
40 |
Correct |
533 ms |
52024 KB |
Output is correct |
41 |
Correct |
440 ms |
28612 KB |
Output is correct |
42 |
Correct |
398 ms |
40516 KB |
Output is correct |
43 |
Correct |
310 ms |
28500 KB |
Output is correct |
44 |
Correct |
470 ms |
52000 KB |
Output is correct |
45 |
Correct |
336 ms |
28524 KB |
Output is correct |
46 |
Correct |
379 ms |
28544 KB |
Output is correct |
47 |
Correct |
459 ms |
51940 KB |
Output is correct |
48 |
Correct |
465 ms |
51952 KB |
Output is correct |
49 |
Correct |
494 ms |
30588 KB |
Output is correct |
50 |
Correct |
483 ms |
30536 KB |
Output is correct |
51 |
Correct |
732 ms |
52888 KB |
Output is correct |
52 |
Correct |
596 ms |
52828 KB |
Output is correct |
53 |
Correct |
1261 ms |
30424 KB |
Output is correct |
54 |
Correct |
608 ms |
43456 KB |
Output is correct |
55 |
Correct |
445 ms |
28600 KB |
Output is correct |
56 |
Correct |
659 ms |
52928 KB |
Output is correct |
57 |
Correct |
759 ms |
29416 KB |
Output is correct |
58 |
Correct |
1006 ms |
29476 KB |
Output is correct |
59 |
Correct |
475 ms |
51952 KB |
Output is correct |