# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
555951 | pere_gil | Detecting Molecules (IOI16_molecules) | C++14 | 1072 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
#define ii pair<long long,long long>
typedef long long ll;
int MAX_N=1005;
vector<vector<ll> > ma(MAX_N,vector<ll> (1,0));
vector<int> res;
void solve(int &l, int &r, ll pos, vector<ii> &v, ll &sum){
if(pos==MAX_N){
if(sum<l || sum>r) return;
res.clear();
for(int i=0;i<v.size();i++)
for(int j=1;j<=v[i].first;j++)
res.push_back(ma[v[i].second][j]);
/*
printf("end with %lld\n",sum);
for(int i=0;i<res.size();i++) printf("%d ",res[i]); printf("\n");
for(int i=0;i<v.size();i++) printf("%lld ; %lld\n",v[i].first,v[i].second);
printf("\n");
*/
return;
}
for(ll i=0;i<ma[pos].size();i++){
if(sum+pos*i>r) return;
sum+=pos*i;
v.push_back({i,pos});
solve(l,r,pos+1,v,sum);
sum-=pos*i;
v.pop_back();
}
}
vector<int> find_subset(int l, int r, vector<int> w) {
int n=w.size();
ll sum=0;
for(int i=0;i<n;i++){
ma[w[i]].push_back(i);
sum+=w[i];
}
if(sum<l) return {};
vector<ii> v;
sum=0;
solve(l,r,1,v,sum);
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |