Submission #1102199

#TimeUsernameProblemLanguageResultExecution timeMemory
1102199akzytrDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
// #include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	ll p = 0;
	vector<int> result;
	pair<int, int> w2[n];
	for(int i = 0; i < n; i++) {
		w2[i].first = w[i];
		w2[i].second = i;
	}
	sort(w2, w2 + n);

	set<ll> pss;
	map<, int> psjn;

	psjn[0] = -1;
	pss.insert(0);
	for(int i = 0; i < w.size(); i++) {
		p += w2[i].first;
		auto lb = pss.lower_bound(p - u);
		if(lb == pss.end()) {
			lb--;
		}

		if(lb != pss.end() && p - *lb >= l && p - *lb <= u) {
			for(int j = psjn[*lb] + 1; j <= i; j++) {
				result.push_back(w2[j].second);
			}
			break;
		}

		pss.insert(p);
		psjn[p] = i;
	}

	return result;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:20: error: 'n' was not declared in this scope
    9 |  pair<int, int> w2[n];
      |                    ^
molecules.cpp:11:3: error: 'w2' was not declared in this scope; did you mean 'w'?
   11 |   w2[i].first = w[i];
      |   ^~
      |   w
molecules.cpp:14:7: error: 'w2' was not declared in this scope; did you mean 'w'?
   14 |  sort(w2, w2 + n);
      |       ^~
      |       w
molecules.cpp:17:11: error: template argument 1 is invalid
   17 |  map<, int> psjn;
      |           ^
molecules.cpp:17:11: error: template argument 3 is invalid
molecules.cpp:17:11: error: template argument 4 is invalid
molecules.cpp:19:6: error: invalid types 'int[int]' for array subscript
   19 |  psjn[0] = -1;
      |      ^
molecules.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i = 0; i < w.size(); i++) {
      |                 ~~^~~~~~~~~~
molecules.cpp:29:20: error: invalid types 'int[const long long int]' for array subscript
   29 |    for(int j = psjn[*lb] + 1; j <= i; j++) {
      |                    ^
molecules.cpp:36:7: error: invalid types 'int[ll {aka long long int}]' for array subscript
   36 |   psjn[p] = i;
      |       ^