답안 #229042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229042 2020-05-03T09:48:55 Z huzaifa242 Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define int int32_t
#define long int64_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l=0,int r=INT_MAX)
{return uniform_int_distribution<int>(l,r)(rng);}

template <typename T,typename G>
ostream& operator << (ostream& out, const pair<T,G> &a) 
{return out<<"( "<<a.x<<", "<<a.y<<")";}

template <typename T>
ostream& operator << (ostream& out, const vector<T> &a) 
{out<<"[ ";for(const auto &i:a)out<<i<<", ";return out<<"]"<<endl;}

template <typename T>
ostream& operator << (ostream& out, const set<T> &a) 
{out<<"{ ";for(const auto &i:a)out<<i<<", ";return out<<"}"<<endl;}

template <typename T,typename G>
ostream& operator << (ostream& out, const map<T,G> &a) 
{out<<"< ";for(const auto &i:a)out<<i<<", ";return out<<">"<<endl;}

template<typename T, size_t N>
typename enable_if<!is_same<typename remove_cv<T>::type, char>::value,
ostream&>::type operator<<(ostream& out, T(&a)[N])
{out<<"[ ";for(size_t i=0;i<N;++i)out<<a[i]<<", ";out <<"]"<<endl;return out;}

void debug_out(){cerr<<endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr<<(H)<<" ";debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr<<"#"<<#__VA_ARGS__<<":\n",debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

vector<int> find_subset(int l, int r, vector<int> &a){
	int n=a.size(),i;
	long mn=l,mx=r;
	vector<pair<long,int> >	w(n);
	for(i=0;i<n;i++)
		w[i]={a[i],i};
	sort(w.begin(),w.end());
	long sum=w[0].x;
	int left=0,right=0;
	vector<int> ans;
	while(left<n){
		if(sum>=mn && sum<=mx ){
			for(i=left;i<=right;i++)
				ans.push_back(w[i].y);
			return ans;
		}else if(sum<mn){
			if(right<n-1){
				right++;
				sum+=w[right].x;
			}else
				left=n;
		}else{
			sum-=w[left].x;
			left++;
			if(left>right){
				right=left;
				sum=w[left].x;
			}
		}
	}
	return ans;
}

Compilation message

/tmp/ccOfRMVl.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