제출 #683965

#제출 시각아이디문제언어결과실행 시간메모리
683965JuanDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;


vector<int> find_subset(int L, int R, vector<int> w){
	int pref = 0, suff = 0, n = w.size();
	int r;
	vector<int> ans;
	for(int i = 0; i < n; i++){
		pref+=w[i], suff+=w[n-1-i];
		if(pref<=R && suff>=L){
			found = true, r = R;
			break;
		}
	}
	if(!found) return ans;

	int l=0, sum=pref;
	while(true){
		if(sum>=L && sum<=R){
			for(int i = l; i <= r; i++) ans.push_back(i);
			break;
		}
		sum += w[++r] - w[l++];
	}
	return ans;
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:4: error: 'found' was not declared in this scope; did you mean 'round'?
   12 |    found = true, r = R;
      |    ^~~~~
      |    round
molecules.cpp:16:6: error: 'found' was not declared in this scope; did you mean 'round'?
   16 |  if(!found) return ans;
      |      ^~~~~
      |      round