답안 #330173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330173 2020-11-24T05:51:41 Z Kevin_Zhang_TW Snake Escaping (JOI18_snake_escaping) C++17
5 / 100
2000 ms 4076 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;
		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;
		} 
		int res = 0;
		for (int i = 0;i < 1<<n;++i) {
			if ([&]() {
					for (int j = 0;j < n;++j) {
						if (com[j] == '0' && (i>>j&1)) return false;
						if (com[j] == '1' && (i>>j&1) == 0) return false;
					}
					return true;
					} () ) {
				DE(i);
				res += w[i] - '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:45:5: note: in expansion of macro 'DE'
   45 |     DE(i);
      |     ^~
snake_escaping.cpp:18:17: warning: statement has no effect [-Wunused-value]
   18 | #define DE(...) 0
      |                 ^
snake_escaping.cpp:50:3: note: in expansion of macro 'DE'
   50 |   DE(com, res);
      |   ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
8 Correct 16 ms 364 KB Output is correct
9 Correct 6 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
8 Correct 16 ms 364 KB Output is correct
9 Correct 6 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Execution timed out 2097 ms 4076 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
8 Correct 16 ms 364 KB Output is correct
9 Correct 6 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Execution timed out 2097 ms 4076 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
8 Correct 16 ms 364 KB Output is correct
9 Correct 6 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Execution timed out 2088 ms 2668 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 8 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
8 Correct 16 ms 364 KB Output is correct
9 Correct 6 ms 364 KB Output is correct
10 Correct 10 ms 364 KB Output is correct
11 Execution timed out 2097 ms 4076 KB Time limit exceeded
12 Halted 0 ms 0 KB -