Submission #789818

#TimeUsernameProblemLanguageResultExecution timeMemory
789818MalixDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int arrSize = w.size(); int gap = u - l; vector<int> answer; vector<int> answertemp; vector<int> temp = w; sort(temp.begin(), temp.end()); if(arrSize == 1){ if(w[0]<=u && w[0]>=l){ answer.push_back(0); return answer; } return std::vector<int>(0); } if(temp[0] == temp[arrSize-1]){ int modval = u%w[0]; if(modval<=gap){ int termcount = (u-modval)/w[0]; if(arrSize>=termcount){ for(int i = 0; i < termcount; i++){ answer.push_back(i); } return answer; } } return std::vector<int>(0); } if(temp[arrSize-1]-temp[0]==1){ int right = 1; int sum = temp[0]; answertemp.push_back(l); while(sum<l){ sum += temp[right]; answertemp.push_back(right); right++; if(right = arrSize){ return std::vector<int>(0); } } while(!(sum>=l && sum<=u)){ sum -= answertemp[0]; answertemp.erase(answertemp.begin()+0); sum += temp[right]; answertemp.push_back(right); right++; if(right = arrSize){ return std::vector<int>(0); } } int asize = answertemp.size(); for(int i = 0; i < asize; i++){ int it = find(w.begin(), w.end(), answertemp[i]) - w.begin(); answertemp.erase(answertemp.begin()+it); answer.push_back(it); } return answer; } /* if(temp[arrSize-1] - temp[0] == 1){ vector<int> smallarr; vector<int> largearr; int largeSize = 0; for(int i = 0; i < arrSize; i++){ if(m[i]==temp[n-1]){ largearr.push_back(i); largeSize++; } else{ smallarr.push_back(i); smallSize++; } } int mult = temp[0]*temp[n-1]; int modval = u%mult; int reps = u/mult; int smallmod = modval%temp[0]; int largemod = modval%temp[arrSize-1]; int smalldiv = modval/temp[0]; int largediv = modval/temp[arrSize-1]; if(smallmod==0 && smalldiv>=smallSize){ smallSize -= smalldiv; for(int i = 0; i < smalldiv; i++){ answer.push_back(smallarr[i]); smallarr.erase(i); smallSize--; } } else if(largemod==0 && largediv>=largeSize){ largeSize -= largediv; for(int i = 0; i < largediv; i++){ answer.push_back(largearr[i]); largearr.erase(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:48:26: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   48 |                 if(right = arrSize){
      |                    ~~~~~~^~~~~~~~~
molecules.cpp:58:26: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   58 |                 if(right = arrSize){
      |                    ~~~~~~^~~~~~~~~
#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...