답안 #117109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
117109 2019-06-14T21:17:59 Z Lawliet Detecting Molecules (IOI16_molecules) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "molecules.h"

#define MAX 10010

using namespace std;

int N, L, U;

int indAnt[MAX];
int valueAnt[MAX];

bool dp[MAX];

vector<int> ans;

void add(int w, int i)
{
	for(int g = U ; g >= w ; g--)
	{
		if(dp[g - w] && !dp[g])
		{
			dp[g] = true;

			indAnt[g] = i;
			valueAnt[g] = w;
		}
	}
}

int[] find_subset(int l, int u, int[] w)
{
	L = l; U = u;

	dp[0] = true;
	ans.clear();
	memset(dp , false , sizeof(dp));
	memset(indAnt , -1 , sizeof(indAnt));
	memset(valueAnt , -1 , sizeof(valueAnt));

	int ind = 0;

	while( w[ind] != 0 )
	{
		add( w[ind] , ind);
		ind++;
	}

	int can = -1;

	for(int g = L ; g <= U ; g++)
		if(dp[g]) can = g;

	if(can == -1)
	{
		int resp[0];
		//return resp;
		//printf("N\n");
		return resp;
	}

	while( indAnt[can] != -1 )
	{
		ans.push_back( indAnt[can] );

		can -= valueAnt[can];
	}

	int resp[ans.size()];

	for(int g = 0 ; g < ans.size() ; g++)
		resp[g] = ans[g];

	return resp;
}

/*int main()
{
	scanf("%d %d %d",&N,&L,&U);

	int W[N];

	for(int g = 0 ; g < N ; g++)
		scanf("%d",&W[g]);

	find_subset(L , U , W);
}*/

Compilation message

molecules.cpp:31:4: error: decomposition declaration cannot be declared with type 'int'
 int[] find_subset(int l, int u, int[] w)
    ^~
molecules.cpp:31:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:31:4: error: empty decomposition declaration
molecules.cpp:31:7: error: expected initializer before 'find_subset'
 int[] find_subset(int l, int u, int[] w)
       ^~~~~~~~~~~