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 <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
unordered_set<string> st;
ll solve(vector<ll> pr,ll curr,string vis) {
if (curr < 0) {
return 0;
}
if (st.find(vis) != st.end()) {
return 0;
}
st.insert(vis);
ll c=1;
for (int i=0;i<n;i++) {
if (vis[i] == '0') {
vis[i] = '1';
c+=solve(pr,curr-pr[i],vis);
vis[i]= '0';
}
}
return c;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
cin >> n >> m;
vector<ll> pr(n);
for (int i=0;i<n;i++) {
cin >> pr[i];
}
cout << solve(pr,m,string(n,'0'));
return 0;
}
# | 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... |
# | 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... |