제출 #719459

#제출 시각아이디문제언어결과실행 시간메모리
719459thimote75말 (IOI15_horses)C++14
17 / 100
271 ms45768 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define ld long double #define num long long const num MOD = 1e9 + 7; vector<num> X; vector<num> Y; struct SGD { double mx_ls = 0; double se_ls = 0; num mx_pv = 1; num se_pv = 1; void merge (SGD &l, SGD &r) { se_ls = l.se_ls + r.se_ls; se_pv = (l.se_pv * r.se_pv) % MOD; mx_ls = max(l.mx_ls, r.mx_ls + l.se_ls); if (mx_ls == l.mx_ls) mx_pv = l.mx_pv; else mx_pv = (l.se_pv * r.mx_pv) % MOD; } }; struct SegTree { int size, start, height; vector<SGD> tree; SegTree (int _size) { size = _size; height = ceil(log2(size)); start = 1 << height; tree.resize(start << 1); } num query () { return tree[1].mx_pv; } void _update (int index) { if (index == 0) return ; if (index < start) { int n0 = index << 1; int n1 = n0 + 1; tree[index].merge(tree[n0], tree[n1]); } _update(index >> 1); } void update (int pos, int x, int y) { pos += start; tree[pos].se_ls = log((ld) x); tree[pos].mx_ls = log((ld) x) + log((ld) y); tree[pos].se_pv = x; tree[pos].mx_pv = (x * y) % MOD; _update(pos); } }; SegTree tree(1); int compute () { return max(1, (int) tree.query()); } int init(int N, int _X[], int _Y[]) { X.resize(N); Y.resize(N); tree = SegTree(N); for (int i = 0; i < N; i ++) { X [i] = _X[i]; Y [i] = _Y[i]; tree.update(i, X[i], Y[i]); } return compute(); } int updateX(int i, int val) { X [i] = val; tree.update(i, X[i], Y[i]); return compute(); } int updateY(int i, int val) { Y [i] = val; tree.update(i, X[i], Y[i]); return compute(); }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In constructor 'SegTree::SegTree(int)':
horses.cpp:38:16: warning: conversion from 'double' to 'int' may change value [-Wfloat-conversion]
   38 |   height = ceil(log2(size));
      |            ~~~~^~~~~~~~~~~~
horses.cpp: In member function 'void SegTree::update(int, int, int)':
horses.cpp:61:24: warning: conversion from 'long double' to 'double' may change value [-Wfloat-conversion]
   61 |   tree[pos].se_ls = log((ld) x);
      |                     ~~~^~~~~~~~
horses.cpp:62:33: warning: conversion from 'long double' to 'double' may change value [-Wfloat-conversion]
   62 |   tree[pos].mx_ls = log((ld) x) + log((ld) y);
      |                     ~~~~~~~~~~~~^~~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:86:28: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |   tree.update(i, X[i], Y[i]);
      |                            ^
horses.cpp:86:28: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:94:27: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   94 |  tree.update(i, X[i], Y[i]);
      |                           ^
horses.cpp:94:27: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:100:27: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
  100 |  tree.update(i, X[i], Y[i]);
      |                           ^
horses.cpp:100:27: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...