Submission #1151037

#TimeUsernameProblemLanguageResultExecution timeMemory
1151037hungandhimselfBank (IZhO14_bank)C++20
Compilation error
0 ms0 KiB

        cin >> a[i];
        mark[a[i]] = true;
    }

    for (int i = 1; i <= m; i++) {
        cin >> b[i];
    }

    for (int s = 0; s < (1 << n); s++) {
        int sum = 0;
        for (int mask = 0; mask < n; mask++) {
            if (s & (1 << mask)) {
                sum += b[mask + 1];
            }
        }

        if (mark[sum])
            subset[sum].push_back(s);
    }

    memset(dp, false, sizeof dp);
    dp[1][0] = true;
    for (int i = 1; i < n; i++) {
        for (int s = 0; s < (1 << n); s++) {
            if (dp[i][s] == false) continue;
            for (int x : subset[a[i]]) {
                if ((s | x) == x) {
                    dp[i + 1][s ^ x] = true;
                }
            }
        }
    }

    cout << (*max_element(dp[n], dp[n] + 1) == true ? "YES" : "NO") << '\n';
}

/**
    B1 : kiểm tra lại code templete, code đã học thuộc
    đọc kĩ đề
    nháp chưa
    kiểm tra lại code, đặc biệt là những chỗ đã học thuộc (nhiều khi sai ở đó)
**/
signed main () {
    ios_base::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    #ifndef ONLINE_JUDGE
//        freopen ("movie.in", "r", stdin);
//        freopen ("movie.out", "w", stdout);
    #else // online submission
    #endif
/// i have a contest soon and i need to learn a much as possible
/// so let become familiar with a bunch of different problems and solution ideas
    // stop learning useless algorithm (with you) and solve more problems
    //Cứ 7 lần nộp thì chỉ được 1 lần sai

    int test = 1;
//    cin >> test;
    while (test--) runcase(test);
    // return 0;
}

Compilation message (stderr)

bank.cpp:2:9: error: 'cin' does not name a type
    2 |         cin >> a[i];
      |         ^~~
bank.cpp:3:9: error: 'mark' does not name a type
    3 |         mark[a[i]] = true;
      |         ^~~~
bank.cpp:4:5: error: expected declaration before '}' token
    4 |     }
      |     ^
bank.cpp:6:5: error: expected unqualified-id before 'for'
    6 |     for (int i = 1; i <= m; i++) {
      |     ^~~
bank.cpp:6:21: error: 'i' does not name a type
    6 |     for (int i = 1; i <= m; i++) {
      |                     ^
bank.cpp:6:29: error: 'i' does not name a type
    6 |     for (int i = 1; i <= m; i++) {
      |                             ^
bank.cpp:10:5: error: expected unqualified-id before 'for'
   10 |     for (int s = 0; s < (1 << n); s++) {
      |     ^~~
bank.cpp:10:31: error: 'n' was not declared in this scope
   10 |     for (int s = 0; s < (1 << n); s++) {
      |                               ^
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:31: error: 'n' was not declared in this scope
bank.cpp:10:21: error: 's' does not name a type
   10 |     for (int s = 0; s < (1 << n); s++) {
      |                     ^
bank.cpp:10:35: error: 's' does not name a type
   10 |     for (int s = 0; s < (1 << n); s++) {
      |                                   ^
bank.cpp:22:11: error: expected constructor, destructor, or type conversion before '(' token
   22 |     memset(dp, false, sizeof dp);
      |           ^
bank.cpp:23:5: error: 'dp' does not name a type
   23 |     dp[1][0] = true;
      |     ^~
bank.cpp:24:5: error: expected unqualified-id before 'for'
   24 |     for (int i = 1; i < n; i++) {
      |     ^~~
bank.cpp:24:25: error: 'n' was not declared in this scope
   24 |     for (int i = 1; i < n; i++) {
      |                         ^
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:25: error: 'n' was not declared in this scope
bank.cpp:24:21: error: 'i' does not name a type
   24 |     for (int i = 1; i < n; i++) {
      |                     ^
bank.cpp:24:28: error: 'i' does not name a type
   24 |     for (int i = 1; i < n; i++) {
      |                            ^
bank.cpp:35:5: error: 'cout' does not name a type
   35 |     cout << (*max_element(dp[n], dp[n] + 1) == true ? "YES" : "NO") << '\n';
      |     ^~~~
bank.cpp:36:1: error: expected declaration before '}' token
   36 | }
      | ^
bank.cpp: In function 'int main()':
bank.cpp:45:5: error: 'ios_base' has not been declared
   45 |     ios_base::sync_with_stdio (false);
      |     ^~~~~~~~
bank.cpp:46:5: error: 'cin' was not declared in this scope
   46 |     cin.tie (0); cout.tie (0);
      |     ^~~
bank.cpp:46:18: error: 'cout' was not declared in this scope
   46 |     cin.tie (0); cout.tie (0);
      |                  ^~~~
bank.cpp:59:20: error: 'runcase' was not declared in this scope
   59 |     while (test--) runcase(test);
      |                    ^~~~~~~