Submission #330179

# Submission time Handle Problem Language Result Execution time Memory
330179 2020-11-24T05:57:54 Z Kevin_Zhang_TW Snake Escaping (JOI18_snake_escaping) C++17
12 / 100
2000 ms 19180 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T>
bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> 
bool chmin(T &a, T b) { return b < a ? (a = b, true) : false; }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U>
void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T>
void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

const int MAX_N = 20;
int n, q;
char w[(1<<MAX_N) + 10], com[MAX_N << 1];
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> q >> w;
	for (int i = 0;i < q;++i) {
		cin >> com;
		int l = 0, r = (1<<n) - 1, sub = 0;
		reverse(com, com + n);
		for (int i = 0;i < n;++i) {
			if (com[i] == '0') r ^= 1<<i;
			if (com[i] == '1') l ^= 1<<i;
			if (com[i] == '?') sub |= 1<<i;
		} 
		int res = 0;
		for (int s = sub ; s ;(--s) &= sub) {
			res += w[l | s] - '0';
		}
		res += w[l] - '0';
		cout << res << '\n'; 
		DE(com, res);
	}
} 

Compilation message

snake_escaping.cpp: In function 'int32_t main()':
snake_escaping.cpp:18:17: warning: statement has no effect [-Wunused-value]
   18 | #define DE(...) 0
      |                 ^
snake_escaping.cpp:43:3: note: in expansion of macro 'DE'
   43 |   DE(com, res);
      |   ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 277 ms 11628 KB Output is correct
12 Correct 277 ms 14848 KB Output is correct
13 Correct 231 ms 14188 KB Output is correct
14 Correct 233 ms 14060 KB Output is correct
15 Correct 301 ms 15212 KB Output is correct
16 Correct 263 ms 14404 KB Output is correct
17 Correct 274 ms 14316 KB Output is correct
18 Correct 1373 ms 16288 KB Output is correct
19 Correct 229 ms 13096 KB Output is correct
20 Correct 316 ms 14828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 277 ms 11628 KB Output is correct
12 Correct 277 ms 14848 KB Output is correct
13 Correct 231 ms 14188 KB Output is correct
14 Correct 233 ms 14060 KB Output is correct
15 Correct 301 ms 15212 KB Output is correct
16 Correct 263 ms 14404 KB Output is correct
17 Correct 274 ms 14316 KB Output is correct
18 Correct 1373 ms 16288 KB Output is correct
19 Correct 229 ms 13096 KB Output is correct
20 Correct 316 ms 14828 KB Output is correct
21 Correct 429 ms 18056 KB Output is correct
22 Correct 455 ms 18292 KB Output is correct
23 Correct 275 ms 17388 KB Output is correct
24 Correct 275 ms 17260 KB Output is correct
25 Correct 543 ms 19180 KB Output is correct
26 Correct 319 ms 17644 KB Output is correct
27 Correct 315 ms 17516 KB Output is correct
28 Execution timed out 2068 ms 5056 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 87 ms 2412 KB Output is correct
12 Correct 228 ms 3948 KB Output is correct
13 Correct 22 ms 3564 KB Output is correct
14 Correct 35 ms 3692 KB Output is correct
15 Correct 535 ms 3820 KB Output is correct
16 Correct 41 ms 3692 KB Output is correct
17 Correct 42 ms 3692 KB Output is correct
18 Execution timed out 2088 ms 2668 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 277 ms 11628 KB Output is correct
12 Correct 277 ms 14848 KB Output is correct
13 Correct 231 ms 14188 KB Output is correct
14 Correct 233 ms 14060 KB Output is correct
15 Correct 301 ms 15212 KB Output is correct
16 Correct 263 ms 14404 KB Output is correct
17 Correct 274 ms 14316 KB Output is correct
18 Correct 1373 ms 16288 KB Output is correct
19 Correct 229 ms 13096 KB Output is correct
20 Correct 316 ms 14828 KB Output is correct
21 Correct 429 ms 18056 KB Output is correct
22 Correct 455 ms 18292 KB Output is correct
23 Correct 275 ms 17388 KB Output is correct
24 Correct 275 ms 17260 KB Output is correct
25 Correct 543 ms 19180 KB Output is correct
26 Correct 319 ms 17644 KB Output is correct
27 Correct 315 ms 17516 KB Output is correct
28 Execution timed out 2068 ms 5056 KB Time limit exceeded
29 Halted 0 ms 0 KB -