Submission #173974

#TimeUsernameProblemLanguageResultExecution timeMemory
173974CaroLindaDetecting Molecules (IOI16_molecules)C++14
0 / 100
3 ms1016 KiB
#include "molecules.h" #include <bits/stdc++.h> #define debug printf #define lp(i,a,b) for(int i = a ; i < b ; i++ ) #define ff first #define ss second #define pb push_back #define mk make_pair #define ll long long #define sz size() #define pii pair<int,int> #define all(x) x.begin(),x.end() #define tiii tuple<int,int,int> #define mkt make_tuple const int MAX = 10010 ; using namespace std ; bool dp[MAX] ; vector<int> res , aux[MAX] ; bool find(int idx, int num ) { int l = 0 , r = (int)(aux[idx].sz) - 1 , mid ; while(l<=r) { mid = (l+r)>>1 ; if( aux[idx][mid] < num ) l = mid + 1 ; else if( aux[idx][mid] > num ) r = mid - 1 ; else return true ; } return aux[idx][mid] == num ; } vector<int> find_subset(int l, int u, vector<int> w) { int cnt = 1 ; dp[0] = true ; for(int i : w) { for(int j = u ; j >= 0 ; j-- ) { if(!dp[j]) continue ; if( j + i <= u && !dp[j+i] ) { dp[j+i]=true ; aux[cnt].pb(j+i) ; } } cnt ++ ; } cnt -- ; lp(i,1,cnt+1) reverse(all(aux[i])) ; int ok = -1 ; lp(i,l,u+1) if( dp[i] ) ok = i ; if( ok == -1 ) return res ; for(int i = cnt ; i > 0 ; i-- ) if( w[i-1] <= ok && find(i,ok) ) { res.pb(i-1) ; ok -= w[i-1] ; } sort(all(res)); return res ; }

Compilation message (stderr)

molecules.cpp: In function 'bool find(int, int)':
molecules.cpp:27:43: warning: 'mid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int l = 0 , r = (int)(aux[idx].sz) - 1 , mid ;
                                           ^~~
#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...