// Optimal prefix (huffman) code for the uniform distribution with M elements // should not pass #include #include #include #include #include #include using namespace std; unsigned int log2(unsigned int n) { return 31 - __builtin_clz(n); } int main(void) { int N; cin >> N; int M; cin >> M; vector lines; for (int i = 0; i < M; ++i) { uint64_t line = 0; int num_stations; cin >> num_stations; for (int j = 0; j < num_stations; ++j) { int station; cin >> station; uint64_t station_mask = 1ULL << station; line |= station_mask; } lines.push_back(line); } sort(lines.begin(),lines.end()); for (int i = 1; i < M; i++) { if (lines[i] == lines[i-1]) { cout << "not possible" << endl; return 0; } } // length for the optimal prefix code for a uniform distribution with M elements int d = log2(M); // there are (2**(d+1)-M) at level d and (2M-2**(d+1)) at level d+1 cout << std::setprecision(15) << (d+2-(2<