답안 #1097722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097722 2024-10-08T04:29:03 Z Newtonabc Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+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++){
		if(dp[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]a];
			}
			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:29:19: error: expected ']' before 'a'
   29 |     tmp-=w[bk[tmp]a];
      |                   ^
      |                   ]
molecules.cpp:29:19: error: expected ';' before 'a'
   29 |     tmp-=w[bk[tmp]a];
      |                   ^
      |                   ;