Submission #834047

#TimeUsernameProblemLanguageResultExecution timeMemory
834047EllinorHorses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
//#include<bits/stdc++.h> #include <iostream> #include <vector> #include <queue> #include <string> #include <cmath> #include <cstdlib> #include <set> #include <iomanip> #include <limits> #include <map> #include <assert.h> #include <algorithm> #include <list> #include <iterator> #include <fstream> #include <random> #include <unordered_map> #include <array> using namespace std; #define rep(i,a,b) for (int i = (a); i < b; i++) #define pb push_back #define all(x) x.begin(), x.end() typedef long long ll; typedef pair<int, int> pii; ll MOD = 1e9 + 7; // !? // fast #include "horses.h" // ! int n; vector<ll> x, y; int init(int N, int X[], int Y[]) { n = N; x.assign(N, 0); y.assign(N, 0); rep(i,0,N) { x[i] = X[i]; y[i] = Y[i]; } int ans = 0; int horses = 1; rep(i,0,N) { horses *= x[i]; ans = max(ans, horses * y[i]); } return ans; } int updateX(int pos, int val) { x[pos] = val; int ans = 0; int horses = 1; rep(i,0,N) { horses *= x[i]; ans = max(ans, horses * y[i]); } return ans; } int updateY(int pos, int val) { y[pos] = val; int ans = 0; int horses = 1; rep(i,0,N) { horses *= x[i]; ans = max(ans, horses * y[i]); } return ans; } // 17p, M = 0

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:50:22: 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]
   50 |         horses *= x[i];
      |                      ^
horses.cpp:51:37: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   51 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from horses.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
horses.cpp:51:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   51 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from horses.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
horses.cpp:51:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   51 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from horses.cpp:13:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
horses.cpp:51:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from horses.cpp:13:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
horses.cpp:51:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |         ans = max(ans, horses * y[i]);
      |                                     ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:63:13: error: 'N' was not declared in this scope
   63 |     rep(i,0,N) {
      |             ^
horses.cpp:22:42: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                          ^
horses.cpp:64:22: 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]
   64 |         horses *= x[i];
      |                      ^
horses.cpp:65:37: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   65 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from horses.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
horses.cpp:65:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   65 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from horses.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
horses.cpp:65:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   65 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from horses.cpp:13:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
horses.cpp:65:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from horses.cpp:13:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
horses.cpp:65:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |         ans = max(ans, horses * y[i]);
      |                                     ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:77:13: error: 'N' was not declared in this scope
   77 |     rep(i,0,N) {
      |             ^
horses.cpp:22:42: note: in definition of macro 'rep'
   22 | #define rep(i,a,b) for (int i = (a); i < b; i++)
      |                                          ^
horses.cpp:78:22: 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]
   78 |         horses *= x[i];
      |                      ^
horses.cpp:79:37: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   79 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from horses.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
horses.cpp:79:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   79 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from horses.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
horses.cpp:79:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   79 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from horses.cpp:13:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
horses.cpp:79:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |         ans = max(ans, horses * y[i]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from horses.cpp:13:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
horses.cpp:79:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   79 |         ans = max(ans, horses * y[i]);
      |                                     ^