Submission #260418

# Submission time Handle Problem Language Result Execution time Memory
260418 2020-08-10T08:42:20 Z Bill_00 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
using namespace std;
pair<int,int>p[200002];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
  	int n=w.size();
    for(int i=1;i<=n;i++){
		p[i]=mp(w[i],i);
	} 
	sort(p+1,p+n+1);
	vector<int>res;
	ll sum=0,id=0;
	for(int i=1;i<=n;i++){
		sum+=p[i].ff;
		if(sum>=l && sum<=u){
			for(int j=1;j<=i;j++){
				res.push_back(p[i].ss);
			}
			return res;
		}
		if(sum>=l){
			sum-=p[i].ff;
			id=i-1;
			break;
		}
	}
	//cout << id << endl;
	if(id==0){
		return res;
	}
	for(int i=id;i>=1;i--){
		sum=sum-p[i].ff;
		sum=sum+p[i+n-id].ff;
		//cout << sum << endl;
		if(sum>=l){
			for(int j=1;j<i;j++){
				res.push_back(p[j].ss);
			}
			for(int j=i+n-id;j<=n;j++){
				res.push_back(p[j].ss);
			}
			return res;
		}
	}
	return res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:2: error: 'll' was not declared in this scope
  ll sum=0,id=0;
  ^~
molecules.cpp:15:2: note: suggested alternative: 'l'
  ll sum=0,id=0;
  ^~
  l
molecules.cpp:17:3: error: 'sum' was not declared in this scope
   sum+=p[i].ff;
   ^~~
molecules.cpp:26:4: error: 'id' was not declared in this scope
    id=i-1;
    ^~
molecules.cpp:26:4: note: suggested alternative: 'i'
    id=i-1;
    ^~
    i
molecules.cpp:31:5: error: 'id' was not declared in this scope
  if(id==0){
     ^~
molecules.cpp:34:12: error: 'id' was not declared in this scope
  for(int i=id;i>=1;i--){
            ^~
molecules.cpp:34:12: note: suggested alternative: 'i'
  for(int i=id;i>=1;i--){
            ^~
            i
molecules.cpp:35:3: error: 'sum' was not declared in this scope
   sum=sum-p[i].ff;
   ^~~