Submission #499906

# Submission time Handle Problem Language Result Execution time Memory
499906 2021-12-30T00:00:03 Z ETK Fountain Parks (IOI21_parks) C++17
Compilation error
0 ms 0 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sz(A) int(A.size())
#define pii pair<int,int>
const int N = 1e5+5;
vi U,V,A,B;
int p[N],fa[N],lst[N];
void add(int u,int v,int a,int b){
    fa[find(u)]=find(v);
    U.push_back(u-1),V.push_back(v-1);
    A.push_back(a),B.push_back(b);
    if(a>lst[b])lst[b] = a;
}
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
struct node{int x,y;}v[N];
bool cmp(int x,int y){return v[x].x==v[y].x?v[x].y<v[y].y:v[x].x<v[y].x;}
int construct_roads(vi x,vi y){
    int n = sz(x);
    for(int i=1;i<=n;i++)fa[i]=p[i]=i,v[i]={x[i-1],y[i-1]};
    sort(p+1,p+n+1,cmp);
    for(int i=1;i<=n;i++){
        int id = p[i];
        auto [x,y] = v[id];
        bool odd = (x^y)&2;
        if(i>1 && v[p[i-1]].x==x && v[p[i-1]].y==y-2){//vertical
            int k = p[i-1];
            if(find(k)!=find(id)){
                if(odd){
                    if(lst[y-1]==x-1)add(lst[y],id,x-1,y+1);
                    else add(lst[y],id,x-1,y-1);
                }else add(k,id,x+1,y-1);
            }
        }
        if(lst[y] && v[lst[y]].x == x-2){//horizontal
            int k = p[lst[y]];
            if(find(k)!=find(id)){
                if(odd)add(k,id,x-1,y+1);
                else{
                    if(lst[y-1]==x-1){}
                    else add(k,id,x-1,y-1);
                }
            }
        }
        lst[y] = id;
    }
    int c=0;
    for(int i=1;i<=n;i++)c+=(fa[i]==i);
    if(c>1)return 0;
    build(U,V,A,B);
    return 1;
}

Compilation message

parks.cpp: In function 'void add(int, int, int, int)':
parks.cpp:11:14: error: no matching function for call to 'find(int&)'
   11 |     fa[find(u)]=find(v);
      |              ^
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 parks.cpp:2:
/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:
parks.cpp:11:14: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   11 |     fa[find(u)]=find(v);
      |              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parks.cpp:2:
/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:
parks.cpp:11:14: note:   candidate expects 3 arguments, 1 provided
   11 |     fa[find(u)]=find(v);
      |              ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parks.cpp:2:
/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:
parks.cpp:11:14: note:   candidate expects 4 arguments, 1 provided
   11 |     fa[find(u)]=find(v);
      |              ^
parks.cpp:11:23: error: no matching function for call to 'find(int&)'
   11 |     fa[find(u)]=find(v);
      |                       ^
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 parks.cpp:2:
/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:
parks.cpp:11:23: note:   mismatched types 'std::istreambuf_iterator<_CharT>' and 'int'
   11 |     fa[find(u)]=find(v);
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parks.cpp:2:
/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:
parks.cpp:11:23: note:   candidate expects 3 arguments, 1 provided
   11 |     fa[find(u)]=find(v);
      |                       ^
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parks.cpp:2:
/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:
parks.cpp:11:23: note:   candidate expects 4 arguments, 1 provided
   11 |     fa[find(u)]=find(v);
      |                       ^