- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitset.cpp
More file actions
Latest commit
38 lines (29 loc) · 584 Bytes
/
Copy pathbitset.cpp
File metadata and controls
38 lines (29 loc) · 584 Bytes
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
// BOJ 20501 Facebook
#include<bits/stdc++.h>
#defineszsize()
#definebkback()
#definefi first
#definese second
usingnamespacestd;
typedeflonglong ll;
typedef pair<int, int> pii;
intmain() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<bitset<2000>> v(n);
for (int i = 0; i < n; i++) {
string s;
cin >> s;
v[i] = bitset<2000>(s);
}
int q;
cin >> q;
while (q--) {
int x, y;
cin >> x >> y;
cout << (v[x - 1] & v[y - 1]).count() << '\n';
}
}