Submission #1097724

# Submission time Handle Problem Language Result Execution time Memory
1097724 2024-10-08T04:31:12 Z Newtonabc Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
bool dp[N];
int bk[N];
int n;
vector<int> find_subset(int l, int u, vector<int> w) {
	n=w.size();
	vector<int> ans;
	dp[0]=true;
	for(int i=0;i<n;i++){
		for(int j=u;j>=0;j--){
			if(j-w[i]>=0){
				if(!dp[j] && dp[j-w[i]]){
					dp[j]|=dp[j-w[i]];
					bk[j]=i;
				}
			}
		}
	}
	for(int i=l;i<=u;i++){
			int tmp=i;
			//cout<<i <<"\n\n\n\n";
			while(1){
				if(tmp==0) break;
				ans.push_back(bk[tmp]);
				tmp-=w[bk[tmp]];
			}
			break;
		}
	}
	/*for(int i=0;i<ans.size();i++) cout<<ans[i] <<" ";
	cout<<"\n\n\n";*/
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:32:2: warning: no return statement in function returning non-void [-Wreturn-type]
   32 |  }
      |  ^
molecules.cpp: At global scope:
molecules.cpp:35:5: error: expected unqualified-id before 'return'
   35 |     return ans;
      |     ^~~~~~
molecules.cpp:36:1: error: expected declaration before '}' token
   36 | }
      | ^