제출 #1285836

#제출 시각아이디문제언어결과실행 시간메모리
1285836dimitri.shengelia선물 (IOI25_souvenirs)C++20
컴파일 에러
0 ms0 KiB
#include "souvenirs.h" #include <bits/stdc++.h> #include <utility> #include <vector> using namespace std; pair <vector<int>, long long> transaction(long long M); void buy_souvenirs(int N, long long P0) { pair <vector<int>, long long> res; if ( N == 2 ) { transaction ( P0 - 1 ); } else if ( N == 3 ) { res = transaction ( P0 - 1 ); if ( res.first.size() == 1 ) { transaction ( P0 - 1 - res.second - 1 ); transaction ( P0 - 1 - res.second - 1 ); } else { transaction ( ( P0 - 1 - res.second ) / 2 ); } } else if ( P0 == N ) { for ( int i = 1; i < N; i++ ) { for ( int j = 0; j < i; j++ ) { transaction ( N - i ); } } } else { pair <long long, long long> a[N]; fill ( a, a + N, { 0, 0 } ); a[0] = { P0, 1 }; for ( int i = 1; i < N; i++ ) { res = transaction( a[i - 1].first - 2 ); if ( i == N - 1 ) { while ( a[i].second < i ) { a[i].second++; transaction( a[i - 1].first - 1 ); } } else if ( res.first[0] == i ) { a[i].first = a[i - 1].first - 2; a[i].second++; while ( a[i].second < i ) { a[i].second++; transaction( a[i - 1].second - 2 ); } } else { a[i].first = a[i - 1].first; a[i + 1].second++; while ( a[i].second < i ) { a[i].second++; transaction( a[i - 1].second - 1 ); } } } } return; }

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

souvenirs.cpp: In function 'void buy_souvenirs(int, long long int)':
souvenirs.cpp:48:22: error: no matching function for call to 'fill(std::pair<long long int, long long int> [N], std::pair<long long int, long long int>*, <brace-enclosed initializer list>)'
   48 |                 fill ( a, a + N, { 0, 0 } );
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/vector:62,
                 from souvenirs.h:2,
                 from souvenirs.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:1000:5: note: candidate: 'template<class _ForwardIterator, class _Tp> constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1000 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
/usr/include/c++/13/bits/stl_algobase.h:1000:5: note:   template argument deduction/substitution failed:
souvenirs.cpp:48:22: note:   couldn't deduce template parameter '_Tp'
   48 |                 fill ( a, a + N, { 0, 0 } );
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:73,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from souvenirs.cpp:2:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/13/pstl/glue_algorithm_defs.h:191:1: note:   template argument deduction/substitution failed:
souvenirs.cpp:48:22: note:   variable-sized array type 'std::pair<long long int, long long int> (&)[N]' is not a valid template argument
   48 |                 fill ( a, a + N, { 0, 0 } );
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~