답안 #259789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259789 2020-08-08T14:41:05 Z minhcool Cultivation (JOI17_cultivation) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
#define int short int
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
int n, r, c, s[305], e[305], pref[45][45], ans = 10005;
 
bool ck(int up, int left, int down, int right){
	for(int i = 1; i <= r; ++i){
		for(int j = 1; j <= c; ++j) pref[i][j] = 0;
	}
	for(int i = 1; i <= n; ++i){
		pref[max(1, s[i] - up)][max(1, e[i] - left)]++;
		pref[min(r, s[i] + down) + 1][max(1, e[i] - left)]--;
		pref[max(1, s[i] - up)][min(c, e[i] + right) + 1]--;
		pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
		//cout << max(1, s[i] - up) << " " << max(1, e[i] - left) << " " << min(r + 1, s[i] + down + 1) << " " << min(c + 1, e[i] + right) << "\n";
	}
	for(int i = 1; i <= r; ++i){
		for(int j = 1; j <= c; ++j) pref[i][j] += pref[i][j - 1];
	}
	for(int i = 1; i <= r; ++i){
		for(int j = 1; j <= c; ++j){
			pref[i][j] += pref[i - 1][j];
			if(!pref[i][j]) return 0;
		}
	}
	return 1;
}
 
void mini(int &a, int b){
	a = ((a < b) ? a : b);
}
 
signed main(){
	//freopen("cultivation.inp", "r", stdin);
	//freopen("cultivation.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin >> r >> c >> n;
	for(int i = 1; i <= n; i++) cin >> s[i] >> e[i];
	//cout << ck(0, 1, 2, 2) << "\n";
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			int itr = c - 1, temp = i + j - 1;
			for(int k = 0; k <= r - 1; k++){
				while(itr >= 0 && ck(i, j, k, itr)) --itr;
				++itr;
				++temp;
				//cout << i << " " << j << " " << k << " " << itr << " " << temp + itr << "\n";
				if(ck(i, j, k, itr)) mini(ans, temp + itr);
			}
		}
	}
	cout << ans;
}
 

Compilation message

cultivation.cpp: In function 'bool ck(short int, short int, short int, short int)':
cultivation.cpp:23:26: error: no matching function for call to 'min(short int&, int)'
   pref[min(r, s[i] + down) + 1][max(1, e[i] - left)]--;
                          ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
cultivation.cpp:23:26: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[min(r, s[i] + down) + 1][max(1, e[i] - left)]--;
                          ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
cultivation.cpp:23:26: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[min(r, s[i] + down) + 1][max(1, e[i] - left)]--;
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
cultivation.cpp:23:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[min(r, s[i] + down) + 1][max(1, e[i] - left)]--;
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
cultivation.cpp:23:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[min(r, s[i] + down) + 1][max(1, e[i] - left)]--;
                          ^
cultivation.cpp:24:46: error: no matching function for call to 'min(short int&, int)'
   pref[max(1, s[i] - up)][min(c, e[i] + right) + 1]--;
                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
cultivation.cpp:24:46: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[max(1, s[i] - up)][min(c, e[i] + right) + 1]--;
                                              ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
cultivation.cpp:24:46: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[max(1, s[i] - up)][min(c, e[i] + right) + 1]--;
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
cultivation.cpp:24:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[max(1, s[i] - up)][min(c, e[i] + right) + 1]--;
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
cultivation.cpp:24:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[max(1, s[i] - up)][min(c, e[i] + right) + 1]--;
                                              ^
cultivation.cpp:25:26: error: no matching function for call to 'min(short int&, int)'
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                          ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:26: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                          ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:26: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                          ^
cultivation.cpp:25:52: error: no matching function for call to 'min(short int&, int)'
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                                                    ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:52: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                                                    ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:52: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
cultivation.cpp:25:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   pref[min(r, s[i] + down) + 1][min(c, e[i] + right) + 1]++;
                                                    ^