이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (1 << 20) + 12, MOD = 998244353;
int n, q;
string s;
void test() {
cin >> n >> q;
cin >> s;
while(q--) {
string t;
cin >> t;
reverse(t.begin(), t.end());
int res = 0;
for(int i = 0; i < (1 << n); i++) {
bool ok = 1;
for(int j = 0; j < n; j++) {
if(t[j] == '?') continue;
int x = (t[j] - '0');
if(x != ((i >> j) & 1)) {
ok = 0;
break;
}
}
if(ok) {
res += (s[i] - '0');
}
}
cout << res << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
| # | 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... |