답안 #734090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734090 2023-05-01T16:28:05 Z Amaarsaa 팬케이크 정렬 (NOI12_pancake) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
ll n, ans, p, j, s;
void Dfs(ll a[], ll  moves) {
	if ( moves < ans) return;
	if ( moves == 0) return ;
	s = n;
	
	for (ll i = 1; i <= n; i ++) {
		if ( a[i] == (n - i + 1)) s --;
	}
	if ( s == 0) {
		ans =max (ans, moves);
		return;
	}
	for (ll i = 1; i <= n; i ++) {
		reverse(a + i,a +n + 1);
		Dfs(a, moves - 1);
		reverse(a + i, a + n + 1);
	}
	return ;
}
int main() {
	ll i, t, r;
	cin >> t;
	
	while ( t --) {
		cin >> n;
		ans = -1e9;
		ll a[n + 2];
		vector < pair < ll, ll > > v;
		for (i = 1; i <= n; i ++) {
			cin >> a[i];
			v.push_back(make_pair(a[i], i));
		}
		sort (v.begin(), v.end());
		for ( i = 0; i < n; i ++) {
			a[v[i].second ] = i + 1;
		}
		Dfs(a, min(2*n, 10));
		cout << 2 * n - ans << endl;
	}
}

Compilation message

pancake.cpp: In function 'int main()':
pancake.cpp:42:21: error: no matching function for call to 'min(ll, int)'
   42 |   Dfs(a, min(2*n, 10));
      |                     ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from pancake.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:
pancake.cpp:42:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |   Dfs(a, min(2*n, 10));
      |                     ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from pancake.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:
pancake.cpp:42:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |   Dfs(a, min(2*n, 10));
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from pancake.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:
pancake.cpp:42:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |   Dfs(a, min(2*n, 10));
      |                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from pancake.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:
pancake.cpp:42:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |   Dfs(a, min(2*n, 10));
      |                     ^
pancake.cpp:26:11: warning: unused variable 'r' [-Wunused-variable]
   26 |  ll i, t, r;
      |           ^