답안 #735533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735533 2023-05-04T10:07:41 Z sandry24 말 (IOI15_horses) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int mod = 1e9+7;
const int maxn = 500005;

struct node {
    double logsum;
    double mult;
    ll bestlogsum;
    ll bestmult;
};

node st[4*maxn];
ll x[maxn], y[maxn];

void combine(int v, int l, int r){
    st[v].logsum = st[l].logsum + st[r].logsum;
    st[v].mult = (st[l].mult * st[r].mult) % mod;
    if(st[l].bestlogsum > st[l].logsum + st[r].bestlogsum){
        st[v].bestlogsum = st[l].bestlogsum;
        st[v].bestmult = st[l].bestmult;
    } else {
        st[v].bestlogsum = st[l].logsum + st[r].bestlogsum;
        st[v].bestmult = (st[l].mult * st[l].bestmult) % mod;
    }
}

void build(int v, int tl, int tr){
    if(tl == tr){
        st[v].logsum = log10(x[tl]);
        st[v].mult = x[tl];
        st[v].bestlogsum = st[v].logsum + log10(y[tl]);
        st[v].bestmult = (st[v].mult * y[tl]) % mod;
    } else {
        int tm = (tl+tr)/2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        combine(v, v*2, v*2+1);
    }
}

void update(int v, int tl, int tr, int pos, int val){
    if(tl == tr){
        st[v].logsum = log10(x[tl]);
        st[v].mult = x[tl];
        st[v].bestlogsum = st[v].logsum + log10(y[tl]);
        st[v].bestmult = (st[v].mult * y[tl]) % mod;
    } else {
        int tm = (tl+tr)/2;
        if(pos <= tm)
            update(v*2, tl, tm, pos, val);
        else
            update(v*2+1, tm+1, tr, pos, val);
        combine(v, v*2, v*2+1);
    }
}

int init(int N, int X[], int Y[]){
    for(int i = 0; i < N; i++)
        x[i] = X[i], y[i] = Y[i];
    build(1, 0, n-1);
    return st[1].bestmult;
}

int updateX(int pos, int val){
    x[pos] = val;
    update(1, 0, n-1, pos, val);
    return st[1].bestmult;
}

int updateY(int pos, int val){
    y[pos] = val;
    update(1, 0, n-1, pos, val);
    return st[1].bestmult;
}

Compilation message

horses.cpp: In function 'void combine(int, int, int)':
horses.cpp:30:44: error: invalid operands of types 'double' and 'const int' to binary 'operator%'
   30 |     st[v].mult = (st[l].mult * st[r].mult) % mod;
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      |                              |               |
      |                              double          const int
horses.cpp:31:48: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   31 |     if(st[l].bestlogsum > st[l].logsum + st[r].bestlogsum){
      |                                          ~~~~~~^~~~~~~~~~
horses.cpp:31:14: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   31 |     if(st[l].bestlogsum > st[l].logsum + st[r].bestlogsum){
      |        ~~~~~~^~~~~~~~~~
horses.cpp:35:49: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   35 |         st[v].bestlogsum = st[l].logsum + st[r].bestlogsum;
      |                                           ~~~~~~^~~~~~~~~~
horses.cpp:35:41: warning: conversion from 'double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   35 |         st[v].bestlogsum = st[l].logsum + st[r].bestlogsum;
      |                            ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
horses.cpp:36:46: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   36 |         st[v].bestmult = (st[l].mult * st[l].bestmult) % mod;
      |                                        ~~~~~~^~~~~~~~
horses.cpp:36:56: error: invalid operands of types 'double' and 'const int' to binary 'operator%'
   36 |         st[v].bestmult = (st[l].mult * st[l].bestmult) % mod;
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      |                                      |                   |
      |                                      double              const int
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:43:26: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   43 |         st[v].mult = x[tl];
      |                      ~~~~^
horses.cpp:44:41: warning: conversion from 'double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   44 |         st[v].bestlogsum = st[v].logsum + log10(y[tl]);
      |                            ~~~~~~~~~~~~~^~~~~~~~~~~~~~
horses.cpp:45:44: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   45 |         st[v].bestmult = (st[v].mult * y[tl]) % mod;
      |                                        ~~~~^
horses.cpp:45:47: error: invalid operands of types 'double' and 'const int' to binary 'operator%'
   45 |         st[v].bestmult = (st[v].mult * y[tl]) % mod;
      |                          ~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      |                                      |          |
      |                                      double     const int
horses.cpp: In function 'void update(int, int, int, int, int)':
horses.cpp:57:26: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   57 |         st[v].mult = x[tl];
      |                      ~~~~^
horses.cpp:58:41: warning: conversion from 'double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   58 |         st[v].bestlogsum = st[v].logsum + log10(y[tl]);
      |                            ~~~~~~~~~~~~~^~~~~~~~~~~~~~
horses.cpp:59:44: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   59 |         st[v].bestmult = (st[v].mult * y[tl]) % mod;
      |                                        ~~~~^
horses.cpp:59:47: error: invalid operands of types 'double' and 'const int' to binary 'operator%'
   59 |         st[v].bestmult = (st[v].mult * y[tl]) % mod;
      |                          ~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      |                                      |          |
      |                                      double     const int
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:73:17: error: 'n' was not declared in this scope
   73 |     build(1, 0, n-1);
      |                 ^
horses.cpp:74:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   74 |     return st[1].bestmult;
      |            ~~~~~~^~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:79:18: error: 'n' was not declared in this scope
   79 |     update(1, 0, n-1, pos, val);
      |                  ^
horses.cpp:80:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   80 |     return st[1].bestmult;
      |            ~~~~~~^~~~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:85:18: error: 'n' was not declared in this scope
   85 |     update(1, 0, n-1, pos, val);
      |                  ^
horses.cpp:86:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |     return st[1].bestmult;
      |            ~~~~~~^~~~~~~~