제출 #1117040

#제출 시각아이디문제언어결과실행 시간메모리
1117040epicci23Roller Coaster Railroad (IOI16_railroad)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "railroad.h" #define long long ll #define all(v) v.begin() , v.end() #define sz(a) (ll)a.size() using namespace std; const ll INF = 1e18; struct DSU{ vector<ll> par,siz; DSU(ll _n){ par.assign(_n,0); iota(all(par),0); siz.assign(_n,1); } ll find(ll a){ if(par[a]==a) return a; return par[a]=find(par[a]); } void unite(ll a,ll b){ a = find(a) , b = find(b); if(a == b) return; if(siz[a] > siz[b]) swap(a, b); siz[b] += siz[a]; par[a] = b; } }; ll plan_roller_coaster(vector<int> _s, vector<int> _t){ ll n = sz(_s); array<ll,2> ar[n + 5]; for(ll i = 1; i <= n; i++) ar[i][0] = _s[i], ar[i][1] = _t[i]; ar[0] = {INF,1LL}; vector<ll> zip; for(ll i=0;i<=n;i++){ zip.push_back(ar[i][0]); zip.push_back(ar[i][1]); } sort(all(zip)); zip.erase(unique(all(zip)),zip.end()); auto Get = [&](ll val) -> ll{ ll it = lower_bound(all(zip),val) - zip.begin(); return it; }; ll m = sz(zip); vector<ll> art(m+5,0),eks(m+5,0); DSU dsu(m+5); for(ll i = 0; i <= n ; i++){ ll a = Get(ar[i][0]); art[a]++; ll b = Get(ar[i][1]); eks[b]++; dsu.unite(a,b); } ll pa=0,pb=0,ans=0; for(ll i=0;i<m;i++){ pa += art[i]; pb += eks[i]; if(pa > pb) ans+=(pa-pb)*(zip[i+1]-zip[i]); if(pa != pb) dsu.unite(i,i+1); } vector<array<ll,3>> edges; for(ll i=0;i+1<m;i++){ if(dsu.find(i)!=dsu.find(i+1)) edges.push_back({zip[i+1]-zip[i],i,i+1}); } sort(all(edges)); for(auto x:edges){ if(dsu.find(x[1])!=dsu.find(x[2])){ ans += x[0]; dsu.unite(x[1],x[2]); } } return ans; } /*void _(){ ll n; cin >> n; array<ll,2> ar[n+5]; for(ll i=1;i<=n;i++) cin >> ar[i][0] >> ar[i][1]; ar[0] = {INF,1}; vector<ll> zip; for(ll i=0;i<=n;i++){ zip.push_back(ar[i][0]); zip.push_back(ar[i][1]); } sort(all(zip)); zip.erase(unique(all(zip)),zip.end()); auto Get = [&](ll val){ ll it = lower_bound(all(zip),val) - zip.begin(); return it; }; ll m = sz(zip); vector<ll> art(m+5,0),eks(m+5,0); DSU dsu(m+5); for(ll i = 0; i <= n ; i++){ ll a = Get(ar[i][0]); art[a]++; ll b = Get(ar[i][1]); eks[b]++; dsu.unite(a,b); } ll pa=0,pb=0,ans=0; for(ll i=0;i<m;i++){ pa += art[i]; pb += eks[i]; if(pa > pb) ans+=(pa-pb)*(zip[i+1]-zip[i]); if(pa != pb) dsu.unite(i,i+1); } vector<array<ll,3>> edges; for(ll i=0;i+1<m;i++){ if(dsu.find(i)!=dsu.find(i+1)) edges.push_back({zip[i+1]-zip[i],i,i+1}); } sort(all(edges)); for(auto x:edges){ if(dsu.find(x[1])!=dsu.find(x[2])){ ans += x[0]; dsu.unite(x[1],x[2]); } } cout << ans << '\n'; } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); ll tc=1;//cin >> tc; while(tc--) _(); return 0; }*/

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

railroad.cpp:8:7: error: 'll' does not name a type; did you mean 'all'?
    8 | const ll INF = 1e18;
      |       ^~
      |       all
railroad.cpp:11:10: error: 'll' was not declared in this scope; did you mean 'all'?
   11 |   vector<ll> par,siz;
      |          ^~
      |          all
railroad.cpp:11:12: error: template argument 1 is invalid
   11 |   vector<ll> par,siz;
      |            ^
railroad.cpp:11:12: error: template argument 2 is invalid
railroad.cpp:12:9: error: expected ')' before '_n'
   12 |   DSU(ll _n){
      |      ~  ^~~
      |         )
railroad.cpp:17:3: error: 'll' does not name a type; did you mean 'all'?
   17 |   ll find(ll a){
      |   ^~
      |   all
railroad.cpp:21:14: error: 'll' has not been declared
   21 |   void unite(ll a,ll b){
      |              ^~
railroad.cpp:21:19: error: 'll' has not been declared
   21 |   void unite(ll a,ll b){
      |                   ^~
railroad.cpp: In member function 'void DSU::unite(int, int)':
railroad.cpp:22:14: error: no matching function for call to 'find(int&)'
   22 |    a = find(a) , b = find(b);
      |              ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 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 railroad.cpp:1:
/usr/include/c++/10/bits/streambuf_iterator.h:422: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&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
railroad.cpp:22:14: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   22 |    a = find(a) , b = find(b);
      |              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railroad.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3894:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3894 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:3894:5: note:   template argument deduction/substitution failed:
railroad.cpp:22:14: note:   candidate expects 3 arguments, 1 provided
   22 |    a = find(a) , b = find(b);
      |              ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railroad.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note:   template argument deduction/substitution failed:
railroad.cpp:22:14: note:   candidate expects 4 arguments, 1 provided
   22 |    a = find(a) , b = find(b);
      |              ^
railroad.cpp:22:28: error: no matching function for call to 'find(int&)'
   22 |    a = find(a) , b = find(b);
      |                            ^
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 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 railroad.cpp:1:
/usr/include/c++/10/bits/streambuf_iterator.h:422: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&)'
  422 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/10/bits/streambuf_iterator.h:422:5: note:   template argument deduction/substitution failed:
railroad.cpp:22:28: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   22 |    a = find(a) , b = find(b);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railroad.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3894:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3894 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/10/bits/stl_algo.h:3894:5: note:   template argument deduction/substitution failed:
railroad.cpp:22:28: note:   candidate expects 3 arguments, 1 provided
   22 |    a = find(a) , b = find(b);
      |                            ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railroad.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:60:1: note:   template argument deduction/substitution failed:
railroad.cpp:22:28: note:   candidate expects 4 arguments, 1 provided
   22 |    a = find(a) , b = find(b);
      |                            ^
railroad.cpp:24:10: error: invalid types 'int[int]' for array subscript
   24 |    if(siz[a] > siz[b]) swap(a, b);
      |          ^
railroad.cpp:24:19: error: invalid types 'int[int]' for array subscript
   24 |    if(siz[a] > siz[b]) swap(a, b);
      |                   ^
railroad.cpp:25:7: error: invalid types 'int[int]' for array subscript
   25 |    siz[b] += siz[a];
      |       ^
railroad.cpp:25:17: error: invalid types 'int[int]' for array subscript
   25 |    siz[b] += siz[a];
      |                 ^
railroad.cpp:26:7: error: invalid types 'int[int]' for array subscript
   26 |    par[a] = b;
      |       ^
railroad.cpp: At global scope:
railroad.cpp:32:1: error: 'll' does not name a type; did you mean 'all'?
   32 | ll plan_roller_coaster(vector<int> _s, vector<int> _t){
      | ^~
      | all