Submission #943406

# Submission time Handle Problem Language Result Execution time Memory
943406 2024-03-11T13:04:13 Z guechotjrhh Snake Escaping (JOI18_snake_escaping) C++14
Compilation error
0 ms 0 KB
#include<iostream>
#include<string>
using namespace std;

#include<map>
#include<string>
using namespace std;
#define all(x) x.begin(),x.end()
string str;
int n;
map<string, int> mp;
string itos(int a, int l) {
	string res = "";
	for (int i = 0; i < l; i++) {
		res += '0' + (a & 1);
		a >>= 1;
	}
	reverse(all(res));
	return res;
}
void init(int N, int Q, string S) {
	n = N;
	str = S;
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < (1 << n); j++) {
			string s = itos(i, n);
			for (int w = 0; w < n; w++) if (j & (1 << w)) s[w] = '?';
			mp[s] += S[i]-'0';
		}
	}
}
int query(string A) {
	return mp[A];
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	init(N, Q, move(S));
	
	for (int i = 0; i < Q; i++) {
		string A;
		cin >> A;
		cout << query(move(A)) << endl;
	}
}

Compilation message

snake_escaping.cpp: In function 'std::string itos(int, int)':
snake_escaping.cpp:18:2: error: 'reverse' was not declared in this scope
   18 |  reverse(all(res));
      |  ^~~~~~~