Submission #208825

# Submission time Handle Problem Language Result Execution time Memory
208825 2020-03-12T09:02:43 Z Siberian Snake Escaping (JOI18_snake_escaping) C++14
0 / 100
7 ms 376 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

int n, q;
string s;

void read() {
	cin >> n >> q;
	cin >> s;
}

pair<int, int> get_mask() {
	string s;
	cin >> s;
	int mask = 0;
	int must = 0;
	for (int i = 0; i < n; i++) {
		mask *= 2;
		if (s[i] != '0') mask++;
		must *= 2;
		if (s[i] == '1') must++;
	}
	return {mask, must};
}

void build() {

}

bool check_submask(int mask, int submask) {
	return (mask & submask) == submask;
}

void solve() {
	auto x = get_mask();
	int mask = x.first, must = x.second;
	int ans = 0;
	//cout << "mask = " << mask << endl;
	for (int i = mask; i >= 0; i = (i - 1) & mask) {
		if (s[i] == '1' && check_submask(i, must)) ++ans;
		if (i == 0) break;
	}
	cout << ans << "\n";
}

void run() {
	build();
	while (q--) {
		solve();
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -