Submission #653695

#TimeUsernameProblemLanguageResultExecution timeMemory
653695ammar2000Detecting Molecules (IOI16_molecules)C++17
31 / 100
2 ms596 KiB
#include "molecules.h" #include<bits/stdc++.h> #define ll long long #define pb push_back #define F first #define S second #define coy cout<<"YES\n" #define con cout<<"NO\n" #define co1 cout<<"-1\n" #define sc(x) scanf("%lld",&x) #define all(x) x.begin(),x.end() #define fast ios::sync_qith_stdio(0);cin.tie(0);cout.tie(0); using namespace std; ll n,L,r,q[111]; bool dp[111][1111],vis[111][1111]; vector <int > v; bool solve(int in,int we) { if (L<=we&&we<=r) return 1; if (in==n||we>r) return 0; if (vis[in][we]) return (dp[in][we]|dp[in][we+q[in]]); /*v.pb(in); v.pb(q[in]);*/ vis[in][we]=1; dp[in][we]=solve(in+1,we); dp[in][we+q[in]]=solve(in+1,we+q[in]); return (dp[in][we]|dp[in][we+q[in]]); } void res(int in,int we) { if (in==n||we>r) return ; if (dp[in][we]) { res(in+1,we); return ; } if (dp[in][we+q[in]]) { v.pb(in); res(in+1,we+q[in]); return ; } return ; } std::vector<int> find_subset(int l, int u, std::vector<int> w) { n=w.size(); L=l,r=u; int idx=0; for (auto i:w) q[idx++]=i; bool ans=solve(0,0); res(0,0); return v; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:55:9: warning: unused variable 'ans' [-Wunused-variable]
   55 |    bool ans=solve(0,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...