답안 #715998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715998 2023-03-28T18:22:08 Z vinnipuh01 The Kingdom of JOIOI (JOI17_joioi) C++17
컴파일 오류
0 ms 0 KB
#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 sqrt sqrtl

using namespace std;

const long long oo = 2e9;

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


/*
    ViHHiPuh

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


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


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

int a[ 4 ][ 2001 ][ 2001 ], n, m;
int b[ 2001 ][ 2001 ];

bool ok( int x ) {
	for ( int t = 0; t < 4; t ++ ) {
		if ( t & 1 ) {
			mx = n;
			for ( int i = 1; i <= m; i ++ ) {
				for ( int j = 1; j <= n; j ++ )
					b[ i ][ j ] = 0;
			}
			for ( int i = 1; i <= m; i ++ ) {
				for ( int j = 1; j <= mx; j ++ ) {
					if ( a[ t ][ i ][ j ] > x ) {
						mx = j - 1;
						break;
					}
					b[ i ][ j ] = 1;
				}
			}
			int mnn = oo;
			int mxx = 0;
			for ( int i = 1; i <= m; i ++ ) {
				for ( int j = 1; j <= n; j ++ ) {
					if ( !b[ i ][ j ] ) {
						mxx = max( mxx, a[ t ][ i ][ j ] ) ;
						mnn = min( mnn, a[ t ][ i ][ j ] );
					}
				}
			}
			if ( mxx - mnn <= x )
				return true;	
		}
		else {
			mx = m;
			for ( int i = 1; i <= n; i ++ ) {
				for ( int j = 1; j <= m; j ++ )
					b[ i ][ j ] = 0;
			}
			for ( int i = 1; i <= n; i ++ ) {
				for ( int j = 1; j <= mx; j ++ ) {
					if ( a[ t ][ i ][ j ] > x ) {
						mx = j - 1;
						break;
					}
					b[ i ][ j ] = 1;
				}
			}
			int mnn = oo;
			int mxx = 0;
			for ( int i = 1; i <= n; i ++ ) {
				for ( int j = 1; j <= m; j ++ ) {
					if ( !b[ i ][ j ] ) {
						mxx = max( mxx, a[ t ][ i ][ j ] ) ;
						mnn = min( mnn, a[ t ][ i ][ j ] );
					}
				}
			}
			if ( mxx - mnn <= x )
				return true;
		}
	}
	return false;
}

main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	cin >> n >> m;
	mn = oo;
	for ( int i = 1; i <= n; i ++ ) {
		for ( int j = 1; j <= m; j ++ ) {
			cin >> a[ 0 ][ i ][ j ];
			mn = min( mn, a[ 0 ][ i ][ j ] );
		}
	}
	for ( int i = 1; i <= n; i ++ ) {
		for ( int j = 1; j <= m; j ++ )
			a[ 0 ][ i ][ j ] -= mn;
	}
	int x, y;
	x = y = 1;
	for ( int j = m; j >= 1; j -- ) {
		y = 1;
		for ( int i = 1; i <= n; i ++ ) {
			a[ 1 ][ x ][ y ] = a[ 0 ][ i ][ j ];
			y ++;
		}
		x ++;
	}
	x = 1;
	for ( int i = n; i >= 1; i -- ) {
		y = 1;
		for ( int j = m; j >= 1; j -- )
			a[ 2 ][ x ][ y ] = a[ 0 ][ i ][ j ], y ++;
		x ++;
	}
	x = 1;
	for ( int j = 1; j <= m; j ++ ) {
		y = 1;
		for ( int i = n; i >= 1; i -- )
			a[ 3 ][ x ][ y ] = a[ 0 ][ i ][ j ], y ++;
		x ++;
	}
//	for ( int t = 0; t < 4; t ++ ) {
//		cout << "----------\n";
//		for ( int i = 1; i <= n; i ++ ) {
//			for ( int j = 1; j <= m; j ++ )
//				cout << a[ t ][ i ][ j ] << " ";
//			cout << "\n";
//		}
//		cout << "----------\n";
//	}
	int l, r, mid;
	l = 0;
	r = 1e9;
	while ( r > l ) {
		mid = ( l + r ) / 2;
		if ( ok( mid ) )
			r = mid;
		else
			l = mid + 1;
	}
	cout << l;
}

Compilation message

joioi.cpp:109:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  109 | main () {
      | ^~~~
joioi.cpp: In function 'int main()':
joioi.cpp:117:35: error: no matching function for call to 'min(long long int&, int&)'
  117 |    mn = min( mn, a[ 0 ][ i ][ j ] );
      |                                   ^
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 joioi.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:
joioi.cpp:117:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  117 |    mn = min( mn, a[ 0 ][ i ][ j ] );
      |                                   ^
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 joioi.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:
joioi.cpp:117:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  117 |    mn = min( mn, a[ 0 ][ i ][ 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 joioi.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:
joioi.cpp:117:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  117 |    mn = min( mn, a[ 0 ][ i ][ 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 joioi.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:
joioi.cpp:117:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  117 |    mn = min( mn, a[ 0 ][ i ][ j ] );
      |                                   ^