-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkodlas-40p.cpp
More file actions
55 lines (43 loc) · 1.1 KB
/
kodlas-40p.cpp
File metadata and controls
55 lines (43 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define per(i, high) for (int i = high - 1; i >= 0; i--)
#define perr(i, high, low) for (int i = high - 1, i >= low; i++)
#define sz(container) ((int)container.size())
#define all(x) begin(x), end(x)
void fast() {
ios::sync_with_stdio(0);
cin.tie(0);
}
vector<string> plates;
ll n, m;
ll count(ll plate_nr, string mask) {
if (plate_nr == n) {
return mask.find('.') != string::npos;
}
ll total_count = 0;
for (ll offset = 0; offset < m; offset++) {
string new_mask;
for (ll i = 0; i < m; i++) {
if (mask[i] == '.' && plates[plate_nr][(i + offset) % m] == '.') {
new_mask.push_back('.');
} else {
new_mask.push_back('#');
}
}
total_count += count(plate_nr + 1, new_mask);
}
return total_count;
}
int main() {
fast();
cin >> n >> m;
plates.resize(n);
for (ll i = 0; i < n; i++) {
cin >> plates[i];
}
cout << count(0, string(m, '.')) << endl;
return 0;
}