QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#625113 | #7900. Gifts from Knowledge | Zeoy# | RE | 0ms | 3620kb | C++20 | 1.9kb | 2024-10-09 17:30:10 | 2024-10-09 17:30:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define endl "\n"
const int N = 1e6 + 10;
const ll inf = 1ll << 60, mod = 1e9 + 7;
int n, m;
vector<array<string, 2>> a(n + 10);
ll ksm(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1) res = res * a % mod;
b >>= 1;
a = a * a % mod;
}
return res;
}
int dfs(int pos, string x) {
//cout <<pos << " " << x << " " << a[pos][0] << " " << a[pos][1] << endl;
if(pos > n) return 1;
string tmp = x;
int res = 0;
int flag = 1;
for(int j = 0; j < m; j++) {
if(a[pos][0][j] == '1' && x[j] == '1') {
flag = 0;
break;
}
}
if(flag) {
for(int j = 0; j < m; j++) {
if(a[pos][0][j] == '1') {
tmp[j] = '1';
}
}
res += dfs(pos + 1, tmp);
}
tmp = x;
flag = 1;
for(int j = 0; j < m; j++) {
if(a[pos][1][j] == '1' && x[j] == '1') {
flag = 0;
break;
}
}
if(flag) {
for(int j = 0; j < m; j++) {
if(a[pos][1][j] == '1') {
tmp[j] = '1';
}
}
res += dfs(pos + 1, tmp);
}
return res % mod;
}
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> a[i][0];
a[i][1] = a[i][0];
reverse(a[i][1].begin(), a[i][1].end());
}
string x;
for(int i = 1; i <= m; i++) {
x.push_back('0');
}
cout << dfs(1, x) << endl;;
}
/*
3
3 5
01100
10001
00010
2 1
1
1
2 3
001
001
1
3 3
100
010
001
1
4 5
01100
00011
10000
00000
1
2 3
010
010
1
3 6
000100
100010
000001
1
3 5
01000
11000
11000
*/
signed main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int _ = 1;
cin >> _;
while(_--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
3 3 5 01100 10001 00010 2 1 1 1 2 3 001 001
output:
4 0 2
result:
ok 3 number(s): "4 0 2"
Test #2:
score: -100
Runtime Error
input:
15613 10 10 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 0000000000 15 8 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 1 5 00000 5 9 000000000 000000000 0000...