제출 #465193

#제출 시각아이디문제언어결과실행 시간메모리
465193dattranxxxDetecting Molecules (IOI16_molecules)C++11
컴파일 에러
0 ms0 KiB
/*
 * Author :  shora
 */
#include <bits/stdc++.h>
#define print(_v) for (auto &_ : _v) {cerr << _ << ' ';} cerr << endl;
#include "molecules.h"
using namespace std;
using ll = long long;
const int oo = 1e9;
const int N = 2e5;
map<int, ll> dp[N];
map<int, bool> t[N];
int n;
ll call(int i, int l, vector<int>& a) {
	if (i == -1) 
		return l <= 0 ? 0 : oo;
	if (dp[i].count(l))
		return dp[i][l];
	ll x = call(i-1, l-a[i], a) + a[i], y = call(i-1, l, a);
	if (x < y) {
		t[i][l] = 1;
		return dp[i][l] = x; 
	} else {
		t[i][l] = 0;
		return dp[i][l] = y;
	}
}
vector<int> find_subset(int l, int u, std::vector<int>& a) {
	n = w.size();
  call(n-1, l, w);
  vector<int> res;
  if (dp[n-1][l] <= u) {
  	n = n-1;
  	while (n) {
  		if (t[n][l]) {
  			res.push_back(n+1);
  			l -= a[n];
			}
			n--;
		}
	} 
  return res;
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>&)':
molecules.cpp:29:6: error: 'w' was not declared in this scope
   29 |  n = w.size();
      |      ^