Submission #267064

#TimeUsernameProblemLanguageResultExecution timeMemory
267064jairRSDetecting Molecules (IOI16_molecules)C++17
0 / 100
1095 ms516 KiB
#include "molecules.h" #include <set> #include <map> using namespace std; map<int, string> states; map<string, set<int>> values; int gw[200000]; int wsize; set<int> go(string state = "", int sum = 0) { if (state.size() == wsize) { states[sum] = state; set<int> res = {sum}; return res; } set<int> res1 = go(state + "0", sum); set<int> res2 = go(state + "1", sum + gw[state.size()]); res1.insert(res2.begin(), res2.end()); return res1; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { wsize = w.size(); for (int i = 0; i < w.size(); i++) { gw[i] = w[i]; } set<int> possible = go(); int guess = *possible.lower_bound(l); if (guess <= u) { vector<int> res; string state = states[guess]; for (int i = 0; i < w.size(); i++) { if (state[i] == '1') res.push_back(i); } return res; } else { return std::vector<int>(0); } }

Compilation message (stderr)

molecules.cpp: In function 'std::set<int> go(std::string, int)':
molecules.cpp:13:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |     if (state.size() == wsize)
      |         ~~~~~~~~~~~~~^~~~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < w.size(); i++)
      |                     ~~^~~~~~~~~~
molecules.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (int i = 0; i < w.size(); i++)
      |                         ~~^~~~~~~~~~
#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...