Submission #393467

# Submission time Handle Problem Language Result Execution time Memory
393467 2021-04-23T14:16:17 Z A_D Paint (COI20_paint) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#define int long long
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
int n,m;
const int N=2e5+10;
vector<int> idx[N];
int p[N];
int sz[N];
set<int> st[N];
int a[N];
int x[]={0,0,1,-1};
int y[]={1,-1,0,0};
vector<int> vec;
bool out(int i,int j)
{
    //cout<<i<<" "<<j<<endl;
    bool ans=i<1||j<1||i>n||j>m;
    return ans;
}
int find(int u)
{
    if(u==p[u])return u;
    return p[u]=find(p[u]);
}
void compine(int u,int v)
{
    u=find(u);
    v=find(v);
    if(u==v)return;
    if(st[u]>sz[v]){
        swap(u,v);
    }
    for(auto x:st[u]){
        st[v].push_back(x);
        sz[v]++;
    }
    p[u]=v;
}
void fix()
{
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int x=idx[i][j];
            x=find(x);
            x=a[x];
            printf("%d ",x);
        }
        printf("\n");
    }
/*    cout<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int x=idx[i][j];
            x=find(x);
            cout<<x<<" ";
        }
        cout<<endl;
    }
*/
}
void solve()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        idx[i].resize(m+10);
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cnt++;
            p[cnt]=cnt;
            idx[i][j]=cnt;
            scanf("%d",&a[cnt]);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            vec.clear();
            int u=idx[i][j];
            int c=a[u];
            u=find(u);
            for(int k=0;k<4;k++){
                int ni=i+x[k];
                int nj=j+y[k];

                if(out(ni,nj))continue;

                int v=idx[ni][nj];

                int nc=a[v];

                if(c==nc){
                    vec.push_back(v);
                }
                else{
                    st[u].push_back(v);
                    sz[u]++;
                }
            }
            for(auto x:vec){
//                cout<<x<<endl;
                compine(u,x);
            }
        }
    }
    int q;
    cin>>q;
    while(q--){
//        cout<<"\n\n";
  //      fix();
    //    cout<<"\n\n";
        int c,i,j;
        cin>>i>>j>>c;
        int u=idx[i][j];
        u=find(u);
        a[u]=c;
        vec.clear();
        for(auto x:st[u]){
            int xx=find(x);
//            cout<<x<<" ";
            if(a[xx]==c)vec.push_back(xx);
        }
      //  cout<<endl;
        for(auto x:vec){
            compine(u,x);
        }
    }
    fix();
}
main()
{
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    int t=1;
//    cin>>t;
    while(t--)solve();
}

Compilation message

paint.cpp: In function 'void compine(int, int)':
paint.cpp:34:13: error: no match for 'operator>' (operand types are 'std::set<int>' and 'int')
   34 |     if(st[u]>sz[v]){
      |        ~~~~~^~~~~~
      |            |     |
      |            |     int
      |            std::set<int>
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1081:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator>(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)'
 1081 |     operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1081:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1136:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)'
 1136 |     operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1136:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1210:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1210 |     operator>(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1210:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1284:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)'
 1284 |     operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1284:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1358:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1358 |     operator>(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1358:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1434:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)'
 1434 |     operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1434:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110,
                 from paint.cpp:1:
/usr/include/c++/9/bits/regex.h:1512:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1512 |     operator>(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/regex.h:1512:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_pair.h:467:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  467 |     operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_pair.h:467:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::pair<_T1, _T2>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:343:5: note: candidate: 'template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  343 |     operator>(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:343:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:381:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  381 |     operator>(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:381:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:1187:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator>(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1187 |     operator>(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1187:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:67,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_iterator.h:1193:5: note: candidate: 'template<class _Iterator> bool std::operator>(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1193 |     operator>(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_iterator.h:1193:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::move_iterator<_IteratorL>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6264:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6264 |     operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6264:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6277:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 6277 |     operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6277:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from paint.cpp:1:
/usr/include/c++/9/bits/basic_string.h:6289:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6289 |     operator>(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/9/bits/basic_string.h:6289:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   mismatched types 'const _CharT*' and 'std::set<int>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:68,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_deque.h:327:5: note: candidate: 'template<class _Tp, class _Ref, class _Ptr> bool std::operator>(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)'
  327 |     operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_deque.h:327:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:68,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_deque.h:334:5: note: candidate: 'template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator>(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)'
  334 |     operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_deque.h:334:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::_Deque_iterator<_Tp, _Ref, _Ptr>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:68,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_deque.h:2345:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)'
 2345 |     operator>(const deque<_Tp, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/stl_deque.h:2345:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::deque<_Tp, _Alloc>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/tuple:39,
                 from /usr/include/c++/9/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:71,
                 from paint.cpp:1:
/usr/include/c++/9/array:270:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> bool std::operator>(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)'
  270 |     operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
      |     ^~~~~~~~
/usr/include/c++/9/array:270:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::array<_Tp, _Nm>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:71,
                 from paint.cpp:1:
/usr/include/c++/9/tuple:1451:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const std::tuple<_Tps ...>&, const std::tuple<_Elements ...>&)'
 1451 |     operator>(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/9/tuple:1451:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::tuple<_Tps ...>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/locale_conv.h:41,
                 from /usr/include/c++/9/locale:43,
                 from /usr/include/c++/9/iomanip:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:72,
                 from paint.cpp:1:
/usr/include/c++/9/bits/unique_ptr.h:790:5: note: candidate: 'template<class _Tp, class _Dp, class _Up, class _Ep> bool std::operator>(const std::unique_ptr<_Tp, _Dp>&, const std::unique_ptr<_Up, _Ep>&)'
  790 |     operator>(const unique_ptr<_Tp, _Dp>& __x,
      |     ^~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:790:5: note:   template argument deduction/substitution failed:
paint.cpp:34:18: note:   'std::set<int>' is not derived from 'const std::unique_ptr<_Tp, _Dp>'
   34 |     if(st[u]>sz[v]){
      |                  ^
In file included from /usr/include/c++/9/bits/locale_conv.h:41,
                 from /usr/include/c++/9/locale:43,
                 from /usr/include/c++/9/iomanip:43,
                 from /usr/include/x86_64-linux-gnu/c++