Submission #774989

#TimeUsernameProblemLanguageResultExecution timeMemory
774989Minindu2006Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;

vector<int> find_subset(int L, int U, vector<int> w)
{
    vector<pair<int, int>> arr;
    for(int i=0;i<w.size();i++)
        arr.push_back({w[i], i});
    sort(arr.begin(), arr.end());
    int p1 = 0, p2 = 0, pos = 0;
    int sum = arr[0].first;
    while(p1 < w.size())
    {
        if(sum >= L && sum <= U)
        {
            pos = 1;
            break;
        }
        else if(sum < L)
        {
            p1++;
            if(p1 == w.size())
                break;
            sum += arr[p1].first;
        }   
        else if(sum > U)
        {
            sum -= arr[p2].first;
            p2++;
        }   
    }
    vector<int> ans;
    if(!pos)
        return ans;
    for(int i=p2;i<=p1;i++)
        ans.push_back(arr[i].second);
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<w.size();i++)
      |                 ~^~~~~~~~~
molecules.cpp:13:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     while(p1 < w.size())
      |           ~~~^~~~~~~~~~
molecules.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             if(p1 == w.size())
      |                ~~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccV6Oas8.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccovzTS4.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status