답안 #670093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670093 2022-12-08T06:15:38 Z Astrayt 말 (IOI15_horses) C++17
17 / 100
227 ms 66256 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 pii pair<int,int>
#define pb push_back
#define maxn 500005
#define mod 1000000007
#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 = 1; 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);
    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){
    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){
    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;
}

/*void solve(){
    int n, m; cin >> n;
    int x[n], y[n];
    for(int i = 0; i < n; ++i) cin >> x[i] >> y[i];
    cin >> m;
    cout << init(n, x, y) << '\n';
    for(int i = 0; i < m; ++i){
        int t, p, v; cin >> t >> p >> v;
        if(t == 1){
            cout << updateX(p + 1, v) << '\n';
        }else{
            cout << updateY(p + 1, v) << '\n';
        }
    }
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}*/

Compilation message

horses.cpp: In function 'int fastpow(int, int)':
horses.cpp:19:39: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   19 |         if(b & 1) ret = 1ll * ret * a % mod;
      |                                       ^
horses.cpp:20:25: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   20 |         a = 1ll * a * a % mod;
      |                         ^
horses.cpp: In member function 'void FenwickTree::modify(int, int)':
horses.cpp:31:66: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   31 |         for(; p < maxn; p += (p & -p)) val[p] = 1ll * x * val[p] % mod;
      |                                                                  ^
horses.cpp: In member function 'int FenwickTree::query(int)':
horses.cpp:36:38: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   36 |             ret = 1ll * ret * val[p] % mod;
      |                                      ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:85:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   85 |     return 1ll * BX * Y[id] % mod;
      |                             ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:97:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   97 |     return 1ll * BX * Y[id] % mod;
      |                             ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:107:29: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  107 |     return 1ll * BX * Y[id] % mod;
      |                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31568 KB Output is correct
2 Correct 13 ms 31572 KB Output is correct
3 Correct 15 ms 31572 KB Output is correct
4 Correct 13 ms 31572 KB Output is correct
5 Correct 13 ms 31624 KB Output is correct
6 Correct 13 ms 31572 KB Output is correct
7 Correct 13 ms 31572 KB Output is correct
8 Correct 13 ms 31620 KB Output is correct
9 Correct 13 ms 31572 KB Output is correct
10 Correct 13 ms 31572 KB Output is correct
11 Correct 14 ms 31596 KB Output is correct
12 Correct 14 ms 31700 KB Output is correct
13 Correct 13 ms 31584 KB Output is correct
14 Correct 13 ms 31584 KB Output is correct
15 Correct 13 ms 31568 KB Output is correct
16 Correct 13 ms 31552 KB Output is correct
17 Correct 13 ms 31572 KB Output is correct
18 Correct 13 ms 31572 KB Output is correct
19 Correct 12 ms 31572 KB Output is correct
20 Correct 13 ms 31636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 12 ms 31572 KB Output is correct
3 Correct 12 ms 31620 KB Output is correct
4 Correct 13 ms 31644 KB Output is correct
5 Correct 13 ms 31572 KB Output is correct
6 Correct 13 ms 31572 KB Output is correct
7 Correct 16 ms 31600 KB Output is correct
8 Correct 13 ms 31564 KB Output is correct
9 Correct 14 ms 31624 KB Output is correct
10 Correct 15 ms 31608 KB Output is correct
11 Correct 15 ms 31632 KB Output is correct
12 Correct 13 ms 31620 KB Output is correct
13 Correct 13 ms 31572 KB Output is correct
14 Correct 13 ms 31620 KB Output is correct
15 Correct 13 ms 31560 KB Output is correct
16 Correct 14 ms 31664 KB Output is correct
17 Correct 13 ms 31616 KB Output is correct
18 Correct 13 ms 31560 KB Output is correct
19 Correct 13 ms 31724 KB Output is correct
20 Correct 13 ms 31572 KB Output is correct
21 Incorrect 14 ms 31572 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 227 ms 66256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31548 KB Output is correct
2 Correct 14 ms 31652 KB Output is correct
3 Correct 12 ms 31572 KB Output is correct
4 Correct 12 ms 31572 KB Output is correct
5 Correct 13 ms 31608 KB Output is correct
6 Correct 13 ms 31572 KB Output is correct
7 Correct 13 ms 31572 KB Output is correct
8 Correct 13 ms 31624 KB Output is correct
9 Correct 13 ms 31572 KB Output is correct
10 Correct 13 ms 31572 KB Output is correct
11 Correct 13 ms 31572 KB Output is correct
12 Correct 15 ms 31600 KB Output is correct
13 Correct 13 ms 31564 KB Output is correct
14 Correct 14 ms 31572 KB Output is correct
15 Correct 14 ms 31616 KB Output is correct
16 Correct 13 ms 31572 KB Output is correct
17 Correct 13 ms 31572 KB Output is correct
18 Correct 13 ms 31720 KB Output is correct
19 Correct 16 ms 31620 KB Output is correct
20 Correct 13 ms 31628 KB Output is correct
21 Incorrect 13 ms 31652 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 31572 KB Output is correct
2 Correct 13 ms 31568 KB Output is correct
3 Correct 12 ms 31656 KB Output is correct
4 Correct 12 ms 31632 KB Output is correct
5 Correct 13 ms 31580 KB Output is correct
6 Correct 13 ms 31584 KB Output is correct
7 Correct 13 ms 31572 KB Output is correct
8 Correct 14 ms 31648 KB Output is correct
9 Correct 13 ms 31572 KB Output is correct
10 Correct 13 ms 31572 KB Output is correct
11 Correct 14 ms 31632 KB Output is correct
12 Correct 13 ms 31572 KB Output is correct
13 Correct 13 ms 31572 KB Output is correct
14 Correct 15 ms 31608 KB Output is correct
15 Correct 13 ms 31640 KB Output is correct
16 Correct 13 ms 31604 KB Output is correct
17 Correct 13 ms 31572 KB Output is correct
18 Correct 13 ms 31604 KB Output is correct
19 Correct 14 ms 31572 KB Output is correct
20 Correct 13 ms 31632 KB Output is correct
21 Incorrect 14 ms 31616 KB Output isn't correct
22 Halted 0 ms 0 KB -