답안 #452118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
452118 2021-08-03T19:40:01 Z JovanB 말 (IOI15_horses) C++17
100 / 100
485 ms 96500 KB
#include "horses.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
struct drvo{
    ld val;
    ld lazy;
    int prod;
    int lazyprod;
} seg[4000000];
 
ld x[1000005];
ld y[1000005];
ld xpref[1000005];
int u1[1000005];
int xprod[1000005];
int x1[1000005];
 
int n;
 
const int MOD = 1000000007;
 
int mul(int a, int b){
    return (1LL*a*b)%MOD;
}
 
ll pw(ll a, ll b){
    if(b == 0) return 1;
    ll res = pw(a, b/2);
    res = (res*res)%MOD;
    if(b%2) res = (res*a)%MOD;
    return res;
}

void seginit(int node, int l, int r){
    seg[node].lazyprod = 1;
    if(l == r){
        seg[node].val = xpref[l] + y[l];
        seg[node].prod = mul(xprod[l], u1[l]);
        return;
    }
    int mid = (l+r)/2;
    seginit(node*2, l, mid);
    seginit(node*2+1, mid+1, r);
    if(seg[node*2].val > seg[node*2+1].val){
        seg[node].val = seg[node*2].val;
        seg[node].prod = seg[node*2].prod;
    }
    else{
        seg[node].val = seg[node*2+1].val;
        seg[node].prod = seg[node*2+1].prod;
    }
}
 
void propagate(int node, int l, int r){
    seg[node].val += seg[node].lazy;
    seg[node].prod = mul(seg[node].prod, seg[node].lazyprod);
    if(l == r){
        seg[node].lazy = 0;
        seg[node].lazyprod = 1;
        return;
    }
    seg[node*2].lazy += seg[node].lazy;
    seg[node*2].lazyprod = mul(seg[node*2].lazyprod, seg[node].lazyprod);
    seg[node*2+1].lazy += seg[node].lazy;
    seg[node*2+1].lazyprod = mul(seg[node*2+1].lazyprod, seg[node].lazyprod);
    seg[node].lazy = 0;
    seg[node].lazyprod = 1;
}
 
void upd(int node, int l, int r, int tl, int tr, ld val, int prod){
    propagate(node, l, r);
    if(l > tr || tl > r) return;
    if(tl <= l && r <= tr){
        seg[node].lazy += val;
        seg[node].lazyprod = mul(seg[node].lazyprod, prod);
        propagate(node, l, r);
        return;
    }
    int mid = (l+r)/2;
    upd(node*2, l, mid, tl, tr, val, prod);
    upd(node*2+1, mid+1, r, tl, tr, val, prod);
    if(seg[node*2].val > seg[node*2+1].val){
        seg[node].val = seg[node*2].val;
        seg[node].prod = seg[node*2].prod;
    }
    else{
        seg[node].val = seg[node*2+1].val;
        seg[node].prod = seg[node*2+1].prod;
    }
}
 
int init(int N, int X[], int Y[]) {
    n = N;
    xprod[0] = 1;
    for(int i=0; i<N; i++){
        x[i+1] = log10l(X[i]);
        x1[i+1] = X[i];
        xpref[i+1] = x[i+1] + xpref[i];
        xprod[i+1] = mul(xprod[i], X[i]);
        y[i+1] = log10l(Y[i]);
        u1[i+1] = Y[i];
    }
    seginit(1, 1, n);
    return seg[1].prod;
}
 
int updateX(int pos, int val){
    pos++;
    ld g = x[pos];
    x[pos] = log10l(val);
    int f = x1[pos];
    x1[pos] = val;
    upd(1, 1, n, pos, n, x[pos]-g, mul(x1[pos], pw(f, MOD-2)));
	return seg[1].prod;
}
 
int updateY(int pos, int val) {
    pos++;
    ld g = y[pos];
    y[pos] = log10l(val);
    int f = u1[pos];
    u1[pos] = val;
    upd(1, 1, n, pos, pos, y[pos]-g, mul(u1[pos], pw(f, MOD-2)));
	return seg[1].prod;
}

Compilation message

horses.cpp: In function 'int mul(int, int)':
horses.cpp:28:21: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   28 |     return (1LL*a*b)%MOD;
      |            ~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:118:51: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  118 |     upd(1, 1, n, pos, n, x[pos]-g, mul(x1[pos], pw(f, MOD-2)));
      |                                                 ~~^~~~~~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:128:53: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  128 |     upd(1, 1, n, pos, pos, y[pos]-g, mul(u1[pos], pw(f, MOD-2)));
      |                                                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 87560 KB Output is correct
2 Correct 473 ms 96476 KB Output is correct
3 Correct 430 ms 87744 KB Output is correct
4 Correct 450 ms 91468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 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 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 153 ms 86804 KB Output is correct
34 Correct 154 ms 86852 KB Output is correct
35 Correct 161 ms 93732 KB Output is correct
36 Correct 165 ms 93708 KB Output is correct
37 Correct 155 ms 85064 KB Output is correct
38 Correct 138 ms 85900 KB Output is correct
39 Correct 145 ms 84952 KB Output is correct
40 Correct 158 ms 88872 KB Output is correct
41 Correct 143 ms 84972 KB Output is correct
42 Correct 132 ms 85028 KB Output is correct
43 Correct 132 ms 89176 KB Output is correct
44 Correct 128 ms 89268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 280 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 440 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
29 Correct 3 ms 460 KB Output is correct
30 Correct 2 ms 444 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 317 ms 87800 KB Output is correct
34 Correct 485 ms 96500 KB Output is correct
35 Correct 443 ms 87560 KB Output is correct
36 Correct 448 ms 91512 KB Output is correct
37 Correct 153 ms 86900 KB Output is correct
38 Correct 152 ms 86816 KB Output is correct
39 Correct 163 ms 93724 KB Output is correct
40 Correct 166 ms 93680 KB Output is correct
41 Correct 144 ms 85060 KB Output is correct
42 Correct 139 ms 85944 KB Output is correct
43 Correct 133 ms 84876 KB Output is correct
44 Correct 154 ms 88772 KB Output is correct
45 Correct 133 ms 84948 KB Output is correct
46 Correct 132 ms 85048 KB Output is correct
47 Correct 132 ms 89140 KB Output is correct
48 Correct 134 ms 89272 KB Output is correct
49 Correct 447 ms 88888 KB Output is correct
50 Correct 450 ms 88804 KB Output is correct
51 Correct 349 ms 95672 KB Output is correct
52 Correct 365 ms 95192 KB Output is correct
53 Correct 443 ms 87172 KB Output is correct
54 Correct 347 ms 87744 KB Output is correct
55 Correct 309 ms 85964 KB Output is correct
56 Correct 354 ms 90620 KB Output is correct
57 Correct 316 ms 86552 KB Output is correct
58 Correct 331 ms 87184 KB Output is correct
59 Correct 131 ms 89188 KB Output is correct