제출 #444729

#제출 시각아이디문제언어결과실행 시간메모리
444729penguinhackerDrvca (COCI19_drvca)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=1e5; int n, a[mxN], prv[mxN], nxt[mxN], cnt; vector<int> cur={0}; bool rem[mxN]={1}, bad[mxN]; void calc(int i) { if (0<=i&&i<n) { cnt-=bad[i]; if (rem[i]) bad[i]=0; else { if (prv[i]<0||rem[prv[i]]||nxt[i]>=n||rem[nxt[i]]) bad[i]=0; else bad[i]=a[i]-a[prv[i]]!=a[nxt[i]]-a[i]; } cnt+=bad[i]; } } void ck() { if (cnt) return; assert(cnt==0); vector<bool> other(n, 1); cout << cur.size() << "\n"; for (int i : cur) { other[i]=0; cout << a[i] << " "; } cout << "\n" << n-cur.size() << "\n"; for (int i=0; i<n; ++i) if (other[i]) cout << a[i] << " "; exit(0); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0; i<n; ++i) { cin >> a[i]; prv[i]=i-1; nxt[i]=i+1; } sort(a, a+n); for (int i=1; i<n; ++i) calc(i); ck(); for (int i=1; i<n; ++i) { if (i>1&&a[i]==a[i-1]) continue; int d=a[i]-a[0]; for (int j=i; j<n;) { assert(!rem[j]); nxt[prv[j]]=nxt[j]; prv[nxt[j]]=prv[j]; rem[j]=1; cur.push_back(j); calc(j), calc(prv[j]), calc(nxt[j]); ck(); int p=max(j+1, lower_bound(a, a+n, a[j]+d)-a); if (p==n||a[p]!=a[j]+d) break; j=p; } while(cur.size()>1) { int j=cur.back(); cur.pop_back(); nxt[prv[j]]=j; prv[nxt[j]]=j; rem[j]=0; calc(j), calc(prv[j]), calc(nxt[j]); } } cout << -1; return 0; }

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

drvca.cpp: In function 'int main()':
drvca.cpp:69:48: error: no matching function for call to 'max(int, long int)'
   69 |    int p=max(j+1, lower_bound(a, a+n, a[j]+d)-a);
      |                                                ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from drvca.cpp:1:
/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:
drvca.cpp:69:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   69 |    int p=max(j+1, lower_bound(a, a+n, a[j]+d)-a);
      |                                                ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from drvca.cpp:1:
/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:
drvca.cpp:69:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   69 |    int p=max(j+1, lower_bound(a, a+n, a[j]+d)-a);
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from drvca.cpp:1:
/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:
drvca.cpp:69:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   69 |    int p=max(j+1, lower_bound(a, a+n, a[j]+d)-a);
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from drvca.cpp:1:
/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:
drvca.cpp:69:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   69 |    int p=max(j+1, lower_bound(a, a+n, a[j]+d)-a);
      |                                                ^