Submission #234936

# Submission time Handle Problem Language Result Execution time Memory
234936 2020-05-26T11:24:59 Z amoo_safar Snake Escaping (JOI18_snake_escaping) C++14
22 / 100
2000 ms 20184 KB
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 20;

int s1[(1 << Log) + 2];
int L, Q;
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> L >> Q;
	str s;
	cin >> s;
	for(int i = 0; i < (1 << L); i++) s1[i] = s[i] - '0';
	for(int l = 0; l < L; l++)
		for(int i = 0; i < (1 << L); i++)
			if(i >> l & 1) s1[i ^ (1 << l)] += s1[i];
	while(Q --){
		cin >> s;
		int mk0 = 0, mk1 = 0;
		for(int i = 0; i < L; i++){
			if(s[i] == '1') mk1 |= (1 << (L - 1 - i));
			if(s[i] == '0') mk0 |= (1 << (L - 1 - i));	
		}
		int res = s1[mk1];
		int sub = mk0;
		while(sub){
			res += (__builtin_popcount(sub) & 1 ? -1 : 1) * s1[sub + mk1];
			sub = mk0 & (sub - 1);
		}
		cout << res << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 230 ms 15280 KB Output is correct
12 Correct 462 ms 14940 KB Output is correct
13 Correct 370 ms 14072 KB Output is correct
14 Correct 317 ms 14072 KB Output is correct
15 Correct 253 ms 15228 KB Output is correct
16 Correct 289 ms 14328 KB Output is correct
17 Correct 344 ms 14388 KB Output is correct
18 Correct 192 ms 16120 KB Output is correct
19 Correct 346 ms 13176 KB Output is correct
20 Correct 243 ms 14712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 230 ms 15280 KB Output is correct
12 Correct 462 ms 14940 KB Output is correct
13 Correct 370 ms 14072 KB Output is correct
14 Correct 317 ms 14072 KB Output is correct
15 Correct 253 ms 15228 KB Output is correct
16 Correct 289 ms 14328 KB Output is correct
17 Correct 344 ms 14388 KB Output is correct
18 Correct 192 ms 16120 KB Output is correct
19 Correct 346 ms 13176 KB Output is correct
20 Correct 243 ms 14712 KB Output is correct
21 Correct 263 ms 18040 KB Output is correct
22 Correct 994 ms 18432 KB Output is correct
23 Correct 520 ms 17468 KB Output is correct
24 Correct 401 ms 17272 KB Output is correct
25 Correct 298 ms 19192 KB Output is correct
26 Correct 358 ms 17528 KB Output is correct
27 Correct 459 ms 17528 KB Output is correct
28 Correct 198 ms 20184 KB Output is correct
29 Correct 494 ms 16120 KB Output is correct
30 Correct 278 ms 18424 KB Output is correct
31 Correct 346 ms 18424 KB Output is correct
32 Correct 346 ms 18040 KB Output is correct
33 Correct 308 ms 17016 KB Output is correct
34 Correct 441 ms 17308 KB Output is correct
35 Correct 463 ms 17656 KB Output is correct
36 Correct 186 ms 16120 KB Output is correct
37 Correct 726 ms 18040 KB Output is correct
38 Correct 982 ms 16248 KB Output is correct
39 Correct 371 ms 17272 KB Output is correct
40 Correct 347 ms 17272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 49 ms 7964 KB Output is correct
12 Correct 693 ms 8156 KB Output is correct
13 Correct 280 ms 7836 KB Output is correct
14 Correct 85 ms 7836 KB Output is correct
15 Correct 48 ms 7964 KB Output is correct
16 Correct 75 ms 7832 KB Output is correct
17 Correct 124 ms 7832 KB Output is correct
18 Correct 43 ms 8088 KB Output is correct
19 Correct 253 ms 7704 KB Output is correct
20 Correct 47 ms 7960 KB Output is correct
21 Correct 61 ms 7964 KB Output is correct
22 Correct 71 ms 7836 KB Output is correct
23 Correct 51 ms 7832 KB Output is correct
24 Correct 119 ms 7812 KB Output is correct
25 Correct 113 ms 7832 KB Output is correct
26 Correct 39 ms 7704 KB Output is correct
27 Correct 248 ms 7912 KB Output is correct
28 Correct 686 ms 7704 KB Output is correct
29 Correct 71 ms 7832 KB Output is correct
30 Correct 81 ms 7836 KB Output is correct
31 Correct 1683 ms 8040 KB Output is correct
32 Correct 155 ms 7960 KB Output is correct
33 Correct 122 ms 7832 KB Output is correct
34 Execution timed out 2076 ms 6820 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 230 ms 15280 KB Output is correct
12 Correct 462 ms 14940 KB Output is correct
13 Correct 370 ms 14072 KB Output is correct
14 Correct 317 ms 14072 KB Output is correct
15 Correct 253 ms 15228 KB Output is correct
16 Correct 289 ms 14328 KB Output is correct
17 Correct 344 ms 14388 KB Output is correct
18 Correct 192 ms 16120 KB Output is correct
19 Correct 346 ms 13176 KB Output is correct
20 Correct 243 ms 14712 KB Output is correct
21 Correct 263 ms 18040 KB Output is correct
22 Correct 994 ms 18432 KB Output is correct
23 Correct 520 ms 17468 KB Output is correct
24 Correct 401 ms 17272 KB Output is correct
25 Correct 298 ms 19192 KB Output is correct
26 Correct 358 ms 17528 KB Output is correct
27 Correct 459 ms 17528 KB Output is correct
28 Correct 198 ms 20184 KB Output is correct
29 Correct 494 ms 16120 KB Output is correct
30 Correct 278 ms 18424 KB Output is correct
31 Correct 346 ms 18424 KB Output is correct
32 Correct 346 ms 18040 KB Output is correct
33 Correct 308 ms 17016 KB Output is correct
34 Correct 441 ms 17308 KB Output is correct
35 Correct 463 ms 17656 KB Output is correct
36 Correct 186 ms 16120 KB Output is correct
37 Correct 726 ms 18040 KB Output is correct
38 Correct 982 ms 16248 KB Output is correct
39 Correct 371 ms 17272 KB Output is correct
40 Correct 347 ms 17272 KB Output is correct
41 Correct 49 ms 7964 KB Output is correct
42 Correct 693 ms 8156 KB Output is correct
43 Correct 280 ms 7836 KB Output is correct
44 Correct 85 ms 7836 KB Output is correct
45 Correct 48 ms 7964 KB Output is correct
46 Correct 75 ms 7832 KB Output is correct
47 Correct 124 ms 7832 KB Output is correct
48 Correct 43 ms 8088 KB Output is correct
49 Correct 253 ms 7704 KB Output is correct
50 Correct 47 ms 7960 KB Output is correct
51 Correct 61 ms 7964 KB Output is correct
52 Correct 71 ms 7836 KB Output is correct
53 Correct 51 ms 7832 KB Output is correct
54 Correct 119 ms 7812 KB Output is correct
55 Correct 113 ms 7832 KB Output is correct
56 Correct 39 ms 7704 KB Output is correct
57 Correct 248 ms 7912 KB Output is correct
58 Correct 686 ms 7704 KB Output is correct
59 Correct 71 ms 7832 KB Output is correct
60 Correct 81 ms 7836 KB Output is correct
61 Correct 1683 ms 8040 KB Output is correct
62 Correct 155 ms 7960 KB Output is correct
63 Correct 122 ms 7832 KB Output is correct
64 Execution timed out 2076 ms 6820 KB Time limit exceeded
65 Halted 0 ms 0 KB -