답안 #330181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330181 2020-11-24T06:06:57 Z casperwang Snake Escaping (JOI18_snake_escaping) C++14
12 / 100
2000 ms 5784 KB
#include <bits/stdc++.h>
using namespace std;

const int L = 20;
int n, q;
string str;
int a, b;
int val[1<<L];
int ans;

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> q;
  cin >> str;
  for (int i = 0; i < (1<<n); i++)
    val[i] = str[i] - '0';
  for (int i = 0; i < q; i++) {
    cin >> str;
    a = 0, b = 0;
    for (int j = 0; j < n; j++) {
      if (str[j] == '?')
        a = a*2, b = b*2+1;
      else if (str[j] == '0')
        a = a*2, b = b*2;
      else 
        a = a*2+1, b = b*2+1;
    }
    ans = 0;
    for (int j = 0; j < (1<<n); j++) {
      if ((a&j) == a && (b|j) == b) {
        ans += val[j];
      }
    }
    cout << ans << "\n";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 236 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 236 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 949 ms 4452 KB Output is correct
12 Correct 1222 ms 4204 KB Output is correct
13 Correct 1294 ms 3632 KB Output is correct
14 Correct 1243 ms 3564 KB Output is correct
15 Correct 1403 ms 4332 KB Output is correct
16 Correct 1223 ms 3692 KB Output is correct
17 Correct 1245 ms 3820 KB Output is correct
18 Correct 1202 ms 5612 KB Output is correct
19 Correct 959 ms 2540 KB Output is correct
20 Correct 946 ms 4204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 236 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 949 ms 4452 KB Output is correct
12 Correct 1222 ms 4204 KB Output is correct
13 Correct 1294 ms 3632 KB Output is correct
14 Correct 1243 ms 3564 KB Output is correct
15 Correct 1403 ms 4332 KB Output is correct
16 Correct 1223 ms 3692 KB Output is correct
17 Correct 1245 ms 3820 KB Output is correct
18 Correct 1202 ms 5612 KB Output is correct
19 Correct 959 ms 2540 KB Output is correct
20 Correct 946 ms 4204 KB Output is correct
21 Execution timed out 2073 ms 2564 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 236 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Execution timed out 2074 ms 5784 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 2 ms 236 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 949 ms 4452 KB Output is correct
12 Correct 1222 ms 4204 KB Output is correct
13 Correct 1294 ms 3632 KB Output is correct
14 Correct 1243 ms 3564 KB Output is correct
15 Correct 1403 ms 4332 KB Output is correct
16 Correct 1223 ms 3692 KB Output is correct
17 Correct 1245 ms 3820 KB Output is correct
18 Correct 1202 ms 5612 KB Output is correct
19 Correct 959 ms 2540 KB Output is correct
20 Correct 946 ms 4204 KB Output is correct
21 Execution timed out 2073 ms 2564 KB Time limit exceeded
22 Halted 0 ms 0 KB -