Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define NguyenDangQuan the_author
- #define my_heart love_you_to_the_moon_and_back
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define ld long double
- #define ull unsigned long long
- bool typetest;
- inline void fastIOfileinput()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- typetest = 0;
- }
- const int N = 1e5 + 5;
- int n, a[N], cnt[N];
- ll dp[17][257][257];
- int m, k;
- ll ans(0);
- void Read()
- {
- cin >> n >> m >> k;
- for (int i = 1; i <= n; ++i)
- {
- string s;
- cin >> s;
- for (int j = 0; j < m; ++j)
- a[i] |= (s[j] - '0') * (1 << j);
- }
- }
- void Solve()
- {
- for (int i = 1; i < (1 << 8); ++i)
- cnt[i] = __builtin_popcount(i);
- for (int i = 1; i <= n; ++i)
- {
- ll res = 0;
- int pref = a[i] >> 8,
- suff = a[i] & ((1 << 8) - 1);
- for (int j = 0; j < (1 << 8); ++j)
- if (cnt[suff ^ j] <= k)
- res += dp[k - cnt[suff ^ j]][pref][j];
- ans += res;
- for (int j = 0; j < (1 << 8); ++j)
- if (cnt[pref ^ j] <= k)
- ++dp[cnt[pref ^ j]][j][suff];
- //cout << i << ": " << res << "\n";
- }
- cout << ans;
- }
- int32_t main()
- {
- fastIOfileinput();
- if (typetest)
- {
- int t;
- cin >> t;
- while (t--)
- {
- Read();
- Solve();
- }
- }
- else
- {
- Read();
- Solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement