답안 #330190

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

const int L = 20;
int n, q;
string str;
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;
    int 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 = val[a];
    int t = a^b;
    for (int j = t; j; j=(j-1)&t) {
      ans += val[a|j];
    }
    cout << ans << "\n";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 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 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 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 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 272 ms 7156 KB Output is correct
12 Correct 303 ms 4716 KB Output is correct
13 Correct 246 ms 3948 KB Output is correct
14 Correct 248 ms 4204 KB Output is correct
15 Correct 317 ms 4972 KB Output is correct
16 Correct 277 ms 4204 KB Output is correct
17 Correct 282 ms 4076 KB Output is correct
18 Correct 1217 ms 6124 KB Output is correct
19 Correct 216 ms 2924 KB Output is correct
20 Correct 297 ms 4588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 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 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 272 ms 7156 KB Output is correct
12 Correct 303 ms 4716 KB Output is correct
13 Correct 246 ms 3948 KB Output is correct
14 Correct 248 ms 4204 KB Output is correct
15 Correct 317 ms 4972 KB Output is correct
16 Correct 277 ms 4204 KB Output is correct
17 Correct 282 ms 4076 KB Output is correct
18 Correct 1217 ms 6124 KB Output is correct
19 Correct 216 ms 2924 KB Output is correct
20 Correct 297 ms 4588 KB Output is correct
21 Correct 395 ms 5356 KB Output is correct
22 Correct 479 ms 5344 KB Output is correct
23 Correct 300 ms 4332 KB Output is correct
24 Correct 289 ms 4076 KB Output is correct
25 Correct 552 ms 6252 KB Output is correct
26 Correct 342 ms 4700 KB Output is correct
27 Correct 344 ms 4460 KB Output is correct
28 Execution timed out 2095 ms 3876 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 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 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 102 ms 7924 KB Output is correct
12 Correct 248 ms 8080 KB Output is correct
13 Correct 34 ms 7460 KB Output is correct
14 Correct 48 ms 7440 KB Output is correct
15 Correct 624 ms 7448 KB Output is correct
16 Correct 56 ms 7312 KB Output is correct
17 Correct 66 ms 7696 KB Output is correct
18 Execution timed out 2091 ms 7024 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 396 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 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 272 ms 7156 KB Output is correct
12 Correct 303 ms 4716 KB Output is correct
13 Correct 246 ms 3948 KB Output is correct
14 Correct 248 ms 4204 KB Output is correct
15 Correct 317 ms 4972 KB Output is correct
16 Correct 277 ms 4204 KB Output is correct
17 Correct 282 ms 4076 KB Output is correct
18 Correct 1217 ms 6124 KB Output is correct
19 Correct 216 ms 2924 KB Output is correct
20 Correct 297 ms 4588 KB Output is correct
21 Correct 395 ms 5356 KB Output is correct
22 Correct 479 ms 5344 KB Output is correct
23 Correct 300 ms 4332 KB Output is correct
24 Correct 289 ms 4076 KB Output is correct
25 Correct 552 ms 6252 KB Output is correct
26 Correct 342 ms 4700 KB Output is correct
27 Correct 344 ms 4460 KB Output is correct
28 Execution timed out 2095 ms 3876 KB Time limit exceeded
29 Halted 0 ms 0 KB -