Submission #42415

#TimeUsernameProblemLanguageResultExecution timeMemory
42415yusufake고대 책들 (IOI17_books)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define _ int v, int tl, int tr, int l, int r #define tm (tl+tr >> 1) #define sol v+v,tl,tm,l,r #define sag v+v+1,tm+1,tr,l,r #define mp make_pair #define pb push_back #define st first #define nd second typedef long long ll; typedef pair < ll , ll > pp; const int mod = 1e9 + 7; const int N = 1e6 + 6; ll H[N],A[N],B[N],L[N],R[N],n,i,l,r,x,mn,mx; ll minimum_walk(vector < int > p , int s){ memset(H , 0 , sizeof H); x = 0; n = p.size(); for(i=0;i<n;i++){ x += abs(p[i] - i); if(H[i]) continue; l = r = i; for(x=i; !H[x] ; x = p[x]){ H[x] = 1; l = min(l , i); r = max(r , i); } A[l] = r; B[r] = l; } for(mx=r=-1,i=0;i<n;i++){ if(i > r && p[i] != i) mx = max(mx , i); r = max(r , A[i]); R[i] = r; } for(mn=l=n,i=n-1; i>=0 ;i--){ if(i < r && p[i] != i) mn = max(mn , i); l = min(l , B[i]); L[i] = l; } return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn)); }

Compilation message (stderr)

books.cpp: In function 'll minimum_walk(std::vector<int>, int)':
books.cpp:50:36: error: no matching function for call to 'max(int, ll)'
     return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn));
                                    ^
In file included from /usr/include/c++/5/algorithm:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from books.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/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 'll {aka long long int}')
     return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn));
                                    ^
In file included from /usr/include/c++/5/algorithm:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from books.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/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 'll {aka long long int}')
     return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn));
                                    ^
books.cpp:50:57: error: no matching function for call to 'max(int, ll)'
     return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn));
                                                         ^
In file included from /usr/include/c++/5/algorithm:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from books.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
books.cpp:50:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
     return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn));
                                                         ^
In file included from /usr/include/c++/5/algorithm:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from books.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
books.cpp:50:57: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
     return x + 2 * (max(0 , mx-R[s]) + max(0 , L[s] - mn));
                                                         ^