제출 #73782

#제출 시각아이디문제언어결과실행 시간메모리
73782nvmdava전선 연결 (IOI17_wiring)C++17
컴파일 에러
0 ms0 KiB
#include "wiring.h" #include <bits/stdc++.h> #define INF 2000000005LL using namespace std; struct Node{ long long x; bool col; Node(long long _x, bool _col){ x = _x; col = _col; } bool operator<(const Node& rhs){ if(x == rhs.x) return col < rhs.col; return x < rhs.x; } }; vector<Node> v; int last[200005][2]; long long ans[200005], s[200005]; inline long long sum(int l, int r, int x){ if(l == x) return s[r] - s[l - 1] - v[l].x * (r - l + 1); return v[r].x * (r - l + 1) - s[r] + s[l - 1]; } inline void find(i){ int r = last[i][v[i].col ^ 1]; int l = last[r][v[i].col] + 1; long long d = v[r + 1].x - v[r].x; ans[i] = 400000000000000000; for(; l <= r; l++){ ans[i] = min(ans[i], ans[l - 1] + sum(l, r, r) + sum(r + 1, i, r + 1) + x * max(r - l + 1, i - r)); } } long long min_total_length(std::vector<int> r, std::vector<int> b) { v.push_back(Node(-INF, 0)); v.push_back(Node(-INF, 1)); last[1][0] = 0; last[1][1] = 1; for(auto x : r){ v.push_back(Node(x, 0)); } for(auto x : b){ v.push_back(Node(x, 1)); } sort(v.begin(), v.end()); s[0] = -INF; s[1] = -INF * 2; for(int i = 2; i < v.size(); i++){ last[i][0] = last[i - 1][0]; last[i][1] = last[i - 1][1]; last[i][v[i].col] = i; s[i] = s[i - 1] + v[i].x; find(i); } return ans[v.size() - 1]; }

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

wiring.cpp:28:19: error: variable or field 'find' declared void
 inline void find(i){
                   ^
wiring.cpp:28:18: error: 'i' was not declared in this scope
 inline void find(i){
                  ^
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:53:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 2; i < v.size(); i++){
                 ~~^~~~~~~~~~
wiring.cpp:58:9: error: no matching function for call to 'find(int&)'
   find(i);
         ^
In file included from /usr/include/c++/7/bits/locale_facets.h:48:0,
                 from /usr/include/c++/7/bits/basic_ios.h:37,
                 from /usr/include/c++/7/ios:44,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from wiring.cpp:2:
/usr/include/c++/7/bits/streambuf_iterator.h:369:5: note: candidate: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)
     find(istreambuf_iterator<_CharT> __first,
     ^~~~
/usr/include/c++/7/bits/streambuf_iterator.h:369:5: note:   template argument deduction/substitution failed:
wiring.cpp:58:9: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   find(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 wiring.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3899:5: note: candidate: template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)
     find(_InputIterator __first, _InputIterator __last,
     ^~~~
/usr/include/c++/7/bits/stl_algo.h:3899:5: note:   template argument deduction/substitution failed:
wiring.cpp:58:9: note:   candidate expects 3 arguments, 1 provided
   find(i);
         ^