Submission #683150

#TimeUsernameProblemLanguageResultExecution timeMemory
683150JuanDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ff first
#define ss second

vector<int> ans;
vector<pii> arr;

bool dp(int id, int sum){
	if(sum>u) return false;
	if(sum>=l && sum<=u) return true;
	for(int i = id; i < arr.size(); i++){
		if(dp(i+1, sum+arr[i].ff)){
			ans.push_back(arr[i].ss);
			return true;
		}
	}
	return false;
}

int[] find_subset(int l, int u, int[] w){
	for(int i = 0; i < sizeof w; i++) arr.push_back({w[i], i});
	sort(arr.begin(), arr.end(), greater<pii>());
	dp(0, 0);
	return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'bool dp(int, int)':
molecules.cpp:11:9: error: 'u' was not declared in this scope
   11 |  if(sum>u) return false;
      |         ^
molecules.cpp:12:10: error: 'l' was not declared in this scope
   12 |  if(sum>=l && sum<=u) return true;
      |          ^
molecules.cpp:12:20: error: 'u' was not declared in this scope
   12 |  if(sum>=l && sum<=u) return true;
      |                    ^
molecules.cpp:13:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i = id; i < arr.size(); i++){
      |                  ~~^~~~~~~~~~~~
molecules.cpp: At global scope:
molecules.cpp:22:4: error: structured binding declaration cannot have type 'int'
   22 | int[] find_subset(int l, int u, int[] w){
      |    ^~
molecules.cpp:22:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:22:4: error: empty structured binding declaration
molecules.cpp:22:7: error: expected initializer before 'find_subset'
   22 | int[] find_subset(int l, int u, int[] w){
      |       ^~~~~~~~~~~