제출 #496972

#제출 시각아이디문제언어결과실행 시간메모리
496972vinnipuh01Maxcomp (info1cup18_maxcomp)C++17
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long

using namespace std;

const long long oo = 1000000000000000000;

long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen ( "sum.in", "r", stdin )
*/

set<int> dp[ 1001 ][ 1001 ][ 2 ], st;
int a[ 1001 ][ 1001 ];


main () {
	int n, m;
	cin >> n >> m;
	for ( int i = 0; i < n; i ++ ) {
		for ( int j = 0; j < m; j ++ ) {
			cin >> a[ i ][ j ];
		}
	}
	pos = -1;
	if ( n * m <= 20 ) {
		ans = 1;
		for ( int mask = 0; mask < ( 1 << ( n * m ) ); mask ++ ) {
			for ( int i = 0; i < n; i ++ ) {
				for ( int j = 0; j < m; j ++ ) {
					num = ( i ) * m + j;
					if ( mask & ( 1 << num ) ) {
						ans = 0;
						if ( i ) {
							if ( mask & ( 1 << ( num - m ) ) )
								ans = 1;
						}
						if ( j )
							if ( mask & ( 1 << ( num - 1 ) ) )
								ans = 1;
						if ( i < n - 1 )
							if ( mask & ( 1 << ( num + m ) ) )
								ans = 1;
						if ( j < m - 1 ) {
							if ( mask & ( 1 << ( num + 1 ) ) )
								ans = 1;
						}
					}
					if ( !ans )
						break;
				}
				if ( !ans )
					break;
			}
			if ( !ans )
				continue;
			for ( int i = 0; i < n; i ++ ) {
				for ( int j = 0; j < m; j ++ ) {
					num = i * m + j;
					if ( mask & ( 1 << num ) ) {
						mx = max( mx, a[ i ][ j ] );
						mn = min( mn, a[ i ][ j ] );
						st.insert( a[ i ][ j ] );
					}
				}
			}
			pos = max( pos, mx - mn - st.size() );
			mx = 0;
			sum = 0;
			mn = oo;
		}
		cout << pos;
	}
	else {
		
	}
}


/*
4
3 3 4

4 ^ 6 ^ 8 ^ 5 ^ 6 ^ 7 = 14

2 3
2 4 3
5 7 5

*/

컴파일 시 표준 에러 (stderr) 메시지

maxcomp.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main () {
      | ^~~~
maxcomp.cpp: In function 'int main()':
maxcomp.cpp:100:40: error: no matching function for call to 'max(long long int&, long long unsigned int)'
  100 |    pos = max( pos, mx - mn - st.size() );
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from maxcomp.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:
maxcomp.cpp:100:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
  100 |    pos = max( pos, mx - mn - st.size() );
      |                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from maxcomp.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:
maxcomp.cpp:100:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
  100 |    pos = max( pos, mx - mn - st.size() );
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from maxcomp.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:
maxcomp.cpp:100:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  100 |    pos = max( pos, mx - mn - st.size() );
      |                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from maxcomp.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:
maxcomp.cpp:100:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  100 |    pos = max( pos, mx - mn - st.size() );
      |                                        ^