답안 #800823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800823 2023-08-01T22:40:07 Z Liudas 말 (IOI15_horses) C++17
100 / 100
273 ms 62316 KB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
class segtree{
public:
    struct nodes{
        double clogx, clogy;
        double logx;
        long long X;
        long long cX, cY;
    };
    vector<long long> X, Y;
    vector<nodes> tree;
    long long N;
    long long MOD = 1e9 + 7;
    nodes comp(nodes a, nodes b){
        nodes c = a;
        c.logx += b.logx;
        c.X = 1ll * c.X * b.X % MOD;
        if(a.clogy + a.clogx < a.logx + b.clogx + b.clogy){
            c.clogy = b.clogy;
            c.clogx = a.logx + b.clogx;
            c.cX = 1ll * a.X * b.cX % MOD;
            c.cY = b.cY;
        }
        return c;
    }
    void init(long long NN){
        X.assign(NN, 0);
        Y.assign(NN, 0);
        long long K = 1;
        while(K <= NN) K *= 2;
        N = K;
        tree.assign(K * 2, {0, 0, 0, 0, 0, 0});
    }
    void add(int node, int l, int r, int pos){
        if(pos < l || pos >= r){
            return;
        }
        if(r - l == 1){
            tree[node].X = X[pos];
            tree[node].cX = X[pos];
            tree[node].cY = Y[pos];
            tree[node].logx = log((double)(X[pos]));
            tree[node].clogx = log((double)(X[pos]));
            tree[node].clogy = log((double)(Y[pos]));
            return;
        }
        int mid = (l + r) / 2;
        if(pos < mid){
            add(node * 2 + 1, l, mid, pos);
        }
        else{
            add(node * 2 + 2, mid, r, pos);
        }
        tree[node] = comp(tree[node * 2 + 1], tree[node * 2 + 2]);
    }
    void add(int pos){
        add(0, 0, (int)N, pos);
    }
    long long ans(){
        return 1ll * tree[0].cX * tree[0].cY % MOD;
    }
};
segtree tree;
int init(int NN, int XX[], int YY[]){
    int N = NN;
    tree.init(N);
    for(int i = 0; i < N; i ++){
        tree.X[i] = XX[i];
        tree.Y[i] = YY[i];
        tree.add(i);
    }
    return (int)tree.ans();
}
int updateX(int pos, int val){
    tree.X[pos] = val;
    tree.add(pos);
    return (int)tree.ans();
}
int updateY(int pos, int val){
    tree.Y[pos] = val;
    tree.add(pos);
    return (int)tree.ans();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 276 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 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 212 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 340 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 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 187 ms 62188 KB Output is correct
2 Correct 272 ms 62188 KB Output is correct
3 Correct 239 ms 62192 KB Output is correct
4 Correct 256 ms 62188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 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 212 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 340 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 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
33 Correct 152 ms 61300 KB Output is correct
34 Correct 153 ms 61388 KB Output is correct
35 Correct 189 ms 61416 KB Output is correct
36 Correct 186 ms 61268 KB Output is correct
37 Correct 133 ms 61288 KB Output is correct
38 Correct 161 ms 61284 KB Output is correct
39 Correct 127 ms 61320 KB Output is correct
40 Correct 175 ms 61388 KB Output is correct
41 Correct 127 ms 61272 KB Output is correct
42 Correct 127 ms 61288 KB Output is correct
43 Correct 175 ms 61288 KB Output is correct
44 Correct 170 ms 61296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 252 KB Output is correct
14 Correct 0 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 0 ms 212 KB Output is correct
18 Correct 0 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 212 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 340 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 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
33 Correct 187 ms 62208 KB Output is correct
34 Correct 273 ms 62156 KB Output is correct
35 Correct 236 ms 62192 KB Output is correct
36 Correct 256 ms 62284 KB Output is correct
37 Correct 152 ms 61336 KB Output is correct
38 Correct 152 ms 61288 KB Output is correct
39 Correct 185 ms 61288 KB Output is correct
40 Correct 190 ms 61368 KB Output is correct
41 Correct 132 ms 61296 KB Output is correct
42 Correct 167 ms 61288 KB Output is correct
43 Correct 127 ms 61288 KB Output is correct
44 Correct 176 ms 61264 KB Output is correct
45 Correct 128 ms 61292 KB Output is correct
46 Correct 128 ms 61388 KB Output is correct
47 Correct 168 ms 61252 KB Output is correct
48 Correct 168 ms 61300 KB Output is correct
49 Correct 233 ms 62192 KB Output is correct
50 Correct 229 ms 62316 KB Output is correct
51 Correct 224 ms 62180 KB Output is correct
52 Correct 238 ms 62176 KB Output is correct
53 Correct 203 ms 62228 KB Output is correct
54 Correct 213 ms 62188 KB Output is correct
55 Correct 153 ms 61388 KB Output is correct
56 Correct 212 ms 62284 KB Output is correct
57 Correct 158 ms 62200 KB Output is correct
58 Correct 156 ms 62240 KB Output is correct
59 Correct 167 ms 61292 KB Output is correct