Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- const int N = 2000;
- bitset<N> b[N], y[N];
- void solve() {
- int n;
- cin >> n;
- vector<string> g(n);
- for (int i = 0; i < n; i++) {
- cin >> g[i];
- for (int j = 0; j < n; j++) {
- if (i == j) continue;
- if (g[i][j] == 'B') {
- b[i].set(j);
- } else {
- y[i].set(j);
- }
- }
- }
- vector<ll> cnt(2);
- for (int i = 0; i < n; i++) {
- for (int j = i + 1; j < n; j++) {
- int kek = 0;
- if (g[i][j] == 'B') {
- kek = (y[i] & y[j]).count();
- } else {
- kek = (b[i] & b[j]).count();
- }
- cnt[0] += kek * (kek - 1) / 2;
- cnt[1] += (y[i] & b[j]).count() * (b[i] & y[j]).count();
- }
- }
- cout << cnt[1] / 2 - cnt[0] << endl;
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- int T = 1;
- // cin >> T;
- for (int tc = 1; tc <= T; tc++) {
- // cout << "Case #" << tc << ": ";
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement