제출 #788386

#제출 시각아이디문제언어결과실행 시간메모리
788386BulaDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() //#define int ll const ll mod=1e9+7; vector<int> find_subset(int l,int u,vector<int> w){ int n=(int)w.size(); vector<int> v(n+1); for(int i=1;i<=n;i++) v[i]=w[i-1]; int dp[n+1][u+1]; for(int i=0;i<=n;i++){ for(int j=1;j<=u;j++){ dp[i][j]=0; } } vector<int> ans; for(int i=1;i<=n;i++){ dp[i][v[i]]=2; for(int j=u;j>=1;j--){ if(dp[i-1][j]>0 && dp[i][j]==0) dp[i][j]=1 if(j>v[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i]]); } } int sum=0; for(int i=l;i<=u;i++){ if(dp[n][i]>0){ sum=i; break; } } int i=n; while(sum!=0){ if(dp[i][sum]==2){ sum-=v[i]; ans.pb(i-1); i--; }else{ i--; } } return ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:27:46: error: expected ';' before 'if'
   27 |    if(dp[i-1][j]>0 && dp[i][j]==0) dp[i][j]=1
      |                                              ^
      |                                              ;
   28 |    if(j>v[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i]]);
      |    ~~