답안 #344921

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344921 2021-01-06T18:25:57 Z _ani Bootfall (IZhO17_bootfall) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
using namespace std;
const int N = 100;
int dp[N + 1][N + 1][N * N + 1];
vector<int> a;
int b[N];
vector<int> ans;
int sum;
int main()
{
	int n;
	cin >> n;
	a.resize(n);
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] = b[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++)
	{
		int jnj = b[i];
		a.erase(find(a.begin(), a.end(), jnj));
		for (int i = 0; i < n; i++)
			dp[jnj][i][a[i]] = dp[jnj][i][0] = 1;
		for (int i = 0; i < n - 1; i++)
			for (int j = 1; j <= N * N; j++)
				if (j >= a[i] && i >= 1)
					dp[jnj][i][j] = dp[jnj][i - 1][j - a[i]];
		a.push_back(jnj);
	}
	for (int i = 1; i <= N*N; i++)
	{
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if ((sum - b[j] + i) % 2 == 0) {
				int tmp = (sum - b[j] + i) / 2;
				for (int k = 0; k < n; k++)
					if (dp[a[j]][k][tmp]) {
						cnt++;
						break;
					}
			}
		}
		if (cnt == n)ans.push_back(i);
	}
	cout << ans.size() << '\n';
	for (int v : ans)
		cout << v << ' ';
	return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:25:39: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   25 |   a.erase(find(a.begin(), a.end(), jnj));
      |                                       ^
In file included from /usr/include/c++/9/bits/locale_facets.h:48,
                 from /usr/include/c++/9/bits/basic_ios.h:37,
                 from /usr/include/c++/9/ios:44,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from bootfall.cpp:1:
/usr/include/c++/9/bits/streambuf_iterator.h:373:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&)'
  373 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/9/bits/streambuf_iterator.h:373:5: note:   template argument deduction/substitution failed:
bootfall.cpp:25:39: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   25 |   a.erase(find(a.begin(), a.end(), jnj));
      |                                       ^