Submission #370448

#TimeUsernameProblemLanguageResultExecution timeMemory
370448amano_hinaDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h"
#include<bits/stdc++.h>
#define int long long
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n=w.size();
    sort(w.begin(),w.end());
    vector<int> ans;
    int mn=0,mx=0,cnt;
    bool d=1;
    for(int i=0;i<n;i++)
    {
        mn=mn+w[i];
        mx=mx+w[n-1-i];
        if(mn>=l&&mn<=u)
        {
            for(int j=0;j<=i;j++)
            {
                ans.push_back(j);
            }
            break;
        }
        else if(mx>=l&&mx<=u)
        {
            for(int j=n-1;j>=n-1-i;j--)
            {
                ans.push_back(j);
            }
            break;
        }
        else if(mn<l&&u<mx)
        {
            cnt=mn;
            for(int j=i;j>=0;j--)
            {
                cnt=cnt-w[j]+w[n-1-(i-j)];
                if(cnt>=l&&cnt<=u)
                {
                    for(int k=0;k<j;k++)
                    {
                        ans.push_back(k);
                    }
                    for(int k=n-1;k>=n-1-(i-j);k--)
                    {
                        ans.push_back(k);
                    }
                    break;
                    
                }
            }
            break;
        }
    }
    return ans;
    
    
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:10:10: warning: unused variable 'd' [-Wunused-variable]
   10 |     bool d=1;
      |          ^
/tmp/cchraDWG.o: In function `main':
grader.cpp:(.text.startup+0x139): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status