Submission #468123

#TimeUsernameProblemLanguageResultExecution timeMemory
468123TruaShamuBank (IZhO14_bank)C++17
19 / 100
86 ms7108 KiB
#define _crt_secure_no_warnings #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() using pi = pair<int,int>; #define f first #define s second #define mp make_pair void fastio() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); } int N, M; int A[21]; int B[21]; vi sum[20001]; vi dp[21]; int main() { fastio(); cin >> N >> M; for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < M; i++) { cin >> B[i]; } for (int mask = 0; mask < (1 << M); ++mask) { int cur = 0; for (int i = 0; i < M; ++i) { if ((mask & (1 << i)) > 0) { cur += B[i]; } } sum[cur].pb(mask); } dp[0].pb(0); bool f = false; for (int i = 0; i < N; ++i) { bool vis = new bool[1 << 21]; f = false; for (int mask : sum[A[i]]) { for (int pmask : dp[i]) { int maskUnion = mask | pmask; if ((mask & pmask) <= 0 && !vis[&maskUnion]) { vis[&maskUnion] = true; dp[i + 1].pb(mask | pmask); f = true; } } } } cout << (f ? "YES" : "NO")<< "\n"; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:54:59: warning: array subscript 1 is outside array bounds of 'int [1]' [-Warray-bounds]
   54 |                 if ((mask & pmask) <= 0 && !vis[&maskUnion]) {
      |                                             ~~~~~~~~~~~~~~^
bank.cpp:53:21: note: while referencing 'maskUnion'
   53 |                 int maskUnion = mask | pmask;
      |                     ^~~~~~~~~
bank.cpp:55:35: warning: array subscript 1 is outside array bounds of 'int [1]' [-Warray-bounds]
   55 |                     vis[&maskUnion] = true;
      |                     ~~~~~~~~~~~~~~^
bank.cpp:53:21: note: while referencing 'maskUnion'
   53 |                 int maskUnion = mask | pmask;
      |                     ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...