답안 #670097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670097 2022-12-08T06:19:25 Z Astrayt 말 (IOI15_horses) C++17
17 / 100
516 ms 113620 KB
#include <bits/stdc++.h>
using namespace std;
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long
#define double long double
#define pii pair<int,int>
#define pb push_back
#define maxn 500005
#define mod 1000000007ll
#define ff first
#define ss second

int N;
vector<int> X, Y;
vector<double> lgX, lgY, PlgX;

int fastpow(int a, int b){
    int ret = 1;
    for(; b; b >>= 1){
        if(b & 1) ret = 1ll * ret * a % mod;
        a = 1ll * a * a % mod;
    }
    return ret;
}

struct FenwickTree{
    int val[maxn];
    void init(int n){
        for(int i = 0; i <= n; ++i) val[i] = 1;
    }
    void modify(int p, int x){
        for(; p < maxn; p += (p & -p)) val[p] = 1ll * x * val[p] % mod;
    }
    int query(int p){
        int ret = 1;
        for(; p; p -= (p & -p)){
            ret = 1ll * ret * val[p] % mod;
        }
        return ret;
    }
}bit;

struct SegmentTree{
    pair<double, int> node[4 * maxn];
    double tag[4 * maxn];
    void push(int i){
        double t = tag[i];
        node[2 * i].ff += t, tag[2 * i] += t;
        node[2 * i + 1].ff += t, tag[2 * i + 1] += t;
        tag[i] = 0;
        node[i] = max(node[2 * i], node[2 * i + 1]);
    }
    void modify(int i, int l, int r, int ql, int qr, double x){
        if(l == r){
            node[i].ff += x;
            node[i].ss = l;
            return;
        }
        push(i);
        if(ql <= l && r <= qr){
            node[i].ff += x;
            tag[i] += x;
            return;
        }
        int mid = (l + r) / 2;
        if(ql <= mid) modify(2 * i, l, mid, ql, qr, x);
        if(mid < qr) modify(2 * i + 1, mid + 1, r, ql, qr, x);
        node[i] = max(node[2 * i], node[2 * i + 1]);
    }
}seg;

int init(int n, int *x, int *y){
    N = n;
    bit.init(N + 1);
    X.assign(N + 1, 0), Y.assign(N + 1, 0);
    lgX.assign(N + 1, 0.0), lgY.assign(N + 1, 0.0), PlgX.assign(N + 1, 0.0);
    for(int i = 1; i <= n; ++i){
        X[i] = x[i - 1], Y[i] = y[i - 1];
        lgX[i] = log(X[i]), lgY[i] = log(Y[i]);
        PlgX[i] = PlgX[i - 1] + lgX[i];
        bit.modify(i, X[i]);
        seg.modify(1, 1, N, i, i, PlgX[i] + lgY[i]);
    }
    int id = seg.node[1].ss;
    int BX = bit.query(id);
    return 1ll * BX * Y[id] % mod;
}

int updateX(int pos, int val){
    pos++;
    bit.modify(pos, fastpow(X[pos], mod - 2));
    bit.modify(pos, val);
    seg.modify(1, 1, N, pos, N, -lgX[pos]);
    X[pos] = val;
    lgX[pos] = log(val);
    seg.modify(1, 1, N, pos, N, lgX[pos]);
    int id = seg.node[1].ss;
    int BX = bit.query(id);
    return 1ll * BX * Y[id] % mod;
}

int updateY(int pos, int val){
    pos++;
    seg.modify(1, 1, N, pos, pos, -lgY[pos]);
    Y[pos] = val;
    lgY[pos] = log(val);
    seg.modify(1, 1, N, pos, N, lgY[pos]);
    int id = seg.node[1].ss;
    int BX = bit.query(id);
    return 1ll * BX * Y[id] % mod;
}

Compilation message

horses.cpp: In function 'int fastpow(int, int)':
horses.cpp:20:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   20 |         if(b & 1) ret = 1ll * ret * a % mod;
      |                                       ^
horses.cpp:21:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   21 |         a = 1ll * a * a % mod;
      |                         ^
horses.cpp: In member function 'void FenwickTree::modify(int, int)':
horses.cpp:32:66: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   32 |         for(; p < maxn; p += (p & -p)) val[p] = 1ll * x * val[p] % mod;
      |                                                                  ^
horses.cpp: In member function 'int FenwickTree::query(int)':
horses.cpp:37:38: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |             ret = 1ll * ret * val[p] % mod;
      |                                      ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:86:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   86 |     return 1ll * BX * Y[id] % mod;
      |                             ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:99:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   99 |     return 1ll * BX * Y[id] % mod;
      |                             ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:110:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  110 |     return 1ll * BX * Y[id] % mod;
      |                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 62932 KB Output is correct
2 Correct 25 ms 62880 KB Output is correct
3 Correct 27 ms 63052 KB Output is correct
4 Correct 27 ms 62932 KB Output is correct
5 Correct 24 ms 62932 KB Output is correct
6 Correct 24 ms 62932 KB Output is correct
7 Correct 24 ms 62956 KB Output is correct
8 Correct 25 ms 62932 KB Output is correct
9 Correct 27 ms 62932 KB Output is correct
10 Correct 25 ms 62968 KB Output is correct
11 Correct 24 ms 62972 KB Output is correct
12 Correct 23 ms 62924 KB Output is correct
13 Correct 25 ms 62932 KB Output is correct
14 Correct 25 ms 62912 KB Output is correct
15 Correct 26 ms 62868 KB Output is correct
16 Correct 23 ms 62932 KB Output is correct
17 Correct 26 ms 62896 KB Output is correct
18 Correct 25 ms 62876 KB Output is correct
19 Correct 25 ms 62956 KB Output is correct
20 Correct 25 ms 62932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 62932 KB Output is correct
2 Correct 25 ms 62932 KB Output is correct
3 Correct 25 ms 62884 KB Output is correct
4 Correct 26 ms 63004 KB Output is correct
5 Correct 25 ms 62924 KB Output is correct
6 Correct 25 ms 62912 KB Output is correct
7 Correct 24 ms 62932 KB Output is correct
8 Correct 25 ms 62876 KB Output is correct
9 Correct 25 ms 62964 KB Output is correct
10 Correct 27 ms 62892 KB Output is correct
11 Correct 25 ms 62864 KB Output is correct
12 Correct 25 ms 62956 KB Output is correct
13 Correct 25 ms 62940 KB Output is correct
14 Correct 25 ms 62888 KB Output is correct
15 Correct 25 ms 62932 KB Output is correct
16 Correct 29 ms 62968 KB Output is correct
17 Correct 26 ms 62932 KB Output is correct
18 Correct 25 ms 62960 KB Output is correct
19 Correct 26 ms 62932 KB Output is correct
20 Correct 24 ms 62880 KB Output is correct
21 Incorrect 24 ms 62932 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 516 ms 113620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 62944 KB Output is correct
2 Correct 23 ms 62864 KB Output is correct
3 Correct 24 ms 62972 KB Output is correct
4 Correct 24 ms 62840 KB Output is correct
5 Correct 25 ms 62924 KB Output is correct
6 Correct 27 ms 62968 KB Output is correct
7 Correct 25 ms 62860 KB Output is correct
8 Correct 24 ms 62880 KB Output is correct
9 Correct 26 ms 62960 KB Output is correct
10 Correct 25 ms 62980 KB Output is correct
11 Correct 25 ms 62932 KB Output is correct
12 Correct 25 ms 62960 KB Output is correct
13 Correct 29 ms 62876 KB Output is correct
14 Correct 25 ms 62968 KB Output is correct
15 Correct 26 ms 62868 KB Output is correct
16 Correct 23 ms 62924 KB Output is correct
17 Correct 27 ms 62856 KB Output is correct
18 Correct 24 ms 62932 KB Output is correct
19 Correct 26 ms 62932 KB Output is correct
20 Correct 24 ms 62900 KB Output is correct
21 Incorrect 25 ms 62976 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 62952 KB Output is correct
2 Correct 29 ms 62932 KB Output is correct
3 Correct 28 ms 62932 KB Output is correct
4 Correct 25 ms 62904 KB Output is correct
5 Correct 25 ms 62920 KB Output is correct
6 Correct 25 ms 62912 KB Output is correct
7 Correct 25 ms 62916 KB Output is correct
8 Correct 25 ms 62924 KB Output is correct
9 Correct 25 ms 62964 KB Output is correct
10 Correct 25 ms 62872 KB Output is correct
11 Correct 26 ms 62876 KB Output is correct
12 Correct 25 ms 62892 KB Output is correct
13 Correct 25 ms 62924 KB Output is correct
14 Correct 25 ms 62932 KB Output is correct
15 Correct 26 ms 62932 KB Output is correct
16 Correct 27 ms 62892 KB Output is correct
17 Correct 25 ms 62864 KB Output is correct
18 Correct 25 ms 62920 KB Output is correct
19 Correct 25 ms 62900 KB Output is correct
20 Correct 24 ms 62932 KB Output is correct
21 Incorrect 29 ms 62896 KB Output isn't correct
22 Halted 0 ms 0 KB -