Submission #986983

# Submission time Handle Problem Language Result Execution time Memory
986983 2024-05-21T16:39:18 Z PagodePaiva Rectangles (IOI19_rect) C++17
Compilation error
0 ms 0 KB
#include "rect.h"
#include<bits/stdc++.h>

using namespace std;

const int N = 2510;

int n, m;
int v[N][N];
// int linha[N][N][N], coluna[N][N][N]; 
int mark[N][N];
long long lmax[N], lmin[N], rmax[N], rmin[N], qtd[N];

void dfs(int i, int j, int con){
	mark[i][j] = con;
	// cout << i << ' ' << j << ' ' << con << '\n';
	qtd[con]++;
	lmax[con] = max(lmax[con], i);
	lmin[con] = min(lmin[con], i);
	rmax[con] = max(rmax[con], j);
	rmin[con] = min(rmin[con], j);
	if(i > 1 and v[i-1][j] == 0 and mark[i-1][j] == 0) dfs(i-1, j, con);
	if(i < n and v[i+1][j] == 0 and mark[i+1][j] == 0) dfs(i+1, j, con);
	if(j > 1 and v[i][j-1] == 0 and mark[i][j-1] == 0) dfs(i, j-1, con);
	if(j < m and v[i][j+1] == 0 and mark[i][j+1] == 0) dfs(i, j+1, con);
	return;
}

int markcon[N];

long long count_rectangles(std::vector<std::vector<int> > a) {
	n = a.size();
	m = a[0].size();
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			v[i+1][j+1] = a[i][j];
		}
	}
	int con = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(mark[i][j] == 0 and v[i][j] == 0) {
				lmax[con] = i; lmin[con] = i;
				rmax[con] = j; rmin[con] = j;
				dfs(i, j, con);
				con++;
			}
		}
	}
	long long res = 0;
	for(int i = 2;i < n;i++){
		for(int j = 2;j < m;j++){
			if(v[i][j] == 1) continue;
			if(markcon[mark[i][j]] == 0){
				markcon[mark[i][j]] = 1;
				con = mark[i][j];
				// cout << mark[i][j] << ' '; 
				// cout << lmax[con] << ' ' << lmin[con] << ' ' << rmax[con] << ' ' << rmin[con] << ' ' << qtd[con] << '\n';
				if(qtd[con] == (lmax[con]-lmin[con]+1)*(rmax[con]-rmin[con]+1) and lmax[con] < n and lmin[con] > 0 and rmax[con] < m and rmin[con] > 0) res++;
			}
		}
	}
	return res;
	// for(int l = 1;l <= n;l++){
	// 	for(int i = 1;i <= m;i++){
	// 		linha[l][i][i] = v[l][i];
	// 		for(int j = i+1;j <= m;j++){
	// 			linha[l][i][j] = max(linha[l][i][j-1], v[l][j]);
	// 		}
	// 	}
	// }
	// for(int c = 1;c <= m;c++){
	// 	for(int i = 1;i <= n;i++){
	// 		coluna[c][i][i] = v[i][c];
	// 		for(int j = i+1;j <= m;j++){
	// 			coluna[c][i][j] = max(coluna[c][i][j-1], v[j][c]);
	// 		}
	// 	}
	// }
	// int res = 0;
	// for(int l1 = 2;l2 < n;l2++){
	// 	for(int r1 = 2;r1 < n;r1++){

	// 	}
	// }	
}

Compilation message

rect.cpp: In function 'void dfs(int, int, int)':
rect.cpp:18:30: error: no matching function for call to 'max(long long int&, int&)'
   18 |  lmax[con] = max(lmax[con], i);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:18:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |  lmax[con] = max(lmax[con], i);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:18:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |  lmax[con] = max(lmax[con], i);
      |                              ^
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:2:
/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:18:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |  lmax[con] = max(lmax[con], i);
      |                              ^
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:2:
/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:18:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |  lmax[con] = max(lmax[con], i);
      |                              ^
rect.cpp:19:30: error: no matching function for call to 'min(long long int&, int&)'
   19 |  lmin[con] = min(lmin[con], i);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:19:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   19 |  lmin[con] = min(lmin[con], i);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:19:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   19 |  lmin[con] = min(lmin[con], i);
      |                              ^
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:2:
/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:19:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |  lmin[con] = min(lmin[con], i);
      |                              ^
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:2:
/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:19:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |  lmin[con] = min(lmin[con], i);
      |                              ^
rect.cpp:20:30: error: no matching function for call to 'max(long long int&, int&)'
   20 |  rmax[con] = max(rmax[con], j);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:20:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |  rmax[con] = max(rmax[con], j);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:20:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |  rmax[con] = max(rmax[con], j);
      |                              ^
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:2:
/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:20:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |  rmax[con] = max(rmax[con], j);
      |                              ^
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:2:
/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:20:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |  rmax[con] = max(rmax[con], j);
      |                              ^
rect.cpp:21:30: error: no matching function for call to 'min(long long int&, int&)'
   21 |  rmin[con] = min(rmin[con], j);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:21:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |  rmin[con] = min(rmin[con], j);
      |                              ^
In file included from /usr/include/c++/10/vector:60,
                 from rect.h:5,
                 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:21:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |  rmin[con] = min(rmin[con], j);
      |                              ^
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:2:
/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:21:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |  rmin[con] = min(rmin[con], j);
      |                              ^
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:2:
/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:21:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |  rmin[con] = min(rmin[con], j);
      |                              ^