제출 #1207021

#제출 시각아이디문제언어결과실행 시간메모리
1207021pera말 (IOI15_horses)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#include "horses.h"
#define LL long long
using namespace std;
const int N_MAX = 5E5 + 1;
const LL mod = 1E9 + 7;
const __int128 oo = 1E9;
int n;
set<int> S;
vector<LL> x(N_MAX) , y(N_MAX);
int calc(){
   if(S.empty()){
      int mx = 0;
      for(int i = 0;i < n;i ++){
         mx = max(mx , y[i]);
      }
      return mx;
   }
   int j = 0; 
   __int128 prd = 1;
   auto it = --S.end();
   while(true){
      j = *it;
      if(__int128(x[*it]) * prd > oo){
         break;
      }
      if(it == S.begin()){
         j = 0;
         break;
      }
      prd *= __int128(x[i]);
      --it;
   }
   prd = 1;
   __int128 best = 0;
   for(int i = j;i < n;i ++){
      prd *= __int128(x[i]);
      __int128 A = __int128(prd) * __int128(y[i]);
      best = max(best , A);
   }
   best %= mod;
   for(int i = 0;i < j;i ++){
      best = x[i] * best % mod;
   }
   best %= mod;
   return (int)best;
}

int init(int N, int X[], int Y[]) {
   n = N;
   for(int i = 0;i < N;i ++){
      x[i] = X[i];
      y[i] = Y[i];
      if(x[i] > 1){
         S.insert(i);
      }
   }
   return calc();
}

int updateX(int pos, int val) {	
   if(x[pos] > 1){
      S.erase(pos);
   }
   x[pos] = val;
   if(x[pos] > 1){
      S.insert(pos);
   }
	return calc();
}

int updateY(int pos, int val) {
   y[pos] = val;
	return calc();
}

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

horses.cpp: In function 'int calc()':
horses.cpp:15:18: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   15 |          mx = max(mx , y[i]);
      |               ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from horses.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
horses.cpp:15:18: 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'})
   15 |          mx = max(mx , y[i]);
      |               ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from horses.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
horses.cpp:15:18: 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'})
   15 |          mx = max(mx , y[i]);
      |               ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from horses.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
horses.cpp:15:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |          mx = max(mx , y[i]);
      |               ~~~^~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from horses.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
horses.cpp:15:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |          mx = max(mx , y[i]);
      |               ~~~^~~~~~~~~~~
horses.cpp:31:25: error: 'i' was not declared in this scope; did you mean 'it'?
   31 |       prd *= __int128(x[i]);
      |                         ^
      |                         it