Submission #237027

# Submission time Handle Problem Language Result Execution time Memory
237027 2020-06-04T09:38:22 Z michao Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

vi find_subset(int l,int r,vi w)
{
	vector<pii>tab;
	int n=sz(w);
	tab.clear();
	int licznik=1;
	for (auto it:w)tab.pb(mp(it,licznik++));
	sort(tab.begin(),tab.end());
	int ile=0;
	vi ans;
	ans.clear();
	int wskl=-1,wskr=-1;
  vector<ll> pref;
  pref.clear();
  ll sum=0;
  for (int i=0;i<n;i++)sum+=tab[i].st,pref.pb(sum);
  for (int i=0;i<sz(pref);i++)
  {
  	if (pref[i]>=l && pref[i]<=r)
  	{
  		wskl=0,wskr=i;
  		break;
  	}
  	else if (pref[i]>r)
  	{
  		int ile=pref[i]-r;
  		int wsk=*lower_bound(pref.begin(),pref.end(),ile);
  		if (pref[i]-wsk>=l && pref[i]-wsk<=r)
  		{
  			int wsk2=lower_bound(pref.begin(),pref.end(),ile)-pref.begin();
  			wskl=wsk2+1,wskr=i;
  			if (wskl>wskr)wskl=-1,wskr=-1;
  			else break;
  		}
  	}
  }
  if (wskl!=-1)for (int i=wskl;i<=wskr;i++)ans.pb(tab[i].nd);
	return ans;
}

int32_t main()
{
  BOOST;
  vi rak;
  rak=find_subset(10, 20, {15, 17, 16, 18});
  cout<<sz(rak)<<"\n";
  for (auto it:rak)cout<<it<<" ";
  return 0;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:25:6: warning: unused variable 'ile' [-Wunused-variable]
  int ile=0;
      ^~~
/tmp/ccuYAPSH.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccMwLzCk.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status