Submission #154789

# Submission time Handle Problem Language Result Execution time Memory
154789 2019-09-24T15:48:16 Z Mercenary Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "molecules.h"
using namespace std;

vector<int> find_subset(int l, int u, std::vector<int> w) {
    typedef pair<int,int> ii;
    vector<ii> v(w.size());
    for(int i = 0 ; i < (int)w.size() ; ++i){
        v[i] = mp(w[i] , i);
    }
    vector<int> ans;
    sort(v.begin(),v.end());
    int jj = 0;
    int sum = 0;
    for(int i = 0 ; i < (int)w.size() ; ++j){
        while(jj < (int)w.size() && sum + w[jj].first <= u)sum += w[jj++].first;
        if(sum >= l){
            for(int j = i ; j < jj ; ++j)ans.pb(w[j].second);
            return ans;
        }
        sum -= w[i].first;
    }
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:16: error: 'mp' was not declared in this scope
         v[i] = mp(w[i] , i);
                ^~
molecules.cpp:15:43: error: 'j' was not declared in this scope
     for(int i = 0 ; i < (int)w.size() ; ++j){
                                           ^
molecules.cpp:16:49: error: request for member 'first' in 'w.std::vector<int>::operator[](((std::vector<int>::size_type)jj))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
         while(jj < (int)w.size() && sum + w[jj].first <= u)sum += w[jj++].first;
                                                 ^~~~~
molecules.cpp:16:75: error: request for member 'first' in 'w.std::vector<int>::operator[](((std::vector<int>::size_type)(jj ++)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
         while(jj < (int)w.size() && sum + w[jj].first <= u)sum += w[jj++].first;
                                                                           ^~~~~
molecules.cpp:18:46: error: 'class std::vector<int>' has no member named 'pb'
             for(int j = i ; j < jj ; ++j)ans.pb(w[j].second);
                                              ^~
molecules.cpp:18:54: error: request for member 'second' in 'w.std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
             for(int j = i ; j < jj ; ++j)ans.pb(w[j].second);
                                                      ^~~~~~
molecules.cpp:21:21: error: request for member 'first' in 'w.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
         sum -= w[i].first;
                     ^~~~~