#include #include #include #include #include #include int matchings(const std::string& line, int ws = 10, int ns = 25) { int matchings{}; std::istringstream in{line}; int a; std::string skip; in >> skip >> skip; std::vector winning(ws); for (int w = 0; w < ws; ++w) { in >> a; winning.push_back(a); } in >> skip; for (int n = 0; n < ns; ++n) { in >> a; if (std::any_of(winning.cbegin(), winning.cend(), [a](int w){ return w == a; })) { ++matchings; } } return matchings; } int main(void) { int answer{}; std::vector cards; std::ifstream input{ "resources/input.txt" }; if (input.is_open()) { std::string line; while (not std::getline(input,line).eof()) { cards.push_back(matchings(line)); } } input.close(); for (int m : cards) { answer += static_cast(std::pow(2, m - 1)); } std::cout << answer << std::endl; return 0; }