Submission #88626

#TimeUsernameProblemLanguageResultExecution timeMemory
88626NucleistDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> std::vector<int> find_subset(int l, int u, std::vector<int> w) { int k = w.size(); int f = l; l=u; int n = k; vector <int> kk; int sum = max(f,l); bool subset[k+1][max(f,l)+1]; for (int i = 0; i <= n; i++) subset[i][0] = true; for (int i = 1; i <= sum; i++) subset[0][i] = false; for (int i = 1; i <= n; i++) { for (int j = 1; j <= sum; j++) { if(j<w[i-1]) subset[i][j] = subset[i-1][j]; if (j >= w[i-1]) subset[i][j] = subset[i-1][j] || subset[i - 1][j-w[i-1]]; } } bool ka = false; for (int j = min(l,f); j <= max(l,f); j++) { int kaa=j; if(subset[n][j]) { for(int i = n;i>=1;i--) { if(subset[i-1][kaa-w[i-1]]) { kk.push_back(w[i-1]); kaa -= w[i-1]; compteur++; ka=true; if(kaa==0) break; } } } if(ka) break; } cout<<compteur<<'\n'; for(int i=0;i<compteur;i++) cout<<kk[i]<<" "; return std::vector<int>kk; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:5: error: 'vector' was not declared in this scope
     vector <int> kk;
     ^~~~~~
molecules.cpp:8:5: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
molecules.cpp:8:13: error: expected primary-expression before 'int'
     vector <int> kk;
             ^~~
molecules.cpp:9:15: error: 'max' was not declared in this scope
     int sum = max(f,l);
               ^~~
molecules.cpp:9:15: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
molecules.cpp:12:7: error: 'subset' was not declared in this scope
       subset[i][0] = true;
       ^~~~~~
molecules.cpp:12:7: note: suggested alternative: 'sigset'
       subset[i][0] = true;
       ^~~~~~
       sigset
molecules.cpp:14:7: error: 'subset' was not declared in this scope
       subset[0][i] = false;
       ^~~~~~
molecules.cpp:14:7: note: suggested alternative: 'sigset'
       subset[0][i] = false;
       ^~~~~~
       sigset
molecules.cpp:20:10: error: 'subset' was not declared in this scope
          subset[i][j] = subset[i-1][j];
          ^~~~~~
molecules.cpp:20:10: note: suggested alternative: 'sigset'
          subset[i][j] = subset[i-1][j];
          ^~~~~~
          sigset
molecules.cpp:22:12: error: 'subset' was not declared in this scope
            subset[i][j] = subset[i-1][j] ||
            ^~~~~~
molecules.cpp:22:12: note: suggested alternative: 'sigset'
            subset[i][j] = subset[i-1][j] ||
            ^~~~~~
            sigset
molecules.cpp:28:19: error: 'min' was not declared in this scope
      for (int j = min(l,f); j <= max(l,f); j++)
                   ^~~
molecules.cpp:28:19: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
molecules.cpp:31:14: error: 'subset' was not declared in this scope
           if(subset[n][j])
              ^~~~~~
molecules.cpp:31:14: note: suggested alternative: 'sigset'
           if(subset[n][j])
              ^~~~~~
              sigset
molecules.cpp:38:21: error: 'kk' was not declared in this scope
                     kk.push_back(w[i-1]);
                     ^~
molecules.cpp:38:21: note: suggested alternative: 'ka'
                     kk.push_back(w[i-1]);
                     ^~
                     ka
molecules.cpp:40:21: error: 'compteur' was not declared in this scope
                     compteur++;
                     ^~~~~~~~
molecules.cpp:40:21: note: suggested alternative: 'toupper'
                     compteur++;
                     ^~~~~~~~
                     toupper
molecules.cpp:50:6: error: 'cout' was not declared in this scope
      cout<<compteur<<'\n';
      ^~~~
molecules.cpp:50:6: note: suggested alternative:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:75:0,
                 from molecules.cpp:2:
/usr/include/c++/7/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^~~~
molecules.cpp:50:12: error: 'compteur' was not declared in this scope
      cout<<compteur<<'\n';
            ^~~~~~~~
molecules.cpp:50:12: note: suggested alternative: 'toupper'
      cout<<compteur<<'\n';
            ^~~~~~~~
            toupper
molecules.cpp:52:15: error: 'kk' was not declared in this scope
         cout<<kk[i]<<" ";
               ^~
molecules.cpp:52:15: note: suggested alternative: 'ka'
         cout<<kk[i]<<" ";
               ^~
               ka
molecules.cpp:53:28: error: expected primary-expression before 'kk'
     return std::vector<int>kk;
                            ^~
molecules.cpp:53:28: error: expected ';' before 'kk'
molecules.cpp:53:28: error: 'kk' was not declared in this scope
molecules.cpp:53:28: note: suggested alternative: 'ka'
     return std::vector<int>kk;
                            ^~
                            ka