#include #include #include #include #include #include #include const int maxn = 100010; const int maxm = 1000010; int n, m; int u, v, s, t; int p, k; int uu, vv; struct Edge { int u, v, s, t, c; Edge(int u, int v, int w, int t, int c): u(u), v(v), s(s), t(t), c(c) {} }; std::vector tab[maxn]; int main() { // std::ifstream fout("user_out"); // std::ifstream fans("answer"); // std::ifstream finp("input"); FILE *fout, *fans, *finp; fout = fopen("user_out", "r"); fans = fopen("answer", "r"); finp = fopen("input", "r"); std::string ansstr, outstr; char str[100]; fscanf(fans, "%s", str); ansstr = std::string(str); fscanf(fout, "%s", str); outstr = std::string(str); bool ansflag = (ansstr == std::string("NIE")); bool outflag = (outstr == std::string("NIE")); if(ansflag || outflag) { if(ansflag && outflag) { std::cerr << "1:Correct answers!" << std::endl; std::cout << 100 << std::endl; return 0; } else { std::cerr << "1:Wrong answers!" << std::endl; std::cout << 0 << std::endl; return 0; } } fscanf(finp, "%d %d", &n, &m); for(int i = 0; i < m; i++) { fscanf(finp, "%d %d %d %d", &u, &v, &s, &t); uu = std::min(u, v); vv = std::max(u, v); tab[uu].push_back(Edge(uu, vv, s, t, s)); } sscanf(outstr.c_str(), "%d", &p); if(p > 5 * m || p < 0) { std::cerr << "2:Wrong answers!" << std::endl; std::cout << 0 << std::endl; return 0; } while(p--) { fscanf(fout, "%d %d", &k, &s); if(s > n || s <= 0) { std::cerr << "3:Wrong answers!" << std::endl; std::cout << 0 << std::endl; return 0; } for(int i = 0; i < k; i++) { fscanf(fout, "%d", &t); if(t > n || t <= 0) { std::cerr << "4:Wrong answers!" << std::endl; std::cout << 0 << std::endl; return 0; } u = std::min(s, t); v = std::max(s, t); bool flag = false; for(int j = 0; j < tab[u].size(); j++) { if(tab[u][j].v == v) { flag = true; tab[u][j].c = (!tab[u][j].c); break; } } if(!flag) { std::cerr << u << " " << v<