Submission #991539

# Submission time Handle Problem Language Result Execution time Memory
991539 2024-06-02T11:52:45 Z MarwenElarbi Rectangles (IOI19_rect) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include <cstdio>
#include <unistd.h>
#include <cassert>
#include <string>
using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back
const int nax=2505;
vector<vector<int>> grid;
int arx[4]={1,-1,0,0};
int ary[4]={0,0,-1,1};
ll mxx,mxy,mnx,mny;
bool vis[2505][2505];
int N,M;
bool test(int x,int y){
    if(x<=0||y<=0||x>=N||y>=M||grid[x][y]==1||vis[x][y]) return true;
    else return false;
}
void dfs(int x,int y){
    //cout <<x<<" "<<y<<endl;
    vis[x][y]=true;
    mxx=max(mxx,x);
    mxy=max(mxy,y);
    mnx=min(mnx,x);
    mny=min(mny,y);
    for (int i = 0; i < 4; ++i)
    {
        int curx=arx[i];
        int cury=ary[i];
        if(!test(curx+x,cury+y)){
            dfs(curx+x,cury+y);
        }
    }
}
long long count_rectangles(std::vector<std::vector<int> > a) {
    grid=a;
    int n=a.size();
    int m=a[0].size();
    N=n;
    M=m;
    if(n<=2||m<=2) return 0;
    ll ans=0;
    for (int i = 1; i < n-1; ++i)
    {
        for (int j = 1; j < m-1; ++j)
        {
            if(vis[i][j]) continue;
            else if(grid[i][j]==1) continue;
            //cout <<i<<" "<<j<<" "<<endl;
            vis[i][j]=true;
            mxx=mxy=0;
            mnx=mny=max(n,m);
            dfs(i,j);
            bool nabba=true;
            for (int x = mnx; x <= mxx; ++x)
            {
                for (int y = mny; y <= mxy; ++y)
                {
                    if(grid[x][y]==1) nabba=false;
                    if(!nabba) break;
                }
                if(!nabba) break;
            }
            if(!nabba) continue;
            ans+=1ll*(1ll*(mxx-mnx+1)*(mxx-mnx+2)/2)*(1ll*(mxy-mny+1)*(mxy-mny+2)/2); 
            cout <<mnx<<" "<<mxx<<" "<<mny<<" "<<mxy<<endl;
        }
    }
    return ans;
}

Compilation message

rect.cpp: In function 'void dfs(int, int)':
rect.cpp:25:18: error: no matching function for call to 'max(long long int&, int&)'
   25 |     mxx=max(mxx,x);
      |                  ^
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 rect.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:
rect.cpp:25:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |     mxx=max(mxx,x);
      |                  ^
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 rect.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:
rect.cpp:25:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   25 |     mxx=max(mxx,x);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.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:
rect.cpp:25:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |     mxx=max(mxx,x);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.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:
rect.cpp:25:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   25 |     mxx=max(mxx,x);
      |                  ^
rect.cpp:26:18: error: no matching function for call to 'max(long long int&, int&)'
   26 |     mxy=max(mxy,y);
      |                  ^
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 rect.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:
rect.cpp:26:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |     mxy=max(mxy,y);
      |                  ^
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 rect.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:
rect.cpp:26:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |     mxy=max(mxy,y);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.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:
rect.cpp:26:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |     mxy=max(mxy,y);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.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:
rect.cpp:26:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |     mxy=max(mxy,y);
      |                  ^
rect.cpp:27:18: error: no matching function for call to 'min(long long int&, int&)'
   27 |     mnx=min(mnx,x);
      |                  ^
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 rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
rect.cpp:27:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   27 |     mnx=min(mnx,x);
      |                  ^
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 rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
rect.cpp:27:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   27 |     mnx=min(mnx,x);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
rect.cpp:27:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |     mnx=min(mnx,x);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
rect.cpp:27:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |     mnx=min(mnx,x);
      |                  ^
rect.cpp:28:18: error: no matching function for call to 'min(long long int&, int&)'
   28 |     mny=min(mny,y);
      |                  ^
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 rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
rect.cpp:28:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |     mny=min(mny,y);
      |                  ^
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 rect.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
rect.cpp:28:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |     mny=min(mny,y);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
rect.cpp:28:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |     mny=min(mny,y);
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from rect.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
rect.cpp:28:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |     mny=min(mny,y);
      |                  ^