답안 #208823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208823 2020-03-12T08:54:47 Z Siberian Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
2000 ms 16376 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 = 0; i < (1 << n); i++) {
		ans += (check_submask(mask, i) && check_submask(i, must)) * (s[i] - '0');
	}
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 1720 ms 15224 KB Output is correct
12 Correct 1710 ms 14984 KB Output is correct
13 Correct 1681 ms 14268 KB Output is correct
14 Correct 1710 ms 14456 KB Output is correct
15 Correct 1749 ms 15252 KB Output is correct
16 Correct 1752 ms 14456 KB Output is correct
17 Correct 1735 ms 14496 KB Output is correct
18 Correct 1714 ms 16376 KB Output is correct
19 Correct 1660 ms 13304 KB Output is correct
20 Correct 1744 ms 14840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 1720 ms 15224 KB Output is correct
12 Correct 1710 ms 14984 KB Output is correct
13 Correct 1681 ms 14268 KB Output is correct
14 Correct 1710 ms 14456 KB Output is correct
15 Correct 1749 ms 15252 KB Output is correct
16 Correct 1752 ms 14456 KB Output is correct
17 Correct 1735 ms 14496 KB Output is correct
18 Correct 1714 ms 16376 KB Output is correct
19 Correct 1660 ms 13304 KB Output is correct
20 Correct 1744 ms 14840 KB Output is correct
21 Execution timed out 2062 ms 3804 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Execution timed out 2053 ms 3728 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 380 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 7 ms 376 KB Output is correct
8 Correct 7 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 376 KB Output is correct
11 Correct 1720 ms 15224 KB Output is correct
12 Correct 1710 ms 14984 KB Output is correct
13 Correct 1681 ms 14268 KB Output is correct
14 Correct 1710 ms 14456 KB Output is correct
15 Correct 1749 ms 15252 KB Output is correct
16 Correct 1752 ms 14456 KB Output is correct
17 Correct 1735 ms 14496 KB Output is correct
18 Correct 1714 ms 16376 KB Output is correct
19 Correct 1660 ms 13304 KB Output is correct
20 Correct 1744 ms 14840 KB Output is correct
21 Execution timed out 2062 ms 3804 KB Time limit exceeded
22 Halted 0 ms 0 KB -