# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240321 | Dremix10 | Detecting Molecules (IOI16_molecules) | C++17 | 1088 ms | 4264 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;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
#define N (int)(1e5+1)
vector<int> find_subset(int l, int r, vector<int> w) {
int n=w.size();
int i,j;
pair<int,int> arr[n];
for(i=0;i<n;i++)
arr[i]={w[i],i};
sort(arr,arr+n,greater<pair<int,int> >());
set<int> s;
s.insert(0);
map<int,int> low;
low[0]=0;
vector<int> neo;
for(i=1;i<=n;i++){
for(auto x : s){
int num=x+arr[i-1].F;
if(num<l){
if(s.count(num))
continue;
neo.push_back(num);
low[num]=i;
}
else if(num<=r){
vector<int> ans;
ans.push_back(arr[i-1].S);
num=x;
int row=i-1;
//cout<<num<<" "<<row<<endl;
while(num>0){
//cout<<row<<" "<<num<<endl;
for(j=row;j>0;j--){
if(num<arr[j-1].F)
continue;
int temp=num-arr[j-1].F;
int nr=low[temp];
if(temp==0 || nr<j && nr!=0){
num-=arr[j-1].F;
row=j-1;
ans.push_back(arr[j-1].S);
break;
}
}
}
return ans;
}
}
for(auto x : neo)
s.insert(x);
}
return vector<int>(0);
}
/// g++ grader.cpp molecules_full.cpp
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... |