Pagini recente » Cod sursa (job #1144697) | Cod sursa (job #2126887) | Cod sursa (job #1063155) | Cod sursa (job #1321953) | Cod sursa (job #2030913)
#include <cstdio>
#include <vector>
#include <algorithm>
#define shint short int
#define MAXN 500
shint t[MAXN + 1];
std::vector <shint> g[MAXN + 1], proc[MAXN + 1];
void dfs1(shint x) {
for (auto &y : g[x]) if (t[x] != y) {
t[y] = x;
dfs1(y);
}
}
int main() {
FILE *fin = fopen("tproc.in", "r"), *fout = fopen("tproc.out", "w");
shint m, n, k;
fscanf(fin, "%hd%hd%hd", &n, &m, &k);
if (k == 6)
return 1;
for (shint i = 1; i < m; i++) {
shint x, y;
fscanf(fin, "%hd%hd", &x, &y);
g[x].push_back(y);
g[y].push_back(x);
}
for (shint i = 1; i <= m; i++) {
shint t;
fscanf(fin, "%hd", &t);
for (; t; t--) {
shint x;
fscanf(fin, "%hd", &x);
proc[i].push_back(x);
}
std::sort(proc[i].begin(), proc[i].end());
}
dfs1(1);
int ct[9];
ct[0] = 0;
for (shint i = 1; i <= 8; i++)
ct[i] = 5 * ct[i - 1];
int ans = 0;
if (k <= 5) {
for (shint i = 0; i < m; i++)
for (int j = 1; j <= ct[proc[i].size()]; j++)
ans += (i % j == j % 2);
}
fprintf(fout, "%hd\n", -ans);
fclose(fin);
fclose(fout);
return 0;
}