問題を理解できれば解ける。
lli bit2lli(string s) { reverse(s.begin(), s.end()); lli n = 0; for (int i = 0; i < (int)s.size(); ++i) { if (s[i] == '1') n |= 1LL << i; } return n; } class NetworkXOneTimePad { public: int crack(vector <string> P, vector <string> C) { vector<lli> v, u; for (int i = 0; i < (int)P.size(); ++i) { v.push_back(bit2lli(P[i])); } for (int i = 0; i < (int)C.size(); ++i) { u.push_back(bit2lli(C[i])); } sort(v.begin(), v.end()); sort(u.begin(), u.end()); set<lli> ret; for (int i = 0; i < (int)v.size(); ++i) { for (int j = 0; j < (int)u.size(); ++j) { bool flg = true; lli key = v[i] ^ u[j]; for (int k = 0; k < (int)u.size(); ++k) { flg = flg && binary_search(v.begin(), v.end(), key ^ u[k]); } if (flg) ret.insert(key); } } return ret.size(); } };