Submission #199268

#TimeUsernameProblemLanguageResultExecution timeMemory
199268monus1042Detecting Molecules (IOI16_molecules)C++17
9 / 100
5 ms504 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> ans; int ss=w.size(); int same=w[0], cnt1=1, cnt2=0, secel; unordered_set<int> posfir, possec; posfir.insert(0); bool oksame=true; for (int i=1; i<ss; i++){ if (w[i]!=same) {oksame=false; cnt2++; secel=w[i]; possec.insert(i);} else {cnt1++; posfir.insert(i);} } if (!oksame){ if (secel>=l and secel<=u) ans.push_back(*possec.begin()); else if (same>=l and same<=u) ans.push_back(*posfir.begin()); else{ bool done=false; for (int i=1; i<=cnt1; i++){ for (int j=1; j<=cnt2; j++){ if (secel*j + same*i>=l and secel*j + same*i<=u){ auto fi=posfir.begin(), se=possec.begin(); for (int k=0; k<i; k++, fi++) ans.push_back(*fi); for (int k=0; k<j; k++, se++) ans.push_back(*se); done=true; break; } } if (done) break; } } }else{ for (int i=1; i<=ss; i++){ if (same*i>=l and same*i<=u){ for (int j=0; j<i; j++) ans.push_back(j); break; } } } return ans; }
#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...