Submission #160297

#TimeUsernameProblemLanguageResultExecution timeMemory
160297FiloSanzaHorses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; inline int left(int i){return i*2+1;} inline int right(int i){return (i+1)*2;} const int MOD = 1e9+7; int S; vector<pair<int, bool>> segX; vector<int> segM; vector<int> Y; pair<int, bool> mergeX(pair<int, bool> a, pair<int, bool> b){ long long prod = 1LL * a.first * a.second; bool overflow = a.second || b.second || prod >= MOD; return {prod % MOD, overflow}; } pair<int, bool> QueryX(int pos, int l, int r, int a, int b){ if(l > b || r < a) return {1, false}; if(l >= a && r <= b) return segX[pos]; int mid = (l+r)/2; return mergeX( QueryX(left(pos), l, mid, a, b), QueryX(right(pos), mid+1, r, a, b) ); } int mergeY(int a, int b){ auto q = QueryX(0, a+1, b+1, 0, S/2); if(q.second) return b; return Y[a] > 1LL * Y[b] * q.first ? a : b; } int init(int N, int X[], int _Y[]) { S = (1 << (int)ceil(log2(N)+1)) - 1; segX.resize(S, 1); segM.resize(S); Y.resize(N); for(int i=0; i<N; i++){ segX[i+S/2] = {X[i], false}; segM[i+S/2] = i; Y[i] = _Y[i]; } for(int i=S/2-1; i>=0; i--){ segX[i] = mergeX(segX[left(i)], segX[right(i)]); segM[i] = mergeY(segM[left(i)], segM[right(i)]); } for(auto i : segX) cout << i.first << " "; cout << "\n"; return 1LL * QueryX(0, 0, S/2, 0, N-1).first * Y[segM[0]] % MOD; } int updateX(int pos, int val) { return 0; } int updateY(int pos, int val) { return 0; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:40:18: error: no matching function for call to 'std::vector<std::pair<int, bool> >::resize(int&, int)'
  segX.resize(S, 1); 
                  ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from horses.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:689:7: note: candidate: void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<int, bool>; _Alloc = std::allocator<std::pair<int, bool> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]
       resize(size_type __new_size)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:689:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/7/bits/stl_vector.h:709:7: note: candidate: void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::pair<int, bool>; _Alloc = std::allocator<std::pair<int, bool> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::pair<int, bool>]
       resize(size_type __new_size, const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:709:7: note:   no known conversion for argument 2 from 'int' to 'const value_type& {aka const std::pair<int, bool>&}'
horses.cpp:58:60: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return 1LL * QueryX(0, 0, S/2, 0, N-1).first * Y[segM[0]] % MOD;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:61:17: warning: unused parameter 'pos' [-Wunused-parameter]
 int updateX(int pos, int val) { 
                 ^~~
horses.cpp:61:26: warning: unused parameter 'val' [-Wunused-parameter]
 int updateX(int pos, int val) { 
                          ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:65:17: warning: unused parameter 'pos' [-Wunused-parameter]
 int updateY(int pos, int val) {
                 ^~~
horses.cpp:65:26: warning: unused parameter 'val' [-Wunused-parameter]
 int updateY(int pos, int val) {
                          ^~~