Submission #777747

#TimeUsernameProblemLanguageResultExecution timeMemory
777747JoenPoenManDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef unsigned long long int lli; vector<vector<lli>> dp; std::vector<int> find_subset(int l, int u, std::vector<int> w) { dp.resize(u+100); for (int i = 0; i < (int)w.size(); i++) { for (lli j = dp.size()-1; j > 0; j--) { if (dp[j].size() > 0 && j+w[i] <= u) { dp[j+w[i]] = dp[j]; dp[j+w[i]].push_back(i); if (j+w[i] >= l) return dp[j+w[i]]; } } dp[w[i]] = {(lli)i}; if (w[i] >= l && w[i] <= u) return dp[w[i]]; } return std::vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:44: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long unsigned int'} and 'int' [-Wsign-compare]
   13 |             if (dp[j].size() > 0 && j+w[i] <= u) {
      |                                     ~~~~~~~^~~~
molecules.cpp:16:28: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long unsigned int'} and 'int' [-Wsign-compare]
   16 |                 if (j+w[i] >= l) return dp[j+w[i]];
      |                     ~~~~~~~^~~~
molecules.cpp:16:50: error: could not convert 'dp.std::vector<std::vector<long long unsigned int> >::operator[](((std::vector<std::vector<long long unsigned int> >::size_type)(j + ((lli)w.std::vector<int>::operator[](((std::vector<int>::size_type)i))))))' from 'vector<long long unsigned int>' to 'vector<int>'
   16 |                 if (j+w[i] >= l) return dp[j+w[i]];
      |                                                  ^
      |                                                  |
      |                                                  vector<long long unsigned int>
molecules.cpp:20:51: error: could not convert 'dp.std::vector<std::vector<long long unsigned int> >::operator[](((std::vector<std::vector<long long unsigned int> >::size_type)w.std::vector<int>::operator[](((std::vector<int>::size_type)i))))' from 'vector<long long unsigned int>' to 'vector<int>'
   20 |         if (w[i] >= l && w[i] <= u) return dp[w[i]];
      |                                                   ^
      |                                                   |
      |                                                   vector<long long unsigned int>