Submission #1238150

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

#define ll long long
#define F first
#define S second

vector<int> find_subset(int l, int r, vector<int> w){
	int N = w.size(), sum = 0;
	vector<pair<int, int>> W(N);
	for(int i = 0; i < N; i++){
		W[i] = {w[i], i};
	}
	sort(W.begin(), W.end());
	vector<int> ans;
	ilnt left = 0, right = 0;
	while(left <= right){
		if(sum < l){
			sum += w[right].F;
			right++;
		}
		else if(sum > r){
			sum -= W[left].F;
			left++;
		}
		else{
			for(int i = left; i <= right; i++){
				ans.push_back(W[i].S);
			}
		}
	}
	return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:9: error: 'ilnt' was not declared in this scope; did you mean 'int'?
   17 |         ilnt left = 0, right = 0;
      |         ^~~~
      |         int
molecules.cpp:20:34: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<int>::size_type' {aka 'long unsigned int'} [-fpermissive]
   20 |                         sum += w[right].F;
      |                                  ^~~~~
      |                                  |
      |                                  std::ios_base& (*)(std::ios_base&)
In file included from /usr/include/c++/11/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1043:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
molecules.cpp:6:11: error: request for member 'first' in 'w.std::vector<int>::operator[](((std::vector<int>::size_type)std::right))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    6 | #define F first
      |           ^~~~~
molecules.cpp:20:41: note: in expansion of macro 'F'
   20 |                         sum += w[right].F;
      |                                         ^
molecules.cpp:21:25: warning: ISO C++ forbids incrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   21 |                         right++;
      |                         ^~~~~
molecules.cpp:21:25: error: lvalue required as increment operand
molecules.cpp:24:34: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-fpermissive]
   24 |                         sum -= W[left].F;
      |                                  ^~~~
      |                                  |
      |                                  std::ios_base& (*)(std::ios_base&)
In file included from /usr/include/c++/11/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1043:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::reference = std::pair<int, int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
molecules.cpp:25:25: warning: ISO C++ forbids incrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   25 |                         left++;
      |                         ^~~~
molecules.cpp:25:25: error: lvalue required as increment operand
molecules.cpp:28:37: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   28 |                         for(int i = left; i <= right; i++){
      |                                     ^~~~
      |                                     |
      |                                     std::ios_base& (*)(std::ios_base&)
molecules.cpp:28:45: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   28 |                         for(int i = left; i <= right; i++){
      |                                           ~~^~~~~~~~
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
      |         ^~~~