제출 #725434

#제출 시각아이디문제언어결과실행 시간메모리
725434AndrijaMDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int>arr; int n; int mx=0; int dp[105][1005]; int f(int idx,int x,&vector<int>vec,vector<int>kolku) { if(idx==n) { arr=vec; return 0; } if(dp[idx][x]!=-1)return dp[idx][x]; int rez=0; rez=max(rez, f(idx+1,x,vec,kolku)); if(x+kolku[idx]<=mx) { vector<int>pom; pom=vec; pom.push_back(idx); rez=max(rez, f(idx+1,x+kolku[idx],pom,kolku)+kolku[idx]); } return dp[idx][x]=rez; } vector<int> find_subset(int l, int u, vector<int> w) { memset(dp,-1,sizeof dp); vector<int>v; mx=u; n=(int)w.size(); int kol=0; kol+=f(0,0,v,w); int sum=0; for(int i=0;i<n;i++) { sum+=w[i]; } if(sum<l) { return {}; } if(kol<l) { return { }; } else return arr; }

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

molecules.cpp:10:21: error: expected identifier before '&' token
   10 | int f(int idx,int x,&vector<int>vec,vector<int>kolku)
      |                     ^
molecules.cpp:10:22: error: expected ',' or '...'
   10 | int f(int idx,int x,&vector<int>vec,vector<int>kolku)
      |                      ^~~~~~~~~~~
molecules.cpp: In function 'int f(int, int, int&)':
molecules.cpp:14:13: error: 'vec' was not declared in this scope
   14 |         arr=vec;
      |             ^~~
molecules.cpp:19:28: error: 'vec' was not declared in this scope
   19 |     rez=max(rez, f(idx+1,x,vec,kolku));
      |                            ^~~
molecules.cpp:19:32: error: 'kolku' was not declared in this scope
   19 |     rez=max(rez, f(idx+1,x,vec,kolku));
      |                                ^~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:37:16: error: invalid initialization of reference of type 'int&' from expression of type 'std::vector<int>'
   37 |     kol+=f(0,0,v,w);
      |                ^
molecules.cpp:10:21: note: in passing argument 3 of 'int f(int, int, int&)'
   10 | int f(int idx,int x,&vector<int>vec,vector<int>kolku)
      |                     ^~~~~~~~~~~~