Submission #1076953

#TimeUsernameProblemLanguageResultExecution timeMemory
1076953xnqsBank (IZhO14_bank)C++17
0 / 100
10 ms20892 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <utility> #include <algorithm> #include <cstring> std::ifstream fin("bank.in"); std::ofstream fout("bank.out"); int tgt_cnt, x; int tgt[25]; int arr[25]; char dp[20][1<<20]; bool sol(int pos, int mask) { if (pos==tgt_cnt) { return 1; } if (dp[pos][mask]!=-1) { return dp[pos][mask]; } bool ret = 0; for (int mask2 = 0; mask2 < (1<<x); mask2++) { if (mask2&mask) { continue; } int sum = 0; for (int i = 0; i < x; i++) { if (mask2&(1<<i)) { sum += arr[i]; } } if (sum==tgt[pos]) { ret |= sol(pos+1,mask|mask2); if (ret) { break; } } } return dp[pos][mask] = ret; } int main() { fin >> tgt_cnt >> x; std::cout << tgt_cnt << " " << x << "\n"; for (int i = 0; i < tgt_cnt; i++) { fin >> tgt[i]; std::cout << tgt[i] << " "; } std::cout << "\n"; for (int i = 0; i < x; i++) { fin >> arr[i]; std::cout << arr[i] << " "; } std::cout << "\n"; memset(dp,-1,sizeof(dp)); fout << ((sol(0,0)) ? "YES" : "NO") << "\n"; }

Compilation message (stderr)

bank.cpp: In function 'bool sol(int, int)':
bank.cpp:46:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   46 |  return dp[pos][mask] = ret;
      |         ~~~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...