Submission #802821

#TimeUsernameProblemLanguageResultExecution timeMemory
802821Gabi88Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "molecules.h"
using namespace std;

int[] find_subset(int l, int d, int[] v){
	int n = v.size();
	int pref[n+1];
	pref[0] = v[0]; pref[n] = (1 << 31)+5;
	int poc = 0, kraj = 1;
	for(int i=1; i<n; i++) pref[i] = pref[i-1] + v[i];
	while(kraj <= n){
		int sum = pref[kraj-1];
		if (poc > 0) sum -= pref[poc-1];
		if (sum >= l and sum <= d) return [poc, kraj];
		else if (sum > d) poc++;
		else kraj--;
	}
	return [];
}

Compilation message (stderr)

molecules.cpp:5:4: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
    5 | int[] find_subset(int l, int d, int[] v){
      |    ^
molecules.cpp:5:4: error: structured binding declaration cannot have type 'int'
    5 | int[] find_subset(int l, int d, int[] v){
      |    ^~
molecules.cpp:5:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:5:4: error: empty structured binding declaration
molecules.cpp:5:7: error: expected initializer before 'find_subset'
    5 | int[] find_subset(int l, int d, int[] v){
      |       ^~~~~~~~~~~