Submission #491942

#TimeUsernameProblemLanguageResultExecution timeMemory
491942VirvDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms332 KiB
#include <algorithm> #include <cstdint> #include <vector> #include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { sort(w.begin(), w.end()); uint32_t T{}; std::vector<int> S{}; size_t i{}; while (i < w.size() && T + w[i] <= u) { T += w[i]; S.push_back(i); ++i; } while (i < w.size() && T < l) { T += w[i] - w[S[i % S.size()]]; S[i % S.size()] = i; ++i; } return l <= T && T <= u ? S : std::vector<int>{}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:34: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   14 |  while (i < w.size() && T + w[i] <= u) {
      |                         ~~~~~~~~~^~~~
molecules.cpp:20:27: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   20 |  while (i < w.size() && T < l) {
      |                         ~~^~~
molecules.cpp:26:11: warning: comparison of integer expressions of different signedness: 'int' and 'uint32_t' {aka 'unsigned int'} [-Wsign-compare]
   26 |  return l <= T && T <= u ? S : std::vector<int>{};
      |         ~~^~~~
molecules.cpp:26:21: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   26 |  return l <= T && T <= u ? S : std::vector<int>{};
      |                   ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...