Submission #102044

# Submission time Handle Problem Language Result Execution time Memory
102044 2019-03-22T00:30:10 Z tim25871014 Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l,int u,vector<int> w){

    vector<int> ans;

    int n=w.size();
    vector<pair<int,int>> wp;
    for(int i=0;i<n;i++)
        wp.push_back({w[i],i});
    sort(wp.begin(),wp.end());

    int sum=0,check=0;
    deque<pair<int,int>> sub;
    for(int i=0;i<n;i++){
        sum+=w[i],sub.push_back(wp[i]);
        while(sum>u) sum-=sub.front(),sub.pop_front();
        if(sum<=u && sum>=l) {check=1;break;}
    }
    if(!check) return ans;
    for(auto i:sub) ans.push_back(sub.second);
    return ans;

}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:25: error: no match for 'operator-=' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}')
         while(sum>u) sum-=sub.front(),sub.pop_front();
                      ~~~^~~~~~~~~~~~~
molecules.cpp:23:39: error: 'class std::deque<std::pair<int, int> >' has no member named 'second'; did you mean 'end'?
     for(auto i:sub) ans.push_back(sub.second);
                                       ^~~~~~
                                       end