제출 #831044

#제출 시각아이디문제언어결과실행 시간메모리
831044NoLoveBank (IZhO14_bank)C++14
25 / 100
1077 ms596 KiB
/**
 *    author : Lăng Trọng Đạt
 *    created: 2023-08-19
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int int64_t
using pii = pair<int, int>;



int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("hi.inp", "r")) {
        freopen("hi.inp", "r", stdin);
        freopen("hi.out", "w", stderr);
    }

    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;

    // dp[i][mask] = true neu nhu i nguoi dau tien co the nhan du luong
    vector<vector<bool>> dp(n, vector<bool>(1 << m, 0));

    for (int i = 0; i < n; i++) {
        for (int mask = 1; mask < (1 << m); mask++) {
            vector<int> on;
            for (int j = 0; j < m; j++)
                if (mask & (1 << j))
                    on.push_back(j);
            for (int mask2 = 1; mask2 < (1 << on.size()); mask2++) {
                int tmp = mask, total = 0;
                for (int j = 0; j < on.size(); j++) {
                    if (mask2 & (1 << j)) {
                        total += b[on[j]];
                        tmp ^= 1 << on[j];
                    }
                }
                if (total == a[i]) {
                    if (i == 0 or dp[i - 1][tmp]) dp[i][mask] = true;
                    db(total, i, mask, mask2, tmp)
                    db(bitset<6>(mask), bitset<6>(mask2));
                }
             }
        }
    }

    cout << (dp[n - 1][(1 << m) - 1] ? "YES\n" : "NO");
}

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int32_t main()':
bank.cpp:39:35: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |                 for (int j = 0; j < on.size(); j++) {
      |                                 ~~^~~~~~~~~~~
bank.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen("hi.out", "w", stderr);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...