Submission #884953

# Submission time Handle Problem Language Result Execution time Memory
884953 2023-12-08T18:04:37 Z maxFedorchuk Dango Maker (JOI18_dango_maker) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const long long MX=2020;

long long mtr[MX][MX];
char ch[MX][MX];


const long long MXK=MX*MX;
vector < long long > mas[2*MXK];
long long usea[2*MXK];
long long pr[2*MXK];

long long timer=0,koma,komb;

bool khuna(long long zar)
{
    if(usea[zar])
    {
        return 0;
    }

    usea[zar]=1;

    for(auto u:mas[zar])
    {
        if(pr[u]==0)
        {
            pr[zar]=u;
            pr[u]=zar;
            return 1;
        }
    }

    for(auto u:mas[zar])
    {
        if(khuna(pr[u]))
        {
            pr[zar]=u;
            pr[u]=zar;
            return 1;
        }
    }

    return 0;
}
void kntkhuna()
{
    while(true)
    {
        fill(usea+1,usea+1+timer,0);

        bool p=0;

        for(long long i=1;i<=koma;i++)
        {
            if(pr[i]==0)
            {
                if(khuna(i))
                {
                    p=1;
                }
            }
        }

        if(!p)
        {
            return;
        }
    }

    return;
}

void DFS(long long zar)
{
    usea[zar]=1;

    if(zar<=koma)
    {
        for(auto u:mas[zar])
        {
            if(pr[u]!=zar && usea[u]==0)
            {
                DFS(u);
            }
        }
    }
    else
    {
        if(usea[pr[zar]]==0)
        {
            DFS(pr[zar]);
        }
    }

    return;
}
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    long long n,m;
    cin>>n>>m;

    for(long long i=1;i<=n;i++)
    {
        for(long long j=1;j<=m;j++)
        {
            cin>>ch[i][j];
        }
    }

    for(long long i=1;i<=n;i++)
    {
        for(long long j=1;(j+2)<=m;j++)
        {
            if(ch[i][j]=='R' && ch[i][j+1]=='G' && ch[i][j+2]=='W')
            {
                timer++;
                mtr[i][j]=timer;
            }
        }
    }
    koma=timer;


    for(long long i=1;(i+2)<=n;i++)
    {
        for(long long j=1;j<=m;j++)
        {
            if(ch[i][j]=='R' && ch[i+1][j]=='G' && ch[i+2][j]=='W')
            {
                timer++;

                for(long long corx=i;corx<=(i+2);corx++)
                {
                    for(long long cory=max(1,j-2);cory<=j;cory++)
                    {
                        if(mtr[corx][cory])
                        {
                            mas[mtr[corx][cory]].push_back(timer);
                            mas[timer].push_back(mtr[corx][cory]);
                        }
                    }
                }
            }
        }
    }
    komb=timer-koma;

    if(koma==0)
    {
        cout<<komb<<"\n";
        return 0;
    }

    if(komb==0)
    {
        cout<<koma<<"\n";
        return 0;
    }

    kntkhuna();
    fill(usea+1,usea+koma+komb+1,0);

    for(long long i=1;i<=koma;i++)
    {
        if(pr[i]==0)
        {
            DFS(i);
        }
    }

    long long res=0;
    for(long long i=1;i<=koma;i++)
    {
        res+=(usea[i]==1);
    }

    for(long long i=(koma+1);i<=(koma+komb);i++)
    {
        res+=(usea[i]==0);
    }

    cout<<res<<"\n";
    return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:140:49: error: no matching function for call to 'max(int, long long int)'
  140 |                     for(long long cory=max(1,j-2);cory<=j;cory++)
      |                                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dango_maker.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:
dango_maker.cpp:140:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  140 |                     for(long long cory=max(1,j-2);cory<=j;cory++)
      |                                                 ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from dango_maker.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:
dango_maker.cpp:140:49: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  140 |                     for(long long cory=max(1,j-2);cory<=j;cory++)
      |                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dango_maker.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:
dango_maker.cpp:140:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  140 |                     for(long long cory=max(1,j-2);cory<=j;cory++)
      |                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dango_maker.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:
dango_maker.cpp:140:49: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  140 |                     for(long long cory=max(1,j-2);cory<=j;cory++)
      |                                                 ^