| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1228021 | Amaarsaa | Snake Escaping (JOI18_snake_escaping) | C++20 | 2093 ms | 4336 KiB |
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
string cost;
string str;
ll dfs(ll ind, ll val, ll add) {
if ( add == 0) {
return (cost[val] - '0');
}
ll cnt = 0;
if ( str[ind] == '1' || str[ind] == '?') {
cnt += dfs(ind + 1, val + add, add/2);
}
if ( str[ind] == '0' || str[ind] == '?') {
cnt += dfs(ind + 1, val , add/2);
}
return cnt;
}
int main() {
ll n, m, r, x, q, y, i, j, ans, t;
cin >> n >> q;
cin >> cost;
while (q --) {
cin >> str;
r =1<<(n - 1);
cout << dfs(0, 0, r) << endl;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
