답안 #218931

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218931 2020-04-03T08:18:22 Z yayups Detecting Molecules (IOI16_molecules) C++11
컴파일 오류
0 ms 0 KB
// created 01 FEB 2018
// updated JUNE 2018
// updated JULY 2018
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <bitset>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <list>
#include <stdexcept>

#define N 200000

using namespace std;

int find_subset(int l, int u, int w[], int n, int result[]) {
	int prefix[N];
	prefix[0]=w[0];
	for(int i=0;i<n;i++) {
		prefix[i] = prefix[i-1]+w[i];
	}
	
	vector<int> v(prefix,prefix+n);
	vector<int>::iterator low,up;
	
	int a,b=0;
	
	//it's going to be v[b]-v[a]
	for(a=0;a<n;a++) {
		cout << "a is " << a <<endl;
		low=lower_bound(v.begin()+a,v.end(),l+v[a]);
		up =upper_bound(v.begin()+a,v.end(),u+v[a]);
		if(low-v.begin()<up-v.begin()) {
			b=low-v.begin();
			break;
		}
	}
	//cout  << a<<endl<<b<<endl;
	
	if(a==n) {
		return 0;
	}
	
	for(int i=0;i<b-a;i++) {
		result[i]=a+1+i;
	}
	
	return b-a;
}

int main ()
{
    std::ios_base::sync_with_stdio(false), cin.tie(0) , cout.tie(0);
    //freopen("leftin.in", "r", stdin);
    //freopen("leftout.out", "w", stdout);
	
	//int w[4]={5,5,6,6};
	//int result[N];
    //cout << find_subset(14,15,w,4,result);
}


Compilation message

/tmp/ccynuy4V.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc2U5IXd.o:molecules.cpp:(.text.startup+0x0): first defined here
/tmp/ccynuy4V.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status