Submission #839687

#TimeUsernameProblemLanguageResultExecution timeMemory
839687mat_jurSnake Escaping (JOI18_snake_escaping)C++14
5 / 100
2065 ms14980 KiB
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto &o, pair<auto, auto> p) {o << "(" << p.first << ", " << p.second << ")"; return o;}
auto operator<<(auto &o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto e : x) o<<e<<", "; return o<<"}";}
#define debug(X) cerr << "["#X"]: " << X << '\n';
#else 
#define debug(X) ;
#endif
#define ll long long
#define all(v) (v).begin(), (v).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define ROF(i,r,l) for(int i=(r);i>=(l);--i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
#define fi first
#define se second
#define eb emplace_back

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int l, t;
	cin >> l >> t;
	int n = (1<<l);
	string val;
	cin >> val;
	REP(i, t) {
		string b;
		cin >> b;
		vector<int> q;
		int s = 0;
		REP(j, l) {
			if (b[j] == '?') q.eb(l-j-1);
			if (b[j] == '1') s += (1<<(l-j-1));
		}
		int res = 0;
		REP(bm, (1<<ssize(q))) {
			int x = s;
			REP(j, ssize(q)) {
				if (bm&(1<<j)) x += (1<<q[j]);
			}
			res += val[x]-'0';
		}
		cout << res << '\n';
	}
	
	return 0;
}

Compilation message (stderr)

snake_escaping.cpp: In function 'int main()':
snake_escaping.cpp:27:6: warning: unused variable 'n' [-Wunused-variable]
   27 |  int n = (1<<l);
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...