제출 #132669

#제출 시각아이디문제언어결과실행 시간메모리
132669MoNsTeR_CuBe고대 책들 (IOI17_books)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; long long minimum_walk(std::vector<int> p, int s) { #define int long long int l = 0, r = p.size()-1; int maxi = -1; int ans = -2; int n = p.size(); for(int i = 0; i < (int)p.size(); i++){ l = i; if(p[i] != i){ break; } } for(int i = (int)p.size()-1; i >= 0; i--){ r = i; if(p[i] != i){ break; } } if(l >= r) return 0; if(s == 0){ for(int i = l; i <= r; i++){ ans += abs(p[i]-i); maxi = max(maxi, (int)p[i]); if(i >= maxi){ ans += 2; } } return ans + 2*l; } vector< bool > visited(n, false); ans = 0; for(int i = 0; i < n; i++){ ans += abs(i-p[i]); for(int j = i; j < p[i]; j++){ visited[j] = true; } } for(int i = min(l,s); i <= max(s,r); i++){ ans += (!visited[i])*2; } return ans; #undef int }

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

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:50:21: error: no matching function for call to 'min(long long int&, int&)'
  for(int i = min(l,s); i <= max(s,r); i++){
                     ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
books.cpp:50:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  for(int i = min(l,s); i <= max(s,r); i++){
                     ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
books.cpp:50:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  for(int i = min(l,s); i <= max(s,r); i++){
                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
books.cpp:50:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  for(int i = min(l,s); i <= max(s,r); i++){
                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
books.cpp:50:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  for(int i = min(l,s); i <= max(s,r); i++){
                     ^
books.cpp:50:36: error: no matching function for call to 'max(int&, long long int&)'
  for(int i = min(l,s); i <= max(s,r); i++){
                                    ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
books.cpp:50:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  for(int i = min(l,s); i <= max(s,r); i++){
                                    ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
books.cpp:50:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  for(int i = min(l,s); i <= max(s,r); i++){
                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
books.cpp:50:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  for(int i = min(l,s); i <= max(s,r); i++){
                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from books.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
books.cpp:50:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  for(int i = min(l,s); i <= max(s,r); i++){
                                    ^