# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
107550 | 2019-04-25T02:21:13 Z | PeppaPig | 말 (IOI15_horses) | C++14 | 325 ms | 62840 KB |
#include "horses.h" #include <bits/stdc++.h> #define long long long using namespace std; const int N = 1<<19; const int M = 1e9+7; #define var int p = 1, int l = 0, int r = n-1 #define mid ((l + r) >> 1) #define lb p<<1, l, mid #define rb p<<1|1, mid+1, r struct node { double log; long sum; node() : log(0), sum(1) { } node(double log, long sum) : log(log), sum(sum) { } friend node operator+(const node &a, const node &b) { node ret; ret.log = a.log + b.log; ret.sum = (a.sum * b.sum) % M; return ret; } friend bool operator<(const node &a, const node &b) { return make_pair(a.log, a.sum) < make_pair(b.log, b.sum); } } t[N<<1], lz[N<<1]; int n, x[N], y[N]; node A[N]; void build(var) { if(l == r) return void(t[p] = A[l]); build(lb), build(rb); t[p] = t[p<<1] < t[p<<1|1] ? t[p<<1|1] : t[p<<1]; } void push(var) { t[p] = t[p] + lz[p]; if(l != r) { lz[p<<1] = lz[p<<1] + lz[p]; lz[p<<1|1] = lz[p<<1|1] + lz[p]; } lz[p] = node(0, 1); } void update(int x, int y, node k, var) { push(p, l, r); if(x > r || l > y) return; if(x <= l && r <= y) { lz[p] = lz[p] + k; push(p, l, r); return; } update(x, y, k, lb), update(x, y, k, rb); t[p] = t[p<<1] < t[p<<1|1] ? t[p<<1|1] : t[p<<1]; } int init(int N, int X[], int Y[]) { n = N; node cul(0, 1); for(int i = 0; i < n; i++) { x[i] = X[i], y[i] = Y[i]; cul = cul + node((double)log2(x[i]), x[i]); A[i] = cul + node((double)log2(y[i]), y[i]); } build(); return t[1].sum; } long modpow(long a, long b) { long ret = 1; for( ; b; b >>= 1) { if(b & 1) ret = (ret * a) % M; a = (a * a) % M; } return ret; } int updateX(int pos, int val) { double nlog = (double)log2(val) - (double)log2(x[pos]); long nsum = (1ll * val * modpow(x[pos], M-2)) % M; x[pos] = val; update(pos, n-1, node(nlog, nsum)); return t[1].sum; } int updateY(int pos, int val) { double nlog = (double)log2(val) - (double)log2(y[pos]); long nsum = (1ll * val * modpow(y[pos], M-2)) % M; y[pos] = val; update(pos, pos, node(nlog, nsum)); return t[1].sum; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 41336 KB | Output is correct |
2 | Correct | 34 ms | 41332 KB | Output is correct |
3 | Correct | 34 ms | 41344 KB | Output is correct |
4 | Correct | 37 ms | 41208 KB | Output is correct |
5 | Correct | 36 ms | 41336 KB | Output is correct |
6 | Correct | 36 ms | 41340 KB | Output is correct |
7 | Correct | 34 ms | 41336 KB | Output is correct |
8 | Correct | 34 ms | 41432 KB | Output is correct |
9 | Correct | 36 ms | 41344 KB | Output is correct |
10 | Correct | 33 ms | 41336 KB | Output is correct |
11 | Correct | 44 ms | 41464 KB | Output is correct |
12 | Correct | 35 ms | 41344 KB | Output is correct |
13 | Correct | 37 ms | 41336 KB | Output is correct |
14 | Correct | 33 ms | 41336 KB | Output is correct |
15 | Correct | 42 ms | 41336 KB | Output is correct |
16 | Correct | 36 ms | 41316 KB | Output is correct |
17 | Correct | 37 ms | 41336 KB | Output is correct |
18 | Correct | 33 ms | 41344 KB | Output is correct |
19 | Correct | 34 ms | 41336 KB | Output is correct |
20 | Correct | 33 ms | 41472 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 41336 KB | Output is correct |
2 | Correct | 41 ms | 41336 KB | Output is correct |
3 | Correct | 36 ms | 41344 KB | Output is correct |
4 | Correct | 32 ms | 41336 KB | Output is correct |
5 | Correct | 35 ms | 41360 KB | Output is correct |
6 | Correct | 35 ms | 41464 KB | Output is correct |
7 | Correct | 34 ms | 41444 KB | Output is correct |
8 | Correct | 40 ms | 41336 KB | Output is correct |
9 | Correct | 35 ms | 41344 KB | Output is correct |
10 | Correct | 35 ms | 41336 KB | Output is correct |
11 | Correct | 33 ms | 41336 KB | Output is correct |
12 | Correct | 33 ms | 41392 KB | Output is correct |
13 | Correct | 40 ms | 41336 KB | Output is correct |
14 | Correct | 41 ms | 41464 KB | Output is correct |
15 | Correct | 35 ms | 41344 KB | Output is correct |
16 | Correct | 37 ms | 41308 KB | Output is correct |
17 | Correct | 36 ms | 41388 KB | Output is correct |
18 | Correct | 33 ms | 41336 KB | Output is correct |
19 | Correct | 33 ms | 41336 KB | Output is correct |
20 | Correct | 34 ms | 41344 KB | Output is correct |
21 | Correct | 32 ms | 41464 KB | Output is correct |
22 | Correct | 33 ms | 41336 KB | Output is correct |
23 | Correct | 41 ms | 41404 KB | Output is correct |
24 | Correct | 41 ms | 41464 KB | Output is correct |
25 | Correct | 38 ms | 41464 KB | Output is correct |
26 | Correct | 35 ms | 41464 KB | Output is correct |
27 | Correct | 38 ms | 41464 KB | Output is correct |
28 | Correct | 35 ms | 41464 KB | Output is correct |
29 | Correct | 33 ms | 41464 KB | Output is correct |
30 | Correct | 35 ms | 41464 KB | Output is correct |
31 | Correct | 34 ms | 41464 KB | Output is correct |
32 | Correct | 36 ms | 41468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 156 ms | 50264 KB | Output is correct |
2 | Correct | 325 ms | 62840 KB | Output is correct |
3 | Correct | 305 ms | 53936 KB | Output is correct |
4 | Correct | 303 ms | 57860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 41324 KB | Output is correct |
2 | Correct | 32 ms | 41296 KB | Output is correct |
3 | Correct | 37 ms | 41308 KB | Output is correct |
4 | Correct | 34 ms | 41308 KB | Output is correct |
5 | Correct | 37 ms | 41340 KB | Output is correct |
6 | Correct | 35 ms | 41340 KB | Output is correct |
7 | Correct | 37 ms | 41348 KB | Output is correct |
8 | Correct | 34 ms | 41336 KB | Output is correct |
9 | Correct | 34 ms | 41336 KB | Output is correct |
10 | Correct | 35 ms | 41464 KB | Output is correct |
11 | Correct | 33 ms | 41344 KB | Output is correct |
12 | Correct | 35 ms | 41336 KB | Output is correct |
13 | Correct | 36 ms | 41336 KB | Output is correct |
14 | Correct | 34 ms | 41336 KB | Output is correct |
15 | Correct | 36 ms | 41344 KB | Output is correct |
16 | Correct | 34 ms | 41344 KB | Output is correct |
17 | Correct | 32 ms | 41344 KB | Output is correct |
18 | Correct | 34 ms | 41336 KB | Output is correct |
19 | Correct | 41 ms | 41344 KB | Output is correct |
20 | Correct | 35 ms | 41412 KB | Output is correct |
21 | Correct | 42 ms | 41336 KB | Output is correct |
22 | Correct | 41 ms | 41336 KB | Output is correct |
23 | Correct | 36 ms | 41496 KB | Output is correct |
24 | Correct | 36 ms | 41464 KB | Output is correct |
25 | Correct | 37 ms | 41408 KB | Output is correct |
26 | Correct | 35 ms | 41468 KB | Output is correct |
27 | Correct | 34 ms | 41472 KB | Output is correct |
28 | Correct | 36 ms | 41592 KB | Output is correct |
29 | Correct | 33 ms | 41336 KB | Output is correct |
30 | Correct | 35 ms | 41464 KB | Output is correct |
31 | Correct | 34 ms | 41464 KB | Output is correct |
32 | Correct | 37 ms | 41464 KB | Output is correct |
33 | Correct | 105 ms | 53240 KB | Output is correct |
34 | Correct | 99 ms | 53240 KB | Output is correct |
35 | Correct | 119 ms | 60152 KB | Output is correct |
36 | Correct | 104 ms | 60120 KB | Output is correct |
37 | Correct | 87 ms | 51448 KB | Output is correct |
38 | Correct | 85 ms | 52328 KB | Output is correct |
39 | Correct | 65 ms | 51320 KB | Output is correct |
40 | Correct | 81 ms | 55160 KB | Output is correct |
41 | Correct | 94 ms | 51292 KB | Output is correct |
42 | Correct | 74 ms | 51412 KB | Output is correct |
43 | Correct | 94 ms | 55672 KB | Output is correct |
44 | Correct | 75 ms | 55672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 41416 KB | Output is correct |
2 | Correct | 33 ms | 41336 KB | Output is correct |
3 | Correct | 33 ms | 41344 KB | Output is correct |
4 | Correct | 33 ms | 41340 KB | Output is correct |
5 | Correct | 35 ms | 41472 KB | Output is correct |
6 | Correct | 34 ms | 41416 KB | Output is correct |
7 | Correct | 39 ms | 41336 KB | Output is correct |
8 | Correct | 35 ms | 41340 KB | Output is correct |
9 | Correct | 35 ms | 41464 KB | Output is correct |
10 | Correct | 37 ms | 41464 KB | Output is correct |
11 | Correct | 34 ms | 41464 KB | Output is correct |
12 | Correct | 37 ms | 41344 KB | Output is correct |
13 | Correct | 34 ms | 41336 KB | Output is correct |
14 | Correct | 31 ms | 41332 KB | Output is correct |
15 | Correct | 36 ms | 41344 KB | Output is correct |
16 | Correct | 38 ms | 41336 KB | Output is correct |
17 | Correct | 30 ms | 41464 KB | Output is correct |
18 | Correct | 30 ms | 41344 KB | Output is correct |
19 | Correct | 31 ms | 41336 KB | Output is correct |
20 | Correct | 30 ms | 41344 KB | Output is correct |
21 | Correct | 30 ms | 41336 KB | Output is correct |
22 | Correct | 34 ms | 41336 KB | Output is correct |
23 | Correct | 35 ms | 41464 KB | Output is correct |
24 | Correct | 36 ms | 41472 KB | Output is correct |
25 | Correct | 37 ms | 41404 KB | Output is correct |
26 | Correct | 34 ms | 41464 KB | Output is correct |
27 | Correct | 36 ms | 41464 KB | Output is correct |
28 | Correct | 36 ms | 41464 KB | Output is correct |
29 | Correct | 39 ms | 41388 KB | Output is correct |
30 | Correct | 33 ms | 41464 KB | Output is correct |
31 | Correct | 35 ms | 41464 KB | Output is correct |
32 | Correct | 36 ms | 41440 KB | Output is correct |
33 | Correct | 188 ms | 54076 KB | Output is correct |
34 | Correct | 323 ms | 62840 KB | Output is correct |
35 | Correct | 294 ms | 54092 KB | Output is correct |
36 | Correct | 320 ms | 57848 KB | Output is correct |
37 | Correct | 105 ms | 53240 KB | Output is correct |
38 | Correct | 93 ms | 53340 KB | Output is correct |
39 | Correct | 103 ms | 60180 KB | Output is correct |
40 | Correct | 114 ms | 60228 KB | Output is correct |
41 | Correct | 97 ms | 51384 KB | Output is correct |
42 | Correct | 102 ms | 52344 KB | Output is correct |
43 | Correct | 77 ms | 51420 KB | Output is correct |
44 | Correct | 104 ms | 55376 KB | Output is correct |
45 | Correct | 79 ms | 51320 KB | Output is correct |
46 | Correct | 85 ms | 51364 KB | Output is correct |
47 | Correct | 87 ms | 55644 KB | Output is correct |
48 | Correct | 82 ms | 55544 KB | Output is correct |
49 | Correct | 302 ms | 55224 KB | Output is correct |
50 | Correct | 323 ms | 55460 KB | Output is correct |
51 | Correct | 217 ms | 62148 KB | Output is correct |
52 | Correct | 221 ms | 61652 KB | Output is correct |
53 | Correct | 281 ms | 53624 KB | Output is correct |
54 | Correct | 211 ms | 54136 KB | Output is correct |
55 | Correct | 159 ms | 52344 KB | Output is correct |
56 | Correct | 196 ms | 57080 KB | Output is correct |
57 | Correct | 164 ms | 52984 KB | Output is correct |
58 | Correct | 164 ms | 53512 KB | Output is correct |
59 | Correct | 86 ms | 55644 KB | Output is correct |