제출 #706763

#제출 시각아이디문제언어결과실행 시간메모리
706763Yell0Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef long long ll; int find_subset(int l,int u,vector<int> w,int n,&vector<int> result) { vector<pii> a; for(int i=0;i<n;++i) a.push_back({w[i],i}); sort(a.begin(),a.end()); int i=0,j=0; ll sum=0; for(;i<n;++i) { sum+=a[i].first; if(sum>=l) break; } if(sum<l) return 0; for(;j<=i;++j) { sum-=a[j].first; if(sum<=u) break; } if(sum>u) return 0; for(int x=0;x<=i-j;++x) result[x]=a[x+j].second; return 0; }

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

molecules.cpp:7:49: error: expected identifier before '&' token
    7 | int find_subset(int l,int u,vector<int> w,int n,&vector<int> result) {
      |                                                 ^
molecules.cpp:7:50: error: expected ',' or '...'
    7 | int find_subset(int l,int u,vector<int> w,int n,&vector<int> result) {
      |                                                  ^~~~~~~~~~~
molecules.cpp: In function 'int find_subset(int, int, std::vector<int>, int, int&)':
molecules.cpp:23:27: error: 'result' was not declared in this scope
   23 |   for(int x=0;x<=i-j;++x) result[x]=a[x+j].second;
      |                           ^~~~~~