Submission #240321

#TimeUsernameProblemLanguageResultExecution timeMemory
240321Dremix10Detecting Molecules (IOI16_molecules)C++17
46 / 100
1088 ms4264 KiB
#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)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:54:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
                         if(temp==0 || nr<j && nr!=0){
                                       ~~~~~^~~~~~~~
#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...