답안 #112310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112310 2019-05-18T17:27:20 Z ioilolcom Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	sort(v.begin(),v.end());
	int a=0;
	int r=0;
	int n=(int)w.size();
	ll sum=0;
	while(r<n&&a<n) {
		sum+=w[r];
		while(sum>u) {
			sum-=w[a]
			      a++;
		}
		if(sum>=l&&sum<=u) {
			for(int i=a; i<=r; i++) {
				ans.push_back(w[i]);
			}
		}
		r++;
	}
	if(ans.size()) return ans;
	return std::vector<int>(0);
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:7: error: 'v' was not declared in this scope
  sort(v.begin(),v.end());
       ^
molecules.cpp:16:10: error: expected ';' before 'a'
          a++;
          ^
molecules.cpp:20:5: error: 'ans' was not declared in this scope
     ans.push_back(w[i]);
     ^~~
molecules.cpp:20:5: note: suggested alternative: 'abs'
     ans.push_back(w[i]);
     ^~~
     abs
molecules.cpp:25:5: error: 'ans' was not declared in this scope
  if(ans.size()) return ans;
     ^~~
molecules.cpp:25:5: note: suggested alternative: 'abs'
  if(ans.size()) return ans;
     ^~~
     abs