답안 #290752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290752 2020-09-04T12:14:40 Z REALITYNB Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h> 
#define int 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){
    sort(all(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)) ; 
    if(sum<l){
        return re ; 
    } 
    if(sum<=l&&sum<=r){
        for(int  x : ans) re.push_back(x) ;
        return re ; 
    } 
    while(sum>r&&b.size()){
        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 ; 
            break ; 
        }
    }
    if(sum>r)
        return re ; 
//	cout << 1 << " " ; 
    for(int  x : ans) re.push_back(x) ; 
    return re ; 
}

Compilation message

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:18:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i=0;i<a.size();i++)  b.insert(mp(a[i],i)) ;
      |                 ~^~~~~~~~~
/tmp/cckrt3t4.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status