Submission #676995

#TimeUsernameProblemLanguageResultExecution timeMemory
676995DulguunDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

int find_subset(int l, int u, int w[], int n, int result[]){
	vector<pair<int,int>> v(n);
	for(int i=0; i<n; i++) v[i]={w[i], i};
	sort(v.begin(), v.end());
	
	for(int k=n; k>0; k++){
		int s=0;
		for(int i=0; i<k; i++) s+=v[i];
		do{
			if(s>=l && s<=u) {
				for(int j=i-k; j<i; j++) result[j]=v[j].second;
				return k;
			}s=s+v[i]-v[i-k];
		}
		while(int i=k; i<n; i++)
	}
	
}

Compilation message (stderr)

molecules.cpp: In function 'int find_subset(int, int, int*, int, int*)':
molecules.cpp:11:27: error: no match for 'operator+=' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   11 |   for(int i=0; i<k; i++) s+=v[i];
molecules.cpp:14:15: error: 'i' was not declared in this scope
   14 |     for(int j=i-k; j<i; j++) result[j]=v[j].second;
      |               ^
molecules.cpp:16:11: error: 'i' was not declared in this scope
   16 |    }s=s+v[i]-v[i-k];
      |           ^
molecules.cpp:18:9: error: expected primary-expression before 'int'
   18 |   while(int i=k; i<n; i++)
      |         ^~~
molecules.cpp:18:9: error: expected ')' before 'int'
   18 |   while(int i=k; i<n; i++)
      |        ~^~~
      |         )
molecules.cpp:18:9: error: expected ';' before 'int'
   18 |   while(int i=k; i<n; i++)
      |         ^~~
      |         ;
molecules.cpp:18:19: warning: statement has no effect [-Wunused-value]
   18 |   while(int i=k; i<n; i++)
      |                  ~^~
molecules.cpp:18:26: error: expected ';' before ')' token
   18 |   while(int i=k; i<n; i++)
      |                          ^
      |                          ;
molecules.cpp:5:27: warning: control reaches end of non-void function [-Wreturn-type]
    5 |  vector<pair<int,int>> v(n);
      |                           ^