Submission #290772

# Submission time Handle Problem Language Result Execution time Memory
290772 2020-09-04T12:35:26 Z REALITYNB Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h> 
#define ll long long 
#define all(a) a.begin(),a.end() 
#define mp make_pair
#define F first 
#define S second 
#define pii pair<int,int> 
using namespace std; 
vector<int> find_subset(int l , int r , vector<int> a){
    int sum=  0   ; 
    for(int x :a) sum+= x ;
    set<int> ans ;
    int n = a.size() ; 
    for(int i=0;i<n;i++) ans.insert(i) ; 
    vector<int> re ;
    set<pii> b ; 
    for(int i=0;i<a.size();i++)  b.insert(mp(a[i],i)) ; 
    while(1){
        if(b.empty()) break ; 
        if(r>=sum) break ; 
        auto it = b.end() ; 
        it-- ; 
        pii w = *it ;
        
        if(sum-w.F>r){
            sum-=w.F ; 
            b.erase(it) ; 
            ans.erase(w.S) ; 
        }
        else if(sum-w.F<l){
            b.erase(it) ; 
        }
        else{
            b.erase(it) ;
            ans.erase(w.S) ;  
            sum-=w.F ; 
        }
    }
    //if(sum>r) return re ; 
//  cout << 1 << " " ; 
    for(int  x : ans) re.push_back(x) ; 
    if(sum<=r&&l<=sum)return re ;  
    return vector<int>() 
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<a.size();i++)  b.insert(mp(a[i],i)) ;
      |                 ~^~~~~~~~~
molecules.cpp:43:25: error: expected ';' before '}' token
   43 |     return vector<int>()
      |                         ^
      |                         ;
   44 | }
      | ~