Submission #774592

#TimeUsernameProblemLanguageResultExecution timeMemory
774592JMsDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
    #include <bits/stdc++.h>

    using namespace std;

    vector<long long> find_subset(long long l, long long u, vector<long long> w)
    {
        unsigned  const long long tam = 200005;
        long long v[tam], aux, ph, pl, s;
        vector <long long> result;
        for( long long i=0; i<w.size(); i++){
            v[i]=i;
        }
        for( long long i=0; i<w.size()-1; i++){
            for( long long j=i+1; j<w.size(); j++){
                if(w[i]>w[j]){
                    aux=w[j];
                    w[j]=w[i];
                    w[i]=aux;
                    aux=v[j];
                    v[j]=v[i];
                    v[i]=aux;
                }
            }
        }
        pl=0;
        ph=0;
        s=w[0];
        while(1){
            cout<<pl<<" "<<ph<<" "<<s<<endl;
            if(s<l && ph<w.size()-1){
                ph++;
                s+=w[ph];
            }
            else if(s>u && pl<ph){
                s-=w[pl];
                pl++;
            }
            else if( ph==w.size()-1 && (s>u || s<l)){
                return vector<long long>();
                break;
            }
            else{
                for( long long i=pl; i<=ph; i++){
                    cout<<v[i]<<" ";
                    result.push_back(v[i]);
                }
                cout<<endl;
                break;
            }
        }
        return result;
    }

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:30: 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]
   10 |         for( long long i=0; i<w.size(); i++){
      |                             ~^~~~~~~~~
molecules.cpp:13:30: 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]
   13 |         for( long long i=0; i<w.size()-1; i++){
      |                             ~^~~~~~~~~~~
molecules.cpp:14:36: 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]
   14 |             for( long long j=i+1; j<w.size(); j++){
      |                                   ~^~~~~~~~~
molecules.cpp:30:25: 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]
   30 |             if(s<l && ph<w.size()-1){
      |                       ~~^~~~~~~~~~~
molecules.cpp:38:24: 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]
   38 |             else if( ph==w.size()-1 && (s>u || s<l)){
      |                      ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/cc2t1xpP.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status