Submission #112296

# Submission time Handle Problem Language Result Execution time Memory
112296 2019-05-18T13:44:02 Z ioilolcom Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int rad(int a,int b){
	return rand%(b-a+1);
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	ll sum=0;
	vector<int> ans;
	for(int i=0; i<(int)w.size(); i++) {
		sum+=w[i];
		ans.push_back(w[i]);
		if(sum>r) {
			int m=rad(0,(int)ans.size()) :
				       sum-=ans[m];
			ans.erase(ans.begin()+m);
			break;
		}
	}
	if(sum>=l&&sum<=r) {
		return ans;
	}
	return std::vector<int>(0);
}

Compilation message

molecules.cpp: In function 'int rad(int, int)':
molecules.cpp:6:13: error: invalid operands of types 'int() throw ()' and 'int' to binary 'operator%'
  return rand%(b-a+1);
         ~~~~^~~~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:10: error: 'r' was not declared in this scope
   if(sum>r) {
          ^
molecules.cpp:15:33: error: expected ',' or ';' before ':' token
    int m=rad(0,(int)ans.size()) :
                                 ^
molecules.cpp:21:18: error: 'r' was not declared in this scope
  if(sum>=l&&sum<=r) {
                  ^