답안 #888186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
888186 2023-12-16T09:55:22 Z Unforgettablepl Snake Escaping (JOI18_snake_escaping) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
const int INF = INT64_MAX;

int arr[1024];

int ask(string &a,int perm){
    int idx = 0;
    for(int x=0;x<a.size();x++){
        if(a[x]=='1')idx|=(1<<x);
        else if(a[x]=='?'){idx|=((perm&1)<<x);perm>>=1;}
    }
    return arr[idx];
}

int32_t main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int L,q;
    cin >> L >> q;
    for(int i=0;i<(1<<L);i++){
        char a;cin>>a;a-='0';
        arr[i]=a;
    }
    map<string,int> memo;
    for (int i = 0; i < q; i++) {
        string a;cin>>a;
        reverse(a.begin(), a.end());
        if(memo.contains(a)){cout<<memo[a]<<'\n';continue;}
        int n = count(a.begin(), a.end(),'?');
        int ans = 0;
        for(int perm = 0;perm<(1<<n);perm++){
            ans+=ask(a,perm);
        }
        cout << ans << '\n';
        memo[a]=ans;
    }
}

Compilation message

snake_escaping.cpp: In function 'long long int ask(std::string&, long long int)':
snake_escaping.cpp:11:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int x=0;x<a.size();x++){
      |                 ~^~~~~~~~~
snake_escaping.cpp: In function 'int32_t main()':
snake_escaping.cpp:31:17: error: 'class std::map<std::__cxx11::basic_string<char>, long long int>' has no member named 'contains'
   31 |         if(memo.contains(a)){cout<<memo[a]<<'\n';continue;}
      |                 ^~~~~~~~