Submission #289378

#TimeUsernameProblemLanguageResultExecution timeMemory
289378UserIsUndefinedDetecting Molecules (IOI16_molecules)C++14
100 / 100
70 ms12032 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<long long,int>> small,big, W; for (int i = 0 ; i < w.size() ; i++){ W.push_back({w[i] , i}); } sort(W.begin(), W.end()); long long sum = 0; bool good = 0; for (int i = 0 ; i < W.size() ; i++){ sum+= W[i].first; small.push_back(W[i]); if (sum >= l && sum <= u){ vector<int> re; for (int i = 0 ; i < small.size() ; i++){ re.push_back(small[i].second); } return re; } if (sum > u){ good = 1; small.pop_back(); sum-= W[i].first; break; } } if (good == 0){ vector<int> em; return em; } // cout << sum << endl; long long sum2 = 0; for (int i = 0 ; i < small.size() ; i++){ sum2+= W[W.size() - 1 - i].first; big.push_back(W[W.size() - 1 - i]); } if (sum2 < l){ return {}; } for (int i = 0 ; i < small.size() ; i++){ sum-= small[i].first; sum+= big[i].first; swap(small[i], big[i]); if (sum >= l && sum <= u){ vector<int> re; for (int i = 0 ; i < small.size() ; i++){ re.push_back(small[i].second); } return re; } } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0 ; i < w.size() ; i++){
      |                      ~~^~~~~~~~~~
molecules.cpp:19:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0 ; i < W.size() ; i++){
      |                      ~~^~~~~~~~~~
molecules.cpp:24:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             for (int i = 0 ; i < small.size() ; i++){
      |                              ~~^~~~~~~~~~~~~~
molecules.cpp:47:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i = 0 ; i < small.size() ; i++){
      |                      ~~^~~~~~~~~~~~~~
molecules.cpp:57:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 0 ; i < small.size() ; i++){
      |                      ~~^~~~~~~~~~~~~~
molecules.cpp:63:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             for (int i = 0 ; i < small.size() ; i++){
      |                              ~~^~~~~~~~~~~~~~
molecules.cpp:7:33: warning: control reaches end of non-void function [-Wreturn-type]
    7 |     vector<pair<long long,int>> small,big, W;
      |                                 ^~~~~
#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...