Submission #1288767

#TimeUsernameProblemLanguageResultExecution timeMemory
1288767muhammad-ahmadDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "molecules.h"
using nameapace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	int a[n + 1];
	for (int i = 0; i < n; i++) a[i + 1] = w[i];
	int pref[n + 2] = {}, suf[n + 2] = {};
	
	map<int, int> C;
	
	for (int i = 1; i <= n; i++){
		pref[i] = a[i] + pref[i - 1];
	}
	for (int i = n; i >= 1; i--){
		suf[i] = suf[i + 1] + a[i];
	}
	
	S[0] = 1e18;
	r = n;
	while (suf[r] < l) r--;
	for (int L = 0; L <= n; L++){
		while (R <= n && pref[L] + suf[R]) R++;
		
		if (pref[L] + suf[R] >= l && pref[L] + suf[R] <= u){
			vector<int> ans;
			for (int i = 1; i <= L; i++) ans.push_back(a[i]);
			for (int i = R; i <= n; i++) ans.push_back(a[i]);
			return ans;
		}
	}
	
	return {};
	
}

Compilation message (stderr)

molecules.cpp:3:7: error: expected nested-name-specifier before 'nameapace'
    3 | using nameapace std;
      |       ^~~~~~~~~
molecules.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int> find_subset(int l, int u, vector<int> w) {
      | ^~~~~~
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~