Submission #956168

# Submission time Handle Problem Language Result Execution time Memory
956168 2024-04-01T08:38:44 Z samvar_0907 Snake Escaping (JOI18_snake_escaping) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
 
signed main(){
    int l, q;
    cin >> l >> q;
    string toxicities; 
    cin >> toxicities;

    while (q--){

        string s; 
        cin >> s;

        int ans = 0;

        for (int bm = 0; bm < (1 << l); bm++){
            bool add = true;
            for (int i = l - 1; i >= 0; i--){
                if (s[i] == '0' || s[i] == '1'){
                    int s_digit = s[i] - '0';
                    int bm_bit = (bm >> (l - i - 1)) & 1;
                    if (s_digit != bm_bit) {
                        add = false;
                        break;
                        }
                    }                
                }
            }
            if (add){
                ans += toxicities[bm]-'0';
            }   
        cout << ans;
        }
    return 0;
}

Compilation message

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:20:18: warning: variable 'add' set but not used [-Wunused-but-set-variable]
   20 |             bool add = true;
      |                  ^~~
snake_escaping.cpp:32:17: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   32 |             if (add){
      |                 ^~~
      |                 std::filesystem::perm_options::add
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from snake_escaping.cpp:1:
/usr/include/c++/10/bits/fs_fwd.h:202:7: note: 'std::filesystem::perm_options::add' declared here
  202 |       add = 0x2,
      |       ^~~
snake_escaping.cpp:33:35: error: 'bm' was not declared in this scope; did you mean 'tm'?
   33 |                 ans += toxicities[bm]-'0';
      |                                   ^~
      |                                   tm