problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int input;
vector<int> k(M);
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
cin >> k.at(i);
for (int j = 0; j < k.at(i); j++) {
cin >> input;
s.at(i).push_back(input);
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p.at(i);
int ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
int cnt = 0;
for (int i = 0; i < M; i++) {
int scnt = 0;
for (int j = 0; j < k.at(i); j++) {
if (bit & (1 << s.at(i).at(j)))
scnt++;
}
if (scnt % 2 == p.at(i))
cnt++;
}
if (cnt == M)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int input;
vector<int> k(M);
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
cin >> k.at(i);
for (int j = 0; j < k.at(i); j++) {
cin >> input;
s.at(i).push_back(input);
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p.at(i);
int ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
int cnt = 0;
for (int i = 0; i < M; i++) {
int scnt = 0;
for (int j = 0; j < k.at(i); j++) {
if (bit & (1 << s.at(i).at(j) - 1))
scnt++;
}
if (scnt % 2 == p.at(i))
cnt++;
}
if (cnt == M)
ans++;
}
cout << ans << endl;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 840,760 | 840,761 | u171046846 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) \
{ \
for (auto i : x) { \
cout << i << " "; \
} \
cout << endl; \
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
// bit全探索
ll N, M;
cin >> N >> M;
vector<int> S[M];
rep(i, M) {
ll k;
cin >> k;
vector<int> A(k);
rep(i, k) cin >> A[i];
rep(i, k)-- A[i];
S[i] = A;
}
vector<int> L(N);
rep(i, N) cin >> L[i];
ll ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
vector<int> cnt(M);
for (int i = 0; i < N; i++) {
if ((bit >> i) & 1) {
// i番目のスイッチがon // 0-indexed
for (int j = 0; j < M; j++) {
if (count(S[j].begin(), S[j].end(), i)) {
cnt[j] ^= 1;
}
}
}
}
ll temp = 0;
rep(i, M) {
if (L[i] == cnt[i])
temp++;
}
if (temp == M)
ans++;
}
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) \
{ \
for (auto i : x) { \
cout << i << " "; \
} \
cout << endl; \
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
// bit全探索
ll N, M;
cin >> N >> M;
vector<int> S[M];
rep(i, M) {
ll k;
cin >> k;
vector<int> A(k);
rep(i, k) cin >> A[i];
rep(i, k)-- A[i];
S[i] = A;
}
vector<int> L(M);
rep(i, M) cin >> L[i];
ll ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
vector<int> cnt(M);
for (int i = 0; i < N; i++) {
if ((bit >> i) & 1) {
// i番目のスイッチがon // 0-indexed
for (int j = 0; j < M; j++) {
if (count(S[j].begin(), S[j].end(), i)) {
cnt[j] ^= 1;
}
}
}
}
ll temp = 0;
rep(i, M) {
if (L[i] == cnt[i])
temp++;
}
if (temp == M)
ans++;
}
cout << ans << '\n';
return 0;
} | [
"identifier.change",
"call.arguments.change"
] | 840,780 | 840,781 | u600402037 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
/*for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
cout << s[i][j] << " ";
}
cout << endl;
}*/
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[m] = {0};
bool flag = true;
for (int i = 0; i < m; i++) {
if (bit >> i & 1) {
for (int j = 0; j < n; j++)
as[j] += s[i][j];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[m] = {0};
bool flag = true;
for (int i = 0; i < n; i++) {
if (bit >> i & 1) {
for (int j = 0; j < m; j++)
as[j] += s[j][i];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 840,784 | 840,785 | u873762144 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[n] = {0};
bool flag = true;
for (int i = 0; i < m; i++) {
if (bit >> i & 1) {
for (int j = 0; j < n; j++)
as[j] += s[i][j];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[m] = {0};
bool flag = true;
for (int i = 0; i < n; i++) {
if (bit >> i & 1) {
for (int j = 0; j < m; j++)
as[j] += s[j][i];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | [
"identifier.change",
"variable_declaration.array_dimensions.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 840,786 | 840,785 | u873762144 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
/*for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
cout << s[i][j] << " ";
}
cout << endl;
}*/
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[m] = {0};
bool flag = true;
for (int i = 0; i < m; i++) {
if (bit >> i & 1) {
for (int j = 0; j < n; j++)
as[j] += s[i][j];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
/*for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
cout << s[i][j] << " ";
}
cout << endl;
}*/
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[m] = {0};
bool flag = true;
for (int i = 0; i < n; i++) {
if (bit >> i & 1) {
for (int j = 0; j < m; j++)
as[j] += s[j][i];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 840,784 | 840,787 | u873762144 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[n] = {0};
bool flag = true;
for (int i = 0; i < m; i++) {
if (bit >> i & 1) {
for (int j = 0; j < n; j++)
as[j] += s[i][j];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k[10], s[10][10], p[10];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int x;
cin >> x;
s[i][x - 1]++;
}
}
/*for(int i=0; i<m; i++) {
for(int j=0; j<n; j++) {
cout << s[i][j] << " ";
}
cout << endl;
}*/
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int as[m] = {0};
bool flag = true;
for (int i = 0; i < n; i++) {
if (bit >> i & 1) {
for (int j = 0; j < m; j++)
as[j] += s[j][i];
}
}
for (int j = 0; j < m; j++)
if (as[j] % 2 != p[j])
flag = false;
if (flag)
ans++;
}
cout << ans << endl;
} | [
"identifier.change",
"variable_declaration.array_dimensions.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 840,786 | 840,787 | u873762144 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
void init() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int s[100][100];
int main() {
#ifdef LOCAL_PROJECT
freopen("in.txt", "r", stdin);
#endif
int n, m;
scanf("%d%d", &n, &m);
vector<int> kk;
for (int i = 0; i < n; i++) {
int k;
scanf("%d", &k);
kk.push_back(k);
for (int j = 0; j < k; j++) {
scanf("%d", &s[i][j]);
s[i][j]--;
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
scanf("%d", &p[i]);
}
ll cnt = 0;
for (int i = 0; i < (1 << n); i++) {
bool f = true;
for (int j = 0; j < n; j++) {
int res = 0;
for (int k = 0; k < kk[j]; k++) {
if ((i >> s[j][k]) & 1) {
res++;
}
}
res %= 2;
if (res != p[j])
f = false;
}
if (f)
cnt++;
}
printf("%lld", cnt);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
void init() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int s[100][100];
int main() {
#ifdef LOCAL_PROJECT
freopen("in.txt", "r", stdin);
#endif
int n, m;
scanf("%d%d", &n, &m);
vector<int> kk;
for (int i = 0; i < m; i++) {
int k;
scanf("%d", &k);
kk.push_back(k);
for (int j = 0; j < k; j++) {
scanf("%d", &s[i][j]);
s[i][j]--;
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
scanf("%d", &p[i]);
}
ll cnt = 0;
for (int i = 0; i < (1 << n); i++) {
bool f = true;
for (int j = 0; j < m; j++) {
int res = 0;
for (int k = 0; k < kk[j]; k++) {
if ((i >> s[j][k]) & 1) {
res++;
}
}
res %= 2;
if (res != p[j])
f = false;
}
if (f)
cnt++;
}
printf("%lld", cnt);
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 840,790 | 840,791 | u018679195 | cpp |
p03031 | #include <stdio.h>
int n, m, ans, k[13][12], p[12];
int mj(int x) {
int a[12], i, j, s;
bool f = 0;
for (i = m; i >= 1; i--) {
a[i] = x % 2;
x /= 2;
}
for (i = 1; i <= m; i++) {
s = 0;
for (j = 1; j <= k[i][0]; j++) {
s += a[k[i][j]];
}
s %= 2;
if (s != p[i]) {
f = 1;
break;
}
}
if (f == 1)
return 0;
else {
return 1;
}
}
int main() {
int i, j, u;
scanf("%d%d", &n, &m);
for (i = 1; i <= m; i++) {
scanf("%d", &k[i][0]);
for (j = 1; j <= k[i][0]; j++) {
scanf("%d", &k[i][j]);
}
}
for (i = 1; i <= m; i++) {
scanf("%d", &p[i]);
}
ans = 0;
u = 1;
for (i = 1; i <= m; i++)
u *= 2;
u--;
for (i = 0; i <= u; i++) {
if (mj(i)) {
ans++;
}
}
printf("%d\n", ans);
}
| #include <stdio.h>
int n, m, ans, k[13][12], p[12];
int mj(int x) {
int a[12], i, j, s;
bool f = 0;
for (i = n; i >= 1; i--) {
a[i] = x % 2;
x /= 2;
}
for (i = 1; i <= m; i++) {
s = 0;
for (j = 1; j <= k[i][0]; j++) {
s += a[k[i][j]];
}
s %= 2;
if (s != p[i]) {
f = 1;
break;
}
}
if (f == 1)
return 0;
else {
return 1;
}
}
int main() {
int i, j, u;
scanf("%d%d", &n, &m);
for (i = 1; i <= m; i++) {
scanf("%d", &k[i][0]);
for (j = 1; j <= k[i][0]; j++) {
scanf("%d", &k[i][j]);
}
}
for (i = 1; i <= m; i++) {
scanf("%d", &p[i]);
}
ans = 0;
u = 1;
for (i = 1; i <= n; i++)
u *= 2;
u--;
for (i = 0; i <= u; i++) {
if (mj(i)) {
ans++;
}
}
printf("%d\n", ans);
}
| [
"assignment.value.change",
"identifier.change",
"control_flow.loop.for.initializer.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 840,792 | 840,793 | u018679195 | cpp |
p03031 |
// auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2,
// 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
// bitset<ビット数> s(tmp);
// // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
// // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
// const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG / GCC環境下で[] による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() // sort(all(vec)); ,reverse(all(vec));etc
int main() {
int n, m;
cin >> n >> m;
vector<bitset<10>> vec(m);
vector<int> k(m);
vector<int> p(m);
rep(i, m) {
cin >> k.at(i);
rep(j, k.at(i)) {
int pos;
cin >> pos;
vec.at(i).set(pos, 1);
}
}
// cout<<vec.at(0)<<vec.at(1)<<endl;
rep(i, m) { cin >> p.at(i); }
int sum = 0;
for (int tmp = 0; tmp < (1 << n); tmp++) {
bitset<10> cnt(tmp);
rep(i, m) {
int match = (vec.at(i) & cnt).count();
if ((match % 2) != p.at(i)) {
goto SKIP;
}
}
sum += 1;
// cout<<"hit:"<<cnt<<endl;
SKIP:
int alias;
// cout<<cnt<<endl;
}
cout << sum << endl;
}
|
// auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2,
// 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
// bitset<ビット数> s(tmp);
// // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
// // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
// const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG / GCC環境下で[] による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() // sort(all(vec)); ,reverse(all(vec));etc
int main() {
int n, m;
cin >> n >> m;
vector<bitset<10>> vec(m);
vector<int> k(m);
vector<int> p(m);
rep(i, m) {
cin >> k.at(i);
rep(j, k.at(i)) {
int pos;
cin >> pos;
vec.at(i).set(pos - 1, 1);
}
}
// cout<<vec.at(0)<<vec.at(1)<<endl;
rep(i, m) { cin >> p.at(i); }
int sum = 0;
for (int tmp = 0; tmp < (1 << n); tmp++) {
bitset<10> cnt(tmp);
rep(i, m) {
int match = (vec.at(i) & cnt).count();
if ((match % 2) != p.at(i)) {
goto SKIP;
}
}
sum += 1;
// cout<<"hit:"<<cnt<<endl;
SKIP:
int alias;
// cout<<cnt<<endl;
}
cout << sum << endl;
}
| [
"expression.operation.binary.add"
] | 840,800 | 840,801 | u340121166 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> connection(M, vector<int>(0));
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
connection[i].push_back(s);
}
}
vector<int> amari(M);
for (int i = 0; i < M; i++)
cin >> amari[i];
int ans = 0;
for (int i = 0; i < (1 << N); i++) {
bool all_bright = true;
for (int j = 0; j < M; j++) {
int on_switch_num = 0;
for (int k = 0; k < connection[j].size(); k++) {
if (i & (1 << connection[j][k]))
on_switch_num++;
}
if (on_switch_num % 2 != amari[j])
all_bright = false;
if (!all_bright)
break;
}
if (all_bright)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> connection(M, vector<int>(0));
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
s--;
connection[i].push_back(s);
}
}
vector<int> amari(M);
for (int i = 0; i < M; i++)
cin >> amari[i];
int ans = 0;
for (int i = 0; i < (1 << N); i++) {
bool all_bright = true;
for (int j = 0; j < M; j++) {
int on_switch_num = 0;
for (int k = 0; k < connection[j].size(); k++) {
if (i & (1 << connection[j][k]))
on_switch_num++;
}
if (on_switch_num % 2 != amari[j])
all_bright = false;
if (!all_bright)
break;
}
if (all_bright)
ans++;
}
cout << ans << endl;
} | [
"expression.unary.arithmetic.add"
] | 840,813 | 840,814 | u597584295 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define int long long
bool isprime(int n) {
double rootn = sqrt(n);
if (n < 2) {
return false;
} else if (n == 2) {
return true;
} else if (n % 2 == 0) {
return false;
} else {
for (int i = 3; i <= rootn; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int> &primes, vector<bool> &is_prime) {
primes = {};
is_prime = {};
for (int i = 0; i <= N; i++) {
is_prime.push_back(true);
}
primes.push_back(2);
for (int j = 4; j <= N; j += 2) {
is_prime[j] = false;
}
int i;
for (i = 3; i * i <= N; i += 2) {
if (!is_prime[i])
continue;
primes.push_back(i);
for (int j = 2 * i; j <= N; j += i) {
is_prime[j] = false;
}
}
for (; i <= N; i += 2) {
if (is_prime[i]) {
primes.push_back(i);
}
}
}
signed main() {
// cout << fixed << setprecision(10) << flush;
int n, m;
cin >> n >> m;
vector<vector<int>> s(m + 1, vector<int>());
vector<int> k(m + 1);
for (int i = 1; i <= m; i++) {
cin >> k[i];
for (int j = 1; j <= k[i]; j++) {
int sij;
cin >> sij;
s[i].push_back(sij);
}
}
vector<int> p(m);
for (int i = 1; i <= m; i++) {
cin >> p[i];
}
vector<int> sw(n + 1, 0);
int n_on = 0;
for (int i = 0; i < (1 << n); i++) {
int tempi = i;
for (int j = 1; j <= n; j++) {
sw[j] = tempi % 2;
tempi /= 2;
}
int l;
for (l = 1; l <= m; l++) {
// 電球 l について
int cond = 0;
for (int u = 0; u < k[l]; u++) {
cond += (sw[s[l][u]] == 1);
}
if (cond % 2 != p[l]) {
break;
}
}
if (l == m + 1) {
// 全部 on だった
n_on++;
}
}
cout << n_on << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
bool isprime(int n) {
double rootn = sqrt(n);
if (n < 2) {
return false;
} else if (n == 2) {
return true;
} else if (n % 2 == 0) {
return false;
} else {
for (int i = 3; i <= rootn; i += 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int> &primes, vector<bool> &is_prime) {
primes = {};
is_prime = {};
for (int i = 0; i <= N; i++) {
is_prime.push_back(true);
}
primes.push_back(2);
for (int j = 4; j <= N; j += 2) {
is_prime[j] = false;
}
int i;
for (i = 3; i * i <= N; i += 2) {
if (!is_prime[i])
continue;
primes.push_back(i);
for (int j = 2 * i; j <= N; j += i) {
is_prime[j] = false;
}
}
for (; i <= N; i += 2) {
if (is_prime[i]) {
primes.push_back(i);
}
}
}
signed main() {
// cout << fixed << setprecision(10) << flush;
int n, m;
cin >> n >> m;
vector<vector<int>> s(m + 1, vector<int>());
vector<int> k(m + 1);
for (int i = 1; i <= m; i++) {
cin >> k[i];
for (int j = 1; j <= k[i]; j++) {
int sij;
cin >> sij;
s[i].push_back(sij);
}
}
vector<int> p(m + 1);
for (int i = 1; i <= m; i++) {
cin >> p[i];
}
vector<int> sw(n + 1, 0);
int n_on = 0;
for (int i = 0; i < (1 << n); i++) {
int tempi = i;
for (int j = 1; j <= n; j++) {
sw[j] = tempi % 2;
tempi /= 2;
}
int l;
for (l = 1; l <= m; l++) {
// 電球 l について
int cond = 0;
for (int u = 0; u < k[l]; u++) {
cond += (sw[s[l][u]] == 1);
}
if (cond % 2 != p[l]) {
break;
}
}
if (l == m + 1) {
// 全部 on だった
n_on++;
}
}
cout << n_on << endl;
return 0;
} | [
"assignment.change"
] | 840,821 | 840,822 | u658401995 | cpp |
p03031 | // https://atcoder.jp/contests/abc128/tasks/abc128_c
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<string, int> PSI;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }
int n, m;
vector<unsigned int> vi; // 入力値のビット列(例:1, 3なら101)
vector<unsigned int> vp; // ビット列の総和の偶数・奇数
bool check(unsigned int arg) {
unsigned int ans = 0, cnt;
bool flag = true;
// スイッチが未接続なら点灯しない
// if (arg == 0)
// return false;
// 全部のスイッチで点灯するか確認
REP(i, m) {
cnt = __builtin_popcount(vi[i] & arg);
if (cnt & 1 != vp[i]) {
flag = false;
break;
}
}
return flag;
}
int dfs(int idx, unsigned int arg) {
if (idx == n) {
return check(arg);
}
int ans = dfs(idx + 1, arg);
arg |= (1 << idx); // nビット目を1にする
ans += dfs(idx + 1, arg);
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
vi.resize(m);
vp.resize(m);
REP(i, m) {
int k, l;
cin >> k;
// 入力値をビット列にする(例:1, 3なら101)
unsigned int t = 0;
REP(j, k) {
cin >> l;
t |= (1 << (--l));
}
vi[i] = t;
}
REP(i, m) { cin >> vp[i]; }
cout << dfs(0, 0) << endl;
return 0;
} | // https://atcoder.jp/contests/abc128/tasks/abc128_c
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<string, int> PSI;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }
int n, m;
vector<unsigned int> vi; // 入力値のビット列(例:1, 3なら101)
vector<unsigned int> vp; // ビット列の総和の偶数・奇数
bool check(unsigned int arg) {
int ans = 0, cnt;
bool flag = true;
// スイッチが未接続なら点灯しない
// if (arg == 0)
// return false;
// 全部のスイッチで点灯するか確認
REP(i, m) {
cnt = __builtin_popcount(vi[i] & arg);
if (cnt % 2 != vp[i]) {
flag = false;
break;
}
}
return flag;
}
int dfs(int idx, unsigned int arg) {
if (idx == n) {
return check(arg);
}
int ans = dfs(idx + 1, arg);
arg |= (1 << idx); // nビット目を1にする
ans += dfs(idx + 1, arg);
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
vi.resize(m);
vp.resize(m);
REP(i, m) {
int k, l;
cin >> k;
// 入力値をビット列にする(例:1, 3なら101)
unsigned int t = 0;
REP(j, k) {
cin >> l;
t |= (1 << (--l));
}
vi[i] = t;
}
REP(i, m) { cin >> vp[i]; }
cout << dfs(0, 0) << endl;
return 0;
}
| [
"variable_declaration.type.narrow.change"
] | 840,824 | 840,825 | u858107870 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline void dump(vector<T> v) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
template <class T> inline void dump(vector<pair<T, T>> v) {
for (auto &p : v)
cerr << p.first << " " << p.second << endl;
}
template <class T> inline void dump(vector<vector<T>> vv) {
for (auto &v : vv) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<bool>> con(
n, vector<bool>(
m, false)); // n 番目のスイッチが m 番目の電球に繋がっているか?
rep(i, m) {
int k;
cin >> k;
rep(i, k) {
int s;
cin >> s;
s--;
con[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
auto f = [&](const vector<int> &n_on) {
rep(i, m) {
if (p[i] != (n_on[i] % 2))
return false;
}
return true;
};
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> n_on(m, 0); // 各電球の on の数
rep(i, n) {
if ((bit >> i) & 1) {
// i 番目のスイッチが on になっている
rep(j, m) {
if (con[i][j])
n_on[j]++;
}
}
}
if (f(n_on))
ans++;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline void dump(vector<T> v) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
template <class T> inline void dump(vector<pair<T, T>> v) {
for (auto &p : v)
cerr << p.first << " " << p.second << endl;
}
template <class T> inline void dump(vector<vector<T>> vv) {
for (auto &v : vv) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<bool>> con(
n, vector<bool>(
m, false)); // n 番目のスイッチが m 番目の電球に繋がっているか?
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
con[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
auto f = [&](const vector<int> &n_on) {
rep(i, m) {
if (p[i] != (n_on[i] % 2))
return false;
}
return true;
};
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> n_on(m, 0); // 各電球の on の数
rep(i, n) {
if ((bit >> i) & 1) {
// i 番目のスイッチが on になっている
rep(j, m) {
if (con[i][j])
n_on[j]++;
}
}
}
if (f(n_on))
ans++;
}
cout << ans << endl;
return 0;
}
| [] | 840,832 | 840,833 | u733814820 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline void dump(vector<T> v) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
template <class T> inline void dump(vector<pair<T, T>> v) {
for (auto &p : v)
cerr << p.first << " " << p.second << endl;
}
template <class T> inline void dump(vector<vector<T>> vv) {
for (auto &v : vv) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<bool>> con(
n, vector<bool>(
m, false)); // n 番目のスイッチが m 番目の電球に繋がっているか?
rep(i, m) {
int k;
cin >> k;
rep(i, k) {
int s;
cin >> s;
s--;
con[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
auto f = [&](const vector<int> &n_on) {
rep(i, m) {
if (p[i] != n_on[i] % 2)
return false;
}
return true;
};
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> n_on(m, 0); // 各電球の on の数
rep(i, n) {
if ((bit >> i) & 1) {
// i 番目のスイッチが on になっている
rep(j, m) {
if (con[i][j])
n_on[j]++;
}
}
}
if (f(n_on))
ans++;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline void dump(vector<T> v) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
template <class T> inline void dump(vector<pair<T, T>> v) {
for (auto &p : v)
cerr << p.first << " " << p.second << endl;
}
template <class T> inline void dump(vector<vector<T>> vv) {
for (auto &v : vv) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<bool>> con(
n, vector<bool>(
m, false)); // n 番目のスイッチが m 番目の電球に繋がっているか?
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
con[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
auto f = [&](const vector<int> &n_on) {
rep(i, m) {
if (p[i] != (n_on[i] % 2))
return false;
}
return true;
};
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> n_on(m, 0); // 各電球の on の数
rep(i, n) {
if ((bit >> i) & 1) {
// i 番目のスイッチが on になっている
rep(j, m) {
if (con[i][j])
n_on[j]++;
}
}
}
if (f(n_on))
ans++;
}
cout << ans << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change"
] | 840,834 | 840,833 | u733814820 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline void dump(vector<T> v) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
template <class T> inline void dump(vector<pair<T, T>> v) {
for (auto &p : v)
cerr << p.first << " " << p.second << endl;
}
template <class T> inline void dump(vector<vector<T>> vv) {
for (auto &v : vv) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<bool>> con(
n, vector<bool>(
m, false)); // n 番目のスイッチが m 番目の電球に繋がっているか?
rep(i, m) {
int k;
cin >> k;
rep(i, k) {
int s;
cin >> s;
s--;
con[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
auto f = [&](const vector<int> &n_on) {
rep(i, m) {
if (p[i] != n_on[i] % 2)
return false;
}
return true;
};
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> n_on(m, 0); // 各電球の on の数
rep(i, n) {
if ((bit >> i) & 1) {
// i 番目のスイッチが on になっている
rep(j, m) {
if (con[i][j])
n_on[j]++;
}
}
}
if (f(n_on))
ans++;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;
using ll = long long;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline void dump(vector<T> v) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
template <class T> inline void dump(vector<pair<T, T>> v) {
for (auto &p : v)
cerr << p.first << " " << p.second << endl;
}
template <class T> inline void dump(vector<vector<T>> vv) {
for (auto &v : vv) {
for (auto &x : v)
cerr << x << " ";
cerr << endl;
}
}
constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 60;
constexpr double eps = (1e-9);
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<vector<bool>> con(
n, vector<bool>(
m, false)); // n 番目のスイッチが m 番目の電球に繋がっているか?
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
con[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
auto f = [&](const vector<int> &n_on) {
rep(i, m) {
if (p[i] != (n_on[i] % 2))
return false;
}
return true;
};
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> n_on(m, 0); // 各電球の on の数
rep(i, n) {
if ((bit >> i) & 1) {
// i 番目のスイッチが on になっている
rep(j, m) {
if (con[i][j])
n_on[j]++;
}
}
}
if (f(n_on))
ans++;
}
cout << ans << endl;
return 0;
}
| [
"control_flow.branch.if.condition.change",
"variable_declaration.type.change"
] | 840,835 | 840,833 | u733814820 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define itn int
#define fi first
#define se second
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
int k, s[20][20], p[20], a;
int ans = 0;
int r[20] = {};
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
cin >> a;
s[i][a - 1] = 1;
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
for (int i = 0; i < (1 << n); i++) {
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
for (int k = 0; k < m; k++) {
if (s[k][j] == 1)
r[k]++;
}
}
}
bool f = true;
for (int j = 0; j < m; j++) {
if (r[j] % 2 != p[j]) {
f = false;
}
r[j] = 0;
}
if (f)
ans++;
}
cout << ans << "\n";
}
| #include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define itn int
#define fi first
#define se second
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m;
int k, s[20][20] = {}, p[20], a;
int ans = 0;
int r[20] = {};
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
cin >> a;
s[i][a - 1] = 1;
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
for (int i = 0; i < (1 << n); i++) {
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
for (int k = 0; k < m; k++) {
if (s[k][j] == 1)
r[k]++;
}
}
}
bool f = true;
for (int j = 0; j < m; j++) {
if (r[j] % 2 != p[j]) {
f = false;
}
r[j] = 0;
}
if (f)
ans++;
}
cout << ans << "\n";
}
| [
"variable_declaration.value.change"
] | 840,836 | 840,837 | u831161882 | cpp |
p03031 | #pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------テンプレート------------------ */
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a <= b) {
a = b;
return true;
}
return false;
}
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) { //階乗
if (i == 0)
return 1;
return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) { //最大公約数
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { //最小公倍数
return a * b / gcd(a, b);
}
int keta(ll n) { //桁数を求める
if (n == 0)
return 1;
int count = 0;
while (n != 0) {
n /= 10;
count++;
}
return count;
}
ll ketasum(ll n) { //各桁の和
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
int n, m;
cin >> n >> m;
vvi s(m);
rep(i, n) {
int k;
cin >> k;
rep(j, k) {
int a;
cin >> a;
a--;
s[k].pb(a);
}
}
vi p(m);
rep(i, m) cin >> p[i];
int count = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < s[i].size(); j++) {
if (1 & (bit >> s[i][j])) {
cnt++;
}
}
if (cnt % 2 != p[i])
ok = false;
}
if (ok)
count++;
}
cout << count << endl;
return 0;
} | #pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------テンプレート------------------ */
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a <= b) {
a = b;
return true;
}
return false;
}
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) { //階乗
if (i == 0)
return 1;
return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) { //最大公約数
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { //最小公倍数
return a * b / gcd(a, b);
}
int keta(ll n) { //桁数を求める
if (n == 0)
return 1;
int count = 0;
while (n != 0) {
n /= 10;
count++;
}
return count;
}
ll ketasum(ll n) { //各桁の和
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
int n, m;
cin >> n >> m;
vvi s(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int a;
cin >> a;
a--;
s[i].pb(a);
}
}
vi p(m);
rep(i, m) cin >> p[i];
int count = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < s[i].size(); j++) {
if (1 & (bit >> s[i][j])) {
cnt++;
}
}
if (cnt % 2 != p[i])
ok = false;
}
if (ok)
count++;
}
cout << count << endl;
return 0;
} | [
"identifier.change",
"variable_access.subscript.index.change"
] | 840,847 | 840,848 | u608773191 | cpp |
p03031 | #pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------テンプレート------------------ */
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a <= b) {
a = b;
return true;
}
return false;
}
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) { //階乗
if (i == 0)
return 1;
return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) { //最大公約数
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { //最小公倍数
return a * b / gcd(a, b);
}
int keta(ll n) { //桁数を求める
if (n == 0)
return 1;
int count = 0;
while (n != 0) {
n /= 10;
count++;
}
return count;
}
ll ketasum(ll n) { //各桁の和
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
int n, m;
cin >> n >> m;
vvi s(m);
rep(i, n) {
int k;
cin >> k;
rep(j, k) {
int a;
cin >> a;
a--;
s[k].pb(a);
}
}
vi p(m);
rep(i, m) cin >> p[i];
int count = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < s[i].size(); j++) {
if (1 & (bit >> s[i][j])) {
cnt++;
}
}
if (cnt % 2 != p[i])
ok = false;
}
if (ok)
count++;
}
cout << count << endl;
return 0;
}; | #pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for (int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
constexpr ll mod = 1e9 + 7;
constexpr ll inf = INT32_MAX / 2;
constexpr ll INF = LLONG_MAX / 2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------テンプレート------------------ */
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a <= b) {
a = b;
return true;
}
return false;
}
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) { //階乗
if (i == 0)
return 1;
return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) { //最大公約数
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) { //最小公倍数
return a * b / gcd(a, b);
}
int keta(ll n) { //桁数を求める
if (n == 0)
return 1;
int count = 0;
while (n != 0) {
n /= 10;
count++;
}
return count;
}
ll ketasum(ll n) { //各桁の和
ll sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
int n, m;
cin >> n >> m;
vvi s(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int a;
cin >> a;
a--;
s[i].pb(a);
}
}
vi p(m);
rep(i, m) cin >> p[i];
int count = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < s[i].size(); j++) {
if (1 & (bit >> s[i][j])) {
cnt++;
}
}
if (cnt % 2 != p[i])
ok = false;
}
if (ok)
count++;
}
cout << count << endl;
return 0;
} | [
"identifier.change",
"variable_access.subscript.index.change"
] | 840,849 | 840,848 | u608773191 | cpp |
p03031 | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;
struct Cond {
int k;
std::vector<int> s;
int p;
};
int main() {
int N, M;
std::cin >> N >> M;
std::vector<Cond> cs;
for (int m = 0; m < M; ++m) {
Cond c;
std::cin >> c.k;
for (int i = 0; i < c.k; ++i) {
int v;
std::cin >> v;
c.s.push_back(v);
}
cs.push_back(c);
}
for (int m = 0; m < M; ++m) {
std::cin >> cs[m].p;
}
int cnt = 0;
for (int i = 1; i < pow(2, N); ++i) {
#if DEBUG
std::cout << "---------- i = " << i << std::endl;
#endif
std::string p;
bool success = true;
int b = pow(2, N - 1);
while (b > 0) {
if (i & b)
p += '1';
else
p += '0';
b >>= 1;
}
for (auto c : cs) {
#if DEBUG
std::cout << "p = " << c.p << std::endl;
#endif
int on_cnt = 0;
#if DEBUG
for (int v : c.s)
std::cout << v << " ";
std::cout << std::endl << "->";
#endif
for (int v : c.s) {
#if DEBUG
std::cout << p[v - 1] << " ";
#endif
if (p[v - 1] == '1')
++on_cnt;
}
#if DEBUG
std::cout << "on_cnt = " << on_cnt % 2 << std::endl;
#endif
if (on_cnt % 2 != c.p) {
success = false;
break;
}
}
if (success)
++cnt;
}
#if DEBUG
std::cout << "Result:";
#endif
std::cout << cnt << std::endl;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;
struct Cond {
int k;
std::vector<int> s;
int p;
};
int main() {
int N, M;
std::cin >> N >> M;
std::vector<Cond> cs;
for (int m = 0; m < M; ++m) {
Cond c;
std::cin >> c.k;
for (int i = 0; i < c.k; ++i) {
int v;
std::cin >> v;
c.s.push_back(v);
}
cs.push_back(c);
}
for (int m = 0; m < M; ++m) {
std::cin >> cs[m].p;
}
int cnt = 0;
for (int i = 0; i < pow(2, N); ++i) {
#if DEBUG
std::cout << "---------- i = " << i << std::endl;
#endif
std::string p;
bool success = true;
int b = pow(2, N - 1);
while (b > 0) {
if (i & b)
p += '1';
else
p += '0';
b >>= 1;
}
for (auto c : cs) {
#if DEBUG
std::cout << "p = " << c.p << std::endl;
#endif
int on_cnt = 0;
#if DEBUG
for (int v : c.s)
std::cout << v << " ";
std::cout << std::endl << "->";
#endif
for (int v : c.s) {
#if DEBUG
std::cout << p[v - 1] << " ";
#endif
if (p[v - 1] == '1')
++on_cnt;
}
#if DEBUG
std::cout << "on_cnt = " << on_cnt % 2 << std::endl;
#endif
if (on_cnt % 2 != c.p) {
success = false;
break;
}
}
if (success)
++cnt;
}
#if DEBUG
std::cout << "Result:";
#endif
std::cout << cnt << std::endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 840,852 | 840,853 | u116523315 | cpp |
p03031 | #include <bits/stdc++.h>
#define ll long long
#define pii_ pair<int, int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define show1(a) cout << #a << " = " << a << endl
#define show2(a, b) cout << #a << " = " << a << "; " << #b << " = " << b << endl
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int maxn = 2e5 + 5;
inline void fastio() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n, m, g[15][15], p[15], cnt[15];
int main() {
fastio();
cin >> n >> m;
rep(i, 0, m - 1) {
int k, x;
cin >> k;
rep(j, 1, k) {
cin >> x;
g[--x][i] = 1;
}
}
rep(i, 0, m - 1) cin >> p[i];
int ans = 0;
rep(i, 0, (1 << n) - 1) {
memset(cnt, 0, sizeof(cnt));
rep(j, 0, i - 1) {
if ((i >> j) & 1) {
rep(k, 0, m - 1) {
if (g[j][k])
cnt[k]++;
}
}
}
int flag = 1;
rep(i, 0, m - 1) if (cnt[i] % 2 != p[i]) flag = 0;
ans += flag;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define pii_ pair<int, int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define show1(a) cout << #a << " = " << a << endl
#define show2(a, b) cout << #a << " = " << a << "; " << #b << " = " << b << endl
using namespace std;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
const int maxn = 2e5 + 5;
inline void fastio() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n, m, g[15][15], p[15], cnt[15];
int main() {
fastio();
cin >> n >> m;
rep(i, 0, m - 1) {
int k, x;
cin >> k;
rep(j, 1, k) {
cin >> x;
g[--x][i] = 1;
}
}
rep(i, 0, m - 1) cin >> p[i];
int ans = 0;
rep(i, 0, (1 << n) - 1) {
memset(cnt, 0, sizeof(cnt));
rep(j, 0, n - 1) {
if ((i >> j) & 1) {
rep(k, 0, m - 1) {
if (g[j][k])
cnt[k]++;
}
}
}
int flag = 1;
rep(i, 0, m - 1) if (cnt[i] % 2 != p[i]) flag = 0;
ans += flag;
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 840,872 | 840,873 | u074650488 | cpp |
p03031 | /*
Problem 11
https://atcoder.jp/contests/abc128/tasks/abc128_c
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main() {
int n, m;
cin >> n >> m;
vector<int> light(m, 0); // lightにつながっているswitchをbitで管理
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
light[i] |= (1 << s);
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
// bit exhausive search
for (int b = 0; b < (1 << n); b++) { // b : 付けるSwitchをbitで管理
// Judge
bool can = true;
for (int i = 0; i < m; i++) {
int cnt = __builtin_popcount(b & light[i]); // 付いているlightの数
if (cnt % 2 != p[i])
can = false;
}
if (can)
ans++;
}
cout << ans << '\n';
} | /*
Problem 11
https://atcoder.jp/contests/abc128/tasks/abc128_c
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main() {
int n, m;
cin >> n >> m;
vector<int> light(m, 0); // lightにつながっているswitchをbitで管理
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
s--;
light[i] |= (1 << s);
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
// bit exhausive search
for (int b = 0; b < (1 << n); b++) { // b : 付けるSwitchをbitで管理
// Judge
bool can = true;
for (int i = 0; i < m; i++) {
int cnt = __builtin_popcount(b & light[i]); // 付いているlightの数
if (cnt % 2 != p[i])
can = false;
}
if (can)
ans++;
}
cout << ans << '\n';
} | [
"expression.unary.arithmetic.add"
] | 840,881 | 840,882 | u603234915 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<vector<int>> connect(m);
rep(i, 0, m) {
int k;
cin >> k;
rep(i, 0, k) {
int s;
cin >> s;
s--;
connect[i].push_back(s);
}
}
vector<int> p(m);
rep(i, 0, m) cin >> p[i];
int ans = 0;
rep(i, 0, 1 << n) {
bool isok = true;
rep(j, 0, m) {
int c = 0;
for (int id : connect[j]) {
if (i >> id & 1)
c++;
}
c %= 2;
if (c != p[j])
isok = false;
}
if (isok)
ans++;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<vector<int>> connect(m);
rep(i, 0, m) {
int k;
cin >> k;
rep(j, 0, k) {
int s;
cin >> s;
s--;
connect[i].push_back(s);
}
}
vector<int> p(m);
rep(i, 0, m) cin >> p[i];
int ans = 0;
rep(i, 0, 1 << n) {
bool isok = true;
rep(j, 0, m) {
int c = 0;
for (int id : connect[j]) {
if (i >> id & 1)
c++;
}
c %= 2;
if (c != p[j])
isok = false;
}
if (isok)
ans++;
}
cout << ans << endl;
}
| [
"identifier.change",
"call.arguments.change"
] | 840,883 | 840,884 | u688789047 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
// N,Mが10以下なので全探索でも間に合う
int N, M;
cin >> N >> M;
vector<vector<int>> S(12, vector<int>(12));
vector<int> P(M);
vector<int> K(M);
int k;
rep(i, M) {
cin >> K[i];
int a = K[i];
rep(j, a) { cin >> S[i][j]; }
}
rep(i, M) cin >> P[i];
// bit全探索
int ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
//スイッチの組み合わせを全探索。bitが立っているところのスイッチが起動している
bool flag = true;
// M個の電球についてみていく
rep(i, M) {
int num = 0;
// i個目の電球とスイッチの条件(num % 2 ==
// P[i])が一致している時だけ先に進む
int k = K[i];
// jはvectorの何こめか
rep(j, k) {
int now = S[i][j];
if (bit & (1 << now))
num++;
}
if (num % 2 != P[i]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
// N,Mが10以下なので全探索でも間に合う
int N, M;
cin >> N >> M;
vector<vector<int>> S(12, vector<int>(12));
vector<int> P(M);
vector<int> K(M);
int k;
rep(i, M) {
cin >> K[i];
int a = K[i];
rep(j, a) { cin >> S[i][j]; }
}
rep(i, M) cin >> P[i];
// bit全探索
int ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
//スイッチの組み合わせを全探索。bitが立っているところのスイッチが起動している
bool flag = true;
// M個の電球についてみていく
rep(i, M) {
int num = 0;
//スイッチの条件(num % 2 == P[i])が一致している時だけ先に進む
int k = K[i];
rep(j, k) {
int now = S[i][j] - 1;
if (bit & (1 << now))
num++;
}
if (num % 2 != P[i]) {
flag = false;
}
}
if (flag)
ans++;
}
cout << ans << endl;
} | [
"assignment.change"
] | 840,892 | 840,891 | u078435079 | cpp |
p03031 | #include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
ll inf = 1000000007;
ll c[55];
int main() {
int n, m;
cin >> n >> m;
int k;
vector<vector<ll>> s(m);
for (int i = 0; i < m; i++) {
cin >> k;
s[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> s[i][j];
s[i][j]--;
}
}
vector<ll> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
ll ans = 0;
for (int bit = 0; bit < (1 << m); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int count = 0;
for (auto id : s[i]) {
if (bit & (1 << id)) {
count++;
}
}
if (count % 2 != p[i]) {
ok = false;
}
}
if (ok)
ans++;
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
ll inf = 1000000007;
ll c[55];
int main() {
int n, m;
cin >> n >> m;
int k;
vector<vector<ll>> s(m);
for (int i = 0; i < m; i++) {
cin >> k;
s[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> s[i][j];
s[i][j]--;
}
}
vector<ll> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int count = 0;
for (auto id : s[i]) {
if (bit & (1 << id)) {
count++;
}
}
if (count % 2 != p[i]) {
ok = false;
}
}
if (ok)
ans++;
}
cout << ans << endl;
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 840,895 | 840,896 | u077051605 | cpp |
p03031 | #include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int k;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> vec(m);
for (int i = 0; i < m; i++) {
cin >> k;
vec[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> vec[i][j];
--vec[i][j];
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int j = 0; j < m; j++) {
int count = 0;
for (auto v : vec[j]) {
if (bit & (1 << v)) {
count++;
}
}
if (count % 2 != p[j]) {
ok = false;
}
if (ok)
ans++;
}
}
cout << ans << endl;
return 0;
} | #include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
int k;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> vec(m);
for (int i = 0; i < m; i++) {
cin >> k;
vec[i].resize(k);
for (int j = 0; j < k; j++) {
cin >> vec[i][j];
--vec[i][j];
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int j = 0; j < m; j++) {
int count = 0;
for (auto v : vec[j]) {
if (bit & (1 << v)) {
count++;
}
}
if (count % 2 != p[j]) {
ok = false;
}
}
if (ok)
ans++;
}
cout << ans << endl;
return 0;
} | [] | 840,897 | 840,898 | u077051605 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> k(11);
vector<vector<int>> s(11, vector<int>(11));
for (int i = 0; i < M; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
cin >> s[i][j];
}
}
vector<int> p(M);
for (int i = 0; i < M; i++) {
cin >> p[i];
}
//スイッチの状態に対し、ビット全探索
int ans = 0;
for (int i = 0; i < (1 << N); i++) {
//各電球に対し検証
int flag = 0;
for (int j = 0; j < M; j++) {
int count = 0;
for (int l = 0; l < k[j]; l++) {
if (i >> (s[j][l] - 1) & 1) {
count++;
}
}
if (count % 2 == 1)
flag++;
}
if (flag == M)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> k(11);
vector<vector<int>> s(11, vector<int>(11));
for (int i = 0; i < M; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
cin >> s[i][j];
}
}
vector<int> p(M);
for (int i = 0; i < M; i++) {
cin >> p[i];
}
//スイッチの状態に対し、ビット全探索
int ans = 0;
for (int i = 0; i < (1 << N); i++) {
//各電球に対し検証
int flag = 0;
for (int j = 0; j < M; j++) {
int count = 0;
for (int l = 0; l < k[j]; l++) {
if (i >> (s[j][l] - 1) & 1) {
count++;
}
}
if (count % 2 == p[j])
flag++;
}
if (flag == M)
ans++;
}
cout << ans << endl;
return 0;
} | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 840,899 | 840,900 | u936176493 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N, M, K, S;
cin >> N >> M;
vector<vector<int>> bulb(M);
vector<int> re(M);
for (int i = 0; i < M; i++) {
cin >> K;
for (int j = 0; j < K; j++) {
cin >> S;
S--;
bulb[i].push_back(S);
}
}
for (int i = 0; i < M; i++) {
cin >> re[i];
}
ll ans = 0;
for (int bits = 1; bits < (1 << N); bits++) { //スイッチの個数
bool ok = true;
for (int i = 0; i < M; i++) { //電球の個数
int sum = 0;
for (auto v : bulb[i]) { //電球の個数が違うので拡張for文
if (bits & (1 << v))
++sum; //ビットが立っているところはカウント
}
if (sum % 2 != re[i])
ok = false; //すべての電球に対してスイッチの偶奇が等しいか確認
}
if (ok)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N, M, K, S;
cin >> N >> M;
vector<vector<int>> bulb(M);
vector<int> re(M);
for (int i = 0; i < M; i++) {
cin >> K;
for (int j = 0; j < K; j++) {
cin >> S;
S--;
bulb[i].push_back(S);
}
}
for (int i = 0; i < M; i++) {
cin >> re[i];
}
ll ans = 0;
for (int bits = 0; bits < (1 << N); bits++) { //スイッチの個数
bool ok = true;
for (int i = 0; i < M; i++) { //電球の個数
int sum = 0;
for (auto v : bulb[i]) { //電球の個数が違うので拡張for文
if (bits & (1 << v))
++sum; //ビットが立っているところはカウント
}
if (sum % 2 != re[i])
ok = false; //すべての電球に対してスイッチの偶奇が等しいか確認
}
if (ok)
ans++;
}
cout << ans << endl;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 840,901 | 840,902 | u861231819 | cpp |
p03031 | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout << (x) << '\n'
#define print_vec(v) \
rep(i, v.size()) { \
if (i != 0) \
cout << " "; \
cout << v[i]; \
} \
cout << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << '\n'
#define DEBUG_VEC(v) \
cout << #v << ":"; \
rep(i, v.size()) cout << " " << v[i]; \
cout << '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 // 10^9+7
#define fi first
#define sc second
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vstr = vector<string>;
void solve() {
int N, M;
cin >> N >> M;
vi k(M), p(M);
vector<vi> s;
rep(i, M) {
cin >> k[i];
vi sk(k[i]);
rep(j, k[i]) {
cin >> sk[j];
sk[j]--;
}
s.pb(sk);
}
rep(i, M) { cin >> p[i]; }
int ans = 0;
rng(bit, 1, pow(2, N)) {
bool ok = 1;
vi on_switch(N);
rep(j, N) { on_switch[j] = (bit >> j & 1); }
rep(j, M) {
int on_count = 0;
for (auto sij : s[j]) {
on_count += on_switch[sij];
}
if (on_count % 2 != p[j]) {
ok = 0;
break;
}
}
if (ok)
ans++;
}
print(ans);
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(20);
// int q; cin >> q;
// while (q--)
solve();
return 0;
} | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout << (x) << '\n'
#define print_vec(v) \
rep(i, v.size()) { \
if (i != 0) \
cout << " "; \
cout << v[i]; \
} \
cout << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << '\n'
#define DEBUG_VEC(v) \
cout << #v << ":"; \
rep(i, v.size()) cout << " " << v[i]; \
cout << '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 // 10^9+7
#define fi first
#define sc second
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vstr = vector<string>;
void solve() {
int N, M;
cin >> N >> M;
vi k(M), p(M);
vector<vi> s;
rep(i, M) {
cin >> k[i];
vi sk(k[i]);
rep(j, k[i]) {
cin >> sk[j];
sk[j]--;
}
s.pb(sk);
}
rep(i, M) { cin >> p[i]; }
int ans = 0;
rng(bit, 0, pow(2, N)) {
bool ok = 1;
vi on_switch(N);
rep(j, N) { on_switch[j] = (bit >> j & 1); }
rep(j, M) {
int on_count = 0;
for (auto sij : s[j]) {
on_count += on_switch[sij];
}
if (on_count % 2 != p[j]) {
ok = 0;
break;
}
}
if (ok)
ans++;
}
print(ans);
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(20);
// int q; cin >> q;
// while (q--)
solve();
return 0;
} | [
"literal.number.change",
"call.arguments.change"
] | 840,910 | 840,911 | u024383312 | cpp |
p03031 | /**
* purpose :
* author : kyomukyomupurin
* created :
**/
// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template <typename T> inline void chmax(T &a, T b) {
if (a < b)
a = b;
return;
}
template <typename T> inline void chmin(T &a, T b) {
if (a > b)
a = b;
return;
}
int k[10];
int s[10][10];
int p[10];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
cin >> k[i];
for (int j = 0; j < k[i]; ++j) {
cin >> s[i][j];
}
}
for (int i = 0; i < m; ++i)
cin >> p[i];
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
int switch_on = 0;
for (int j = 0; j < m; ++j) {
int cnt = 0;
for (int bit = 0; bit < n; ++bit) {
for (int l = 0; l < k[j]; ++l) {
if (bit & (1 << i) && (bit + 1) == s[j][l])
++cnt;
}
}
switch_on += (cnt % 2 == p[j]);
}
ans += switch_on == m;
}
print(ans);
return 0;
} | #pragma region kyomukyomupurin
/**
* author : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
* created : 2020-07-11 10:19:41
**/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using int64 = long long;
template <class T> inline void eraque(std::vector<T> &vec) {
vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
return;
}
template <class T> inline int lower_position(const std::vector<T> &vec, T val) {
return static_cast<int>(std::distance(
vec.begin(), std::lower_bound(vec.begin(), vec.end(), val)));
}
template <class T> inline int upper_position(const std::vector<T> &vec, T val) {
return static_cast<int>(std::distance(
vec.begin(), std::upper_bound(vec.begin(), vec.end(), val)));
}
template <class T> inline std::string to_binary(T n) {
assert(n > 0);
std::string ret = "";
while (n)
ret += (n & 1) ? '1' : '0', n >>= 1;
std::reverse(ret.begin(), ret.end());
return ret;
}
template <class T> inline void println(T val) { std::cout << val << '\n'; }
template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
return os << '(' << p.first << ", " << p.second << ')';
}
template <class Tuple, std::size_t... Is>
void tuple_out(std::ostream &os, const Tuple &tp, std::index_sequence<Is...>) {
((os << (Is ? ", " : "(") << std::get<Is>(tp)), ...) << ")";
}
template <class... Args>
std::ostream &operator<<(std::ostream &os, const std::tuple<Args...> &tp) {
tuple_out(os, tp, std::index_sequence_for<Args...>{});
return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec) {
int n = 0;
for (auto e : vec)
os << (n++ ? ", " : "{") << e;
return os << (n ? "}" : "{}");
}
template <class T, class Compare>
std::ostream &operator<<(std::ostream &os, const std::set<T, Compare> &st) {
int n = 0;
for (auto e : st)
os << (n++ ? ", " : "{") << e;
return os << (n ? "}" : "{}");
}
template <class T, class U, class Compare>
std::ostream &operator<<(std::ostream &os, const std::map<T, U, Compare> &mp) {
int n = 0;
for (auto e : mp)
os << (n++ ? ", " : "{") << e;
return os << (n ? "}" : "{}");
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
for (T &e : vec)
is >> e;
return is;
}
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
return is >> p.first >> p.second;
}
template <class Tuple, std::size_t... Is>
void tuple_in(std::istream &is, Tuple &tp, std::index_sequence<Is...>) {
((is >> std::get<Is>(tp)), ...);
}
template <class... Args>
std::istream &operator>>(std::istream &is, std::tuple<Args...> &tp) {
tuple_in(is, tp, std::index_sequence_for<Args...>{});
return is;
}
#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
void debug_out() { std::cerr << '\n'; }
template <class Head, class... Tail>
void debug_out(Head &&head, Tail &&...tail) {
std::cerr << head;
if (sizeof...(Tail) != 0)
std::cerr << ", ";
debug_out(std::forward<Tail>(tail)...);
}
#pragma endregion kyomukyomupurin
namespace FastIO {
class Scanner {
static constexpr int buf_size = (1 << 18);
static constexpr int integer_size = 20;
static constexpr int string_size = 1000; // default
char buf[buf_size] = {};
char *cur = buf, *ed = buf;
public:
Scanner() {}
template <class T> inline Scanner &operator>>(T &val) {
read(val);
return *this;
}
private:
inline void reload() {
size_t len = ed - cur;
memmove(buf, cur, len);
char *tmp = buf + len;
ed = tmp + fread(tmp, 1, buf_size - len, stdin);
*ed = 0;
cur = buf;
}
inline void skip_space() {
while (true) {
if (cur == ed)
reload();
while (*cur == ' ' || *cur == '\n')
++cur;
if (__builtin_expect(cur != ed, 1))
return;
}
}
template <class T, std::enable_if_t<std::is_same<T, int>::value, int> = 0>
inline void read(T &num) {
skip_space();
if (cur + integer_size >= ed)
reload();
bool neg = false;
num = 0;
if (*cur == '-')
neg = true, ++cur;
while (*cur >= '0')
num = num * 10 + (*cur ^ 48), ++cur;
if (neg)
num = -num;
}
template <class T, std::enable_if_t<std::is_same<T, int64>::value, int> = 0>
inline void read(T &num) {
skip_space();
if (cur + integer_size >= ed)
reload();
bool neg = false;
num = 0;
if (*cur == '-')
neg = true, ++cur;
while (*cur >= '0')
num = num * 10 + (*cur ^ 48), ++cur;
if (neg)
num = -num;
}
template <class T,
std::enable_if_t<std::is_same<T, std::string>::value, int> = 0>
inline void read(T &str) {
skip_space();
if (cur + str.size() >= ed)
reload();
auto it = cur;
while (!(*cur == ' ' || *cur == '\n'))
++cur;
str = std::string(it, cur);
}
template <class T, std::enable_if_t<std::is_same<T, char>::value, int> = 0>
inline void read(T &c) {
skip_space();
if (cur + 1 >= ed)
reload();
c = *cur, ++cur;
}
template <class T, std::enable_if_t<std::is_same<T, double>::value, int> = 0>
inline void read(T &num) {
skip_space();
if (cur + integer_size >= ed)
reload();
bool neg = false;
num = 0;
if (*cur == '-')
neg = true, ++cur;
while (*cur >= '0' && *cur <= '9')
num = num * 10 + (*cur ^ 48), ++cur;
if (*cur != '.')
return;
++cur;
T base = 0.1;
while (*cur >= '0' && *cur <= '9') {
num += base * (*cur ^ 48);
++cur;
base *= 0.1;
}
if (neg)
num = -num;
}
template <class T,
std::enable_if_t<std::is_same<T, long double>::value, int> = 0>
inline void read(T &num) {
skip_space();
if (cur + integer_size >= ed)
reload();
bool neg = false;
num = 0;
if (*cur == '-')
neg = true, ++cur;
while (*cur >= '0' && *cur <= '9')
num = num * 10 + (*cur ^ 48), ++cur;
if (*cur != '.')
return;
++cur;
T base = 0.1;
while (*cur >= '0' && *cur <= '9') {
num += base * (*cur ^ 48);
++cur;
base *= 0.1;
}
if (neg)
num = -num;
}
template <class T> inline void read(std::vector<T> &vec) {
for (T &e : vec)
read(e);
}
template <class T, class U> inline void read(std::pair<T, U> &p) {
read(p.first, p.second);
}
template <class Tuple, std::size_t... Is>
inline void tuple_scan(Tuple &tp, std::index_sequence<Is...>) {
(read(std::get<Is>(tp)), ...);
}
template <class... Args> inline void read(std::tuple<Args...> &tp) {
tuple_scan(tp, std::index_sequence_for<Args...>{});
}
inline void read() {}
template <class Head, class... Tail>
inline void read(Head &&head, Tail &&...tail) {
read(head);
read(std::forward<Tail>(tail)...);
}
};
class Printer {
static constexpr int buf_size = (1 << 18);
static constexpr int integer_size = 20;
static constexpr int string_size = (1 << 6);
static constexpr int margin = 1;
static constexpr int n = 10000;
char buf[buf_size + margin] = {};
char table[n * 4] = {};
char *cur = buf;
public:
constexpr Printer() { build(); }
~Printer() { flush(); }
template <class T> inline Printer &operator<<(T val) {
write(val);
return *this;
}
template <class T> inline void println(T val) {
write(val);
write('\n');
}
private:
constexpr void build() {
for (int i = 0; i < 10000; ++i) {
int tmp = i;
for (int j = 3; j >= 0; --j) {
table[i * 4 + j] = tmp % 10 + '0';
tmp /= 10;
}
}
}
inline void flush() {
fwrite(buf, 1, cur - buf, stdout);
cur = buf;
}
template <class T, std::enable_if_t<std::is_same<T, int>::value, int> = 0>
inline int get_digit(T n) {
if (n >= (int)1e5) {
if (n >= (int)1e8)
return 9;
if (n >= (int)1e7)
return 8;
if (n >= (int)1e6)
return 7;
return 6;
} else {
if (n >= (int)1e4)
return 5;
if (n >= (int)1e3)
return 4;
if (n >= (int)1e2)
return 3;
if (n >= (int)1e1)
return 2;
return 1;
}
}
template <class T, std::enable_if_t<std::is_same<T, int64>::value, int> = 0>
inline int get_digit(T n) {
if (n >= (int64)1e10) {
if (n >= (int64)1e14) {
if (n >= (int64)1e18)
return 19;
if (n >= (int64)1e17)
return 18;
if (n >= (int64)1e16)
return 17;
if (n >= (int64)1e15)
return 16;
return 15;
} else {
if (n >= (int64)1e14)
return 15;
if (n >= (int64)1e13)
return 14;
if (n >= (int64)1e12)
return 13;
if (n >= (int64)1e11)
return 12;
return 11;
}
} else {
if (n >= (int64)1e5) {
if (n >= (int64)1e9)
return 10;
if (n >= (int64)1e8)
return 9;
if (n >= (int64)1e7)
return 8;
if (n >= (int64)1e6)
return 7;
return 6;
} else {
if (n >= (int64)1e4)
return 5;
if (n >= (int64)1e3)
return 4;
if (n >= (int64)1e2)
return 3;
if (n >= (int64)1e1)
return 2;
return 1;
}
}
}
template <class T, std::enable_if_t<std::is_same<T, int>::value, int> = 0>
inline void write(T num) {
if (__builtin_expect(cur + integer_size >= buf + buf_size, 0))
flush();
if (num == 0) {
write('0');
return;
}
if (num < 0) {
write('-');
num = -num;
}
int len = get_digit(num);
int digits = len;
while (num >= 10000) {
memcpy(cur + len - 4, table + (num % 10000) * 4, 4);
num /= 10000;
len -= 4;
}
memcpy(cur, table + num * 4 + (4 - len), len);
cur += digits;
}
template <class T, std::enable_if_t<std::is_same<T, int64>::value, int> = 0>
inline void write(T num) {
if (__builtin_expect(cur + integer_size >= buf + buf_size, 0))
flush();
if (num == 0) {
write('0');
return;
}
if (num < 0) {
write('-');
num = -num;
}
int len = get_digit(num);
int digits = len;
while (num >= 10000) {
memcpy(cur + len - 4, table + (num % 10000) * 4, 4);
num /= 10000;
len -= 4;
}
memcpy(cur, table + num * 4 + (4 - len), len);
cur += digits;
}
template <class T, std::enable_if_t<std::is_same<T, char>::value, int> = 0>
inline void write(T c) {
if (__builtin_expect(cur + 1 >= buf + buf_size, 0))
flush();
*cur = c;
++cur;
}
template <class T,
std::enable_if_t<std::is_same<T, std::string>::value, int> = 0>
inline void write(T str) {
if (__builtin_expect(cur + str.size() >= buf + buf_size, 0))
flush();
for (char c : str)
write(c);
}
template <class T,
std::enable_if_t<std::is_same<T, const char *>::value, int> = 0>
inline void write(T str) {
if (__builtin_expect(cur + string_size >= buf + buf_size, 0))
flush();
for (int i = 0; str[i]; ++i)
write(str[i]);
}
};
} // namespace FastIO
FastIO::Scanner fin;
FastIO::Printer fout;
int k[11];
int s[11][11];
int p[11];
int main() {
int n, m;
fin >> n >> m;
for (int i = 0; i < m; ++i) {
fin >> k[i];
for (int j = 0; j < k[i]; ++j) {
fin >> s[i][j];
--s[i][j];
}
}
for (int i = 0; i < m; ++i)
fin >> p[i];
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
bool flag = true;
for (int j = 0; j < m; ++j) {
int cnt = 0;
for (int kk = 0; kk < k[j]; ++kk) {
if (i & (1 << s[j][kk])) {
++cnt;
}
}
flag &= (cnt % 2 == p[j]);
}
ans += flag;
}
fout.println(ans);
return 0;
}
| [] | 840,912 | 840,913 | u095266283 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> data(M);
for (int i = 0; i < M; i++) {
int L;
cin >> L;
for (int j = 0; j < L; j++) {
int x;
cin >> x;
data.at(i).push_back(x);
}
}
vector<int> tukuka(M);
for (int i = 0; i < M; i++) {
cin >> tukuka.at(i);
}
int ans = 0;
for (int tmp = 0; tmp < (1 << N); tmp++) {
bool a = true;
for (int j = 0; j < M; j++) {
int count = 0;
for (int k = 0; k < data.at(j).size(); k++) {
if (((1 << data.at(j).at(k)) & tmp) != 0)
count++;
}
if (count % 2 != tukuka.at(j)) {
a = false;
}
}
if (a)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> data(M);
for (int i = 0; i < M; i++) {
int L;
cin >> L;
for (int j = 0; j < L; j++) {
int x;
cin >> x;
x--;
data.at(i).push_back(x);
}
}
vector<int> tukuka(M);
for (int i = 0; i < M; i++) {
cin >> tukuka.at(i);
}
int ans = 0;
for (int tmp = 0; tmp < (1 << N); tmp++) {
bool a = true;
for (int j = 0; j < M; j++) {
int count = 0;
for (int k = 0; k < data.at(j).size(); k++) {
if (((1 << data.at(j).at(k)) & tmp) != 0)
count++;
}
if (count % 2 != tukuka.at(j)) {
a = false;
}
}
if (a) {
ans++;
}
}
cout << ans << endl;
} | [
"expression.unary.arithmetic.add"
] | 840,914 | 840,915 | u934462215 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n, m, ans;
cin >> n >> m;
vector<vector<int>> lmp(m);
vector<int> p(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int ss;
cin >> ss;
lmp[i].push_back(ss - 1);
}
}
rep(i, m) cin >> p[i];
ans = 0;
// {0, 1, ..., n-1} の部分集合の全探索
for (int bit = 1; bit < (1 << n); ++bit) {
vector<int> S(n);
for (int i = 0; i < n; ++i) {
if (bit & (1 << i)) { // 列挙に i が含まれるか
S[i] = 1;
}
}
//電球チェック
int flg = 0;
rep(i, m) {
int cnt = 0;
rep(j, lmp[i].size()) {
if (S[lmp[i][j]] == 1)
++cnt;
}
if (cnt % 2 != p[i]) {
++flg;
break;
;
}
}
if (flg == 0)
++ans;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int n, m, ans;
cin >> n >> m;
vector<vector<int>> lmp(m);
vector<int> p(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int ss;
cin >> ss;
lmp[i].push_back(ss - 1);
}
}
rep(i, m) cin >> p[i];
ans = 0;
// {0, 1, ..., n-1} の部分集合の全探索
for (int bit = 0; bit < (1 << n); ++bit) {
vector<int> S(n);
for (int i = 0; i < n; ++i) {
if (bit & (1 << i)) { // 列挙に i が含まれるか
S[i] = 1;
}
}
//電球チェック
int flg = 0;
rep(i, m) {
int cnt = 0;
rep(j, lmp[i].size()) {
if (S[lmp[i][j]] == 1)
++cnt;
}
if (cnt % 2 != p[i]) {
++flg;
break;
;
}
}
if (flg == 0)
++ans;
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 840,920 | 840,921 | u372940733 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
vector<vector<ll>> a(11);
ll ch[11], n, m, ans;
bool sw[11];
void cal() {
bool now = true;
for (ll i = 0; i < n; i++) {
ll sum = 0;
for (ll j = 0; j < a[i].size(); j++) {
if (sw[a[i][j]]) {
sum++;
}
}
if (sum % 2 != ch[i]) {
now = false;
}
}
if (now != false) {
ans++;
}
}
void dep(ll now) {
if (now == n) {
cal();
return;
}
sw[now] = 0;
dep(now + 1);
sw[now] = 1;
dep(now + 1);
}
int main() {
cin >> n >> m;
for (ll i = 0; i < m; i++) {
ll x;
cin >> x;
for (ll j = 0; j < x; j++) {
ll y;
cin >> y;
y--;
a[i].push_back(y);
}
}
for (ll i = 0; i < n; i++) {
cin >> ch[i];
}
dep(0);
cout << ans;
// your code goes here
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL << 62
#define inf 1000000007
vector<vector<ll>> a(11);
ll ch[11], n, m, ans;
bool sw[11];
void cal() {
bool now = true;
for (ll i = 0; i < m; i++) {
ll sum = 0;
for (ll j = 0; j < a[i].size(); j++) {
if (sw[a[i][j]]) {
sum++;
}
}
if (sum % 2 != ch[i]) {
now = false;
}
}
if (now != false) {
ans++;
}
}
void dep(ll now) {
if (now == n) {
cal();
return;
}
sw[now] = 0;
dep(now + 1);
sw[now] = 1;
dep(now + 1);
}
int main() {
cin >> n >> m;
for (ll i = 0; i < m; i++) {
ll x;
cin >> x;
for (ll j = 0; j < x; j++) {
ll y;
cin >> y;
y--;
a[i].push_back(y);
}
}
for (ll i = 0; i < m; i++) {
cin >> ch[i];
}
dep(0);
cout << ans;
// your code goes here
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 840,928 | 840,929 | u166378830 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int l;
cin >> l;
l--;
s[i].push_back(l);
}
}
vector<int> p(N);
for (int i = 0; i < N; i++)
cin >> p[i];
long long res = 0;
for (int bit = 0; bit < (1 << N); bit++) {
bool ok = true;
for (int i = 0; i < M; i++) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
con++;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
res++;
}
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int l;
cin >> l;
l--;
s[i].push_back(l);
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p[i];
long long res = 0;
for (int bit = 0; bit < (1 << N); bit++) {
bool ok = true;
for (int i = 0; i < M; i++) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
con++;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
res++;
}
cout << res << endl;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 840,938 | 840,939 | u945452839 | cpp |
p03031 | #include <algorithm>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
using namespace std;
class zahyo {
public:
int x;
int y;
zahyo() {
x = 0;
y = 0;
}
zahyo(int x_, int y_) {
x = x_;
y = y_;
}
void print() { cout << x << " " << y; }
zahyo operator+(zahyo add) {
add.x = this->x + add.x;
add.y = this->y + add.y;
return add;
}
zahyo operator-(zahyo add) {
add.x = this->x - add.x;
add.y = this->y - add.y;
return add;
}
bool operator==(const zahyo add) const {
if (add.x == this->x and add.y == this->y) {
return true;
} else {
return false;
}
}
bool operator!=(const zahyo add) const {
if (add.x == this->x or add.y == this->y) {
return false;
} else {
return true;
}
}
bool operator<(const zahyo add) const {
if (this->x < add.x) {
return true;
} else if (this->x == add.x and this->y < add.y) {
return true;
} else {
return false;
}
}
bool operator>(const zahyo add) const {
if (this->x > add.x) {
return true;
} else if (this->x == add.x and this->y > add.y) {
return true;
} else {
return false;
}
}
void input() { cin >> x >> y; }
};
int main() {
int n, m;
cin >> n >> m;
int s[10];
for (int i = 0; i < m; i++) {
int k;
cin >> k;
s[i] = 0;
for (int j = 0; j < k; j++) {
int s_;
cin >> s_;
s[i] = s[i] | (1 << s_);
}
}
int p[10];
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int ans = 0;
for (int i = 0; i < (1 << n); i++) {
bool ok = true;
for (int j = 0; j < m; j++) {
int temp = i & s[j];
int check = 0;
while (temp) {
check += temp % 2;
temp = temp >> 1;
}
if (check % 2 != p[j]) {
ok = false;
}
}
if (ok) {
ans++;
}
}
cout << ans << endl;
}
| #include <algorithm>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
using namespace std;
class zahyo {
public:
int x;
int y;
zahyo() {
x = 0;
y = 0;
}
zahyo(int x_, int y_) {
x = x_;
y = y_;
}
void print() { cout << x << " " << y; }
zahyo operator+(zahyo add) {
add.x = this->x + add.x;
add.y = this->y + add.y;
return add;
}
zahyo operator-(zahyo add) {
add.x = this->x - add.x;
add.y = this->y - add.y;
return add;
}
bool operator==(const zahyo add) const {
if (add.x == this->x and add.y == this->y) {
return true;
} else {
return false;
}
}
bool operator!=(const zahyo add) const {
if (add.x == this->x or add.y == this->y) {
return false;
} else {
return true;
}
}
bool operator<(const zahyo add) const {
if (this->x < add.x) {
return true;
} else if (this->x == add.x and this->y < add.y) {
return true;
} else {
return false;
}
}
bool operator>(const zahyo add) const {
if (this->x > add.x) {
return true;
} else if (this->x == add.x and this->y > add.y) {
return true;
} else {
return false;
}
}
void input() { cin >> x >> y; }
};
int main() {
int n, m;
cin >> n >> m;
int s[10];
for (int i = 0; i < m; i++) {
int k;
cin >> k;
s[i] = 0;
for (int j = 0; j < k; j++) {
int s_;
cin >> s_;
s_--;
s[i] = s[i] | (1 << s_);
}
}
int p[10];
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int ans = 0;
for (int i = 0; i < (1 << n); i++) {
bool ok = true;
for (int j = 0; j < m; j++) {
int temp = i & s[j];
int check = 0;
while (temp) {
check += temp % 2;
temp = temp >> 1;
}
if (check % 2 != p[j]) {
ok = false;
}
}
if (ok) {
ans++;
}
}
cout << ans << endl;
}
| [
"expression.unary.arithmetic.add"
] | 840,943 | 840,944 | u023751250 | cpp |
p03031 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[i].push_back(a);
}
}
vector<int> p(m);
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int i = 0; i < (1 << n); i++) {
bool ok = true;
for (int j = 0; j < m; j++) {
int cnt = 0;
for (int k = 0; k < s[j].size(); k++) {
if (i & (1 << s[j][k]))
cnt++;
}
if (cnt % 2 != p[j])
ok = false;
}
if (ok)
ans++;
}
cout << ans << endl;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
a--;
s[i].push_back(a);
}
}
vector<int> p(m);
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int i = 0; i < (1 << n); i++) {
bool ok = true;
for (int j = 0; j < m; j++) {
int cnt = 0;
for (int k = 0; k < s[j].size(); k++) {
if (i & (1 << s[j][k]))
cnt++;
}
if (cnt % 2 != p[j])
ok = false;
}
if (ok)
ans++;
}
cout << ans << endl;
} | [
"expression.unary.arithmetic.add"
] | 840,945 | 840,946 | u936558609 | cpp |
p03031 | #include <iomanip>
#include <iostream>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける
//////////////////
// A
/*int main(void){
int a,p;cin >>a >>p;
cout<<(a*3+p)/2<<endl;
return 0;
}*/
//////////////////
// B
/*int main(void){
int n;cin>>n;
vector<pair<string,pair<int,int> > > box(n);
rep(i,n){
cin>>box[i].first>>box[i].second.first;
box[i].second.second=i+1;
box[i].second.first*=-1;
}
sort(box.begin(), box.end());
//rep(i,n)cout <<box[i].first<<" "<<box[i].second.first<<"
"<<box[i].second.second<<endl;
rep(i,n) cout<<box[i].second.second<<endl;
return 0;
}*/
//////////////////
// C
int main(void) {
int n, m;
cin >> n >> m;
int ret = 0;
vector<vector<bool>> map(m, vector<bool>(n));
vector<int> p(m);
rep(i, m) {
int t;
cin >> t;
rep(j, t) {
int d;
cin >> d;
map[i][d - 1] = true;
}
}
rep(i, m) cin >> p[i];
// rep(i,m){rep(j,n)cout<<map[i][j];cout<<endl;}
for (int bit = 0; bit < (1 << n); bit++) {
bool isclear = true; //電球が全て着いたならtrueで通過する
rep(i, m) {
int denkyugaONnokazu = 0;
rep(j, n) {
if ((map[i][j] == true) &&
(bit & (1 << j + 1))) { // mapが1になってて、bitのj+1ビット目が1なら
denkyugaONnokazu++;
}
}
if (denkyugaONnokazu % 2 != p[i]) { //違った瞬間抜ける
isclear = false;
break;
}
}
if (isclear)
ret++;
}
cout << ret << endl;
return 0;
}
//////////////////
// D
/*int main(void){
return 0;
}*/
//////////////////
// E
/*int main(void){
return 0;
}*/
//////////////////
// F
/*int main(void){
return 0;
}*/
| #include <iomanip>
#include <iostream>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける
//////////////////
// A
/*int main(void){
int a,p;cin >>a >>p;
cout<<(a*3+p)/2<<endl;
return 0;
}*/
//////////////////
// B
/*int main(void){
int n;cin>>n;
vector<pair<string,pair<int,int> > > box(n);
rep(i,n){
cin>>box[i].first>>box[i].second.first;
box[i].second.second=i+1;
box[i].second.first*=-1;
}
sort(box.begin(), box.end());
//rep(i,n)cout <<box[i].first<<" "<<box[i].second.first<<"
"<<box[i].second.second<<endl;
rep(i,n) cout<<box[i].second.second<<endl;
return 0;
}*/
//////////////////
// C
int main(void) {
int n, m;
cin >> n >> m;
int ret = 0;
vector<vector<bool>> map(m, vector<bool>(n));
vector<int> p(m);
rep(i, m) {
int t;
cin >> t;
rep(j, t) {
int d;
cin >> d;
map[i][d - 1] = true;
}
}
rep(i, m) cin >> p[i];
// rep(i,m){rep(j,n)cout<<map[i][j];cout<<endl;}
for (int bit = 0; bit < (1 << n); bit++) {
bool isclear = true; //電球が全て着いたならtrueで通過する
rep(i, m) {
int denkyugaONnokazu = 0;
rep(j, n) {
if ((map[i][j] == true) &&
(bit & (1 << j))) { // mapが1になってて、bitのj+1ビット目が1なら
denkyugaONnokazu++;
}
}
if (denkyugaONnokazu % 2 != p[i]) { //違った瞬間抜ける
isclear = false;
break;
}
}
if (isclear)
ret++;
}
cout << ret << endl;
return 0;
}
//////////////////
// D
/*int main(void){
return 0;
}*/
//////////////////
// E
/*int main(void){
return 0;
}*/
//////////////////
// F
/*int main(void){
return 0;
}*/
| [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 840,967 | 840,968 | u317432339 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int k;
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
--a;
s[i].push_back(a);
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << M); ++bit) {
int flag = 1;
for (int i = 0; i < M; i++) {
int count = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
count++;
}
if (count % 2 != p[i])
flag = 0;
}
if (flag == 1)
++ans;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int k;
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
--a;
s[i].push_back(a);
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << N); ++bit) {
int flag = 1;
for (int i = 0; i < M; i++) {
int count = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
count++;
}
if (count % 2 != p[i])
flag = 0;
}
if (flag == 1)
++ans;
}
cout << ans << endl;
return 0;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 840,969 | 840,970 | u084069244 | cpp |
p03031 | #include <algorithm>
#include <iostream>
#include <vector>
#define MAX 10
#define PATTERN 1024
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> S(m, vector<int>(n, 0));
vector<vector<int>> temp(m, vector<int>(n, 0));
vector<int> p(m);
int k, s;
for (int i = 0; i < m; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
cin >> s;
S[i][s - 1] = 1;
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
bool on = true;
int ans = 0;
int all_on = 1 << n;
for (int mask = 1; mask < all_on; mask++) {
for (int i = 0; i < m; i++) {
int count = 0;
for (int shift = 0; shift < n; shift++) {
int sel = (mask >> shift) & 1;
count += sel * S[i][shift];
}
if (count % 2 != p[i]) {
on = false;
break;
}
}
if (on) {
ans++;
}
on = true;
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
#define MAX 10
#define PATTERN 1024
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> S(m, vector<int>(n, 0));
vector<vector<int>> temp(m, vector<int>(n, 0));
vector<int> p(m);
int k, s;
for (int i = 0; i < m; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
cin >> s;
S[i][s - 1] = 1;
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
bool on = true;
int ans = 0;
int all_on = 1 << n;
for (int mask = 0; mask < all_on; mask++) {
for (int i = 0; i < m; i++) {
int count = 0;
for (int shift = 0; shift < n; shift++) {
int sel = (mask >> shift) & 1;
count += sel * S[i][shift];
}
if (count % 2 != p[i]) {
on = false;
break;
}
}
if (on) {
ans++;
}
on = true;
}
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 840,973 | 840,974 | u790493075 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
typedef long long ll;
const long long INF = 1LL << 60;
int main() {
int N, M;
cin >> N >> M;
vector<int> bit(M, 0), check(M);
rep(i, M) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
bit[i] += pow(2, s - 1);
// cout << bit[i] << ":" << s << ":" << (2^(s-1)) << endl;
}
}
rep(j, M) { cin >> check[j]; }
int ans = 0;
for (int i = 1; i < (1 << N); i++) {
bool flag = true;
rep(j, M) {
int num = bit[j] & i;
int bit_j = 0;
for (int j = 1; j < (1 << N); j = j << 1) {
if (num & j)
bit_j++;
}
if (bit_j % 2 != check[j]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
typedef long long ll;
const long long INF = 1LL << 60;
int main() {
int N, M;
cin >> N >> M;
vector<int> bit(M, 0), check(M);
rep(i, M) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
bit[i] += pow(2, s - 1);
// cout << bit[i] << ":" << s << ":" << (2^(s-1)) << endl;
}
}
rep(j, M) { cin >> check[j]; }
int ans = 0;
for (int i = 0; i < (1 << N); i++) {
bool flag = true;
rep(j, M) {
int num = bit[j] & i;
int bit_j = 0;
for (int j = 1; j < (1 << N); j = j << 1) {
if (num & j)
bit_j++;
}
if (bit_j % 2 != check[j]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 840,986 | 840,987 | u628332144 | cpp |
p03031 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[i].push_back(a);
}
}
int p[m];
for (int i = 0; i < m; i++)
cin >> p[i];
int S = 0;
for (int b = 0; b < (1 << n); b++) {
int l = 0;
for (int i = 0; i < m; i++) {
int t = 0;
for (int j = 0; j < s[i].size(); j++) {
if (b & (1 << s[i][j]))
t++;
}
if (t % 2 == p[i])
l++;
}
if (l == m)
S++;
}
cout << S << endl;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[i].push_back(a);
}
}
int p[m];
for (int i = 0; i < m; i++)
cin >> p[i];
int S = 0;
for (int b = 0; b < (1 << n); b++) {
int l = 0;
for (int i = 0; i < m; i++) {
int t = 0;
for (int j = 0; j < s[i].size(); j++) {
if (b & (1 << s[i][j] - 1))
t++;
}
if (t % 2 == p[i])
l++;
}
if (l == m)
S++;
}
cout << S << endl;
} | [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 840,992 | 840,993 | u016987091 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define RITR(x, c) for (__typeof(c.rbegin()) x = c.rbegin(); x != c.rend(); x++)
#define setp(n) fixed << setprecision(n)
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define all(a) (a.begin()), (a.end())
#define rall(a) (a.rbegin()), (a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
using namespace std;
bool sw[10][10];
//-------------------------------------------------
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
rep(i, M) {
int K;
cin >> K;
rep(j, K) {
int s;
cin >> s;
sw[i][s - 1] = true;
}
}
vi p(M);
rep(i, M) cin >> p[i];
int ans = 0;
rep(S, 1 << N) {
bool ng = false;
rep(i, M) {
int sum = 0;
rep(j, N) if (S >> j & 1) if (sw[j][i]) { sum = 1 - sum; }
if (sum != p[i])
ng = true;
}
if (!ng)
ans++;
}
cout << ans << "\n";
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define RITR(x, c) for (__typeof(c.rbegin()) x = c.rbegin(); x != c.rend(); x++)
#define setp(n) fixed << setprecision(n)
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define all(a) (a.begin()), (a.end())
#define rall(a) (a.rbegin()), (a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert
using namespace std;
bool sw[10][10];
//-------------------------------------------------
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
rep(i, M) {
int K;
cin >> K;
rep(j, K) {
int s;
cin >> s;
sw[i][s - 1] = true;
}
}
vi p(M);
rep(i, M) cin >> p[i];
int ans = 0;
rep(S, 1 << N) {
bool ng = false;
rep(i, M) {
int sum = 0;
rep(j, N) if (S >> j & 1) if (sw[i][j]) { sum = 1 - sum; }
if (sum != p[i])
ng = true;
}
if (!ng)
ans++;
}
cout << ans << "\n";
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 840,994 | 840,995 | u682686221 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 // 10^9+7
#define rep(i, n) for (int i = 0; i < (int)n; i++)
/* 一括cin */
template <class H> void CIN(H &h) { cin >> h; }
template <class H, class... T> void CIN(H &h, T &...t) {
cin >> h;
CIN(t...);
}
/* デバッグ */
namespace /* debug */ {
#define DEBUG(...) \
do { \
cout << #__VA_ARGS__ << " = "; \
debug(__VA_ARGS__); \
} while (0) //変数
#define ldebug(...) \
do { \
cout << "[" << setw(3) << __LINE__ << "] "; \
debug(__VA_ARGS__); \
} while (0) //行数
#define lDEBUG(...) \
do { \
cout << "[" << setw(3) << __LINE__ << "] " << #__VA_ARGS__ << " = "; \
debug(__VA_ARGS__); \
} while (0) //変数, 行数
template <class T> void show(T &x) { cout << x << " "; } //出力
template <class T> void showendl(T &x) { cout << x << endl; } //出力改行
template <class P, class Q> void show(pair<P, Q> &x) {
cout << "(" << x.first << ", " << x.second << ") ";
} // pair出力
template <class P, class Q> void showendl(pair<P, Q> &x) {
cout << "(" << x.first << ", " << x.second << ")" << endl;
} // pair出力改行
template <class H> void debug(H &&h) { showendl(h); } //引数1つ
template <class H, class... Ts> void debug(H &&h, Ts &&...ts) {
show(h);
debug(forward<Ts>(ts)...);
} //可変引数
template <class T> void debug(vector<T> &vt) {
int i = 0;
for (auto x : vt)
++i != vt.size() ? show(x) : showendl(x);
} // vector出力
template <class T> void debug(initializer_list<T> init) {
int i = 0;
for (auto x : init)
++i != init.size() ? show(x) : showendl(x);
} //初期化子リスト出力
} // namespace
using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
int main() {
int n, m;
CIN(n, m);
vvi S(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
S[i].push_back(s);
}
}
vi P;
rep(i, m) {
int p;
cin >> p;
P.push_back(p);
}
int ans = 0;
for (int onoff = 1; onoff < (1 << n); onoff++) {
//全てのonoffパターンについてbit全探索
int rec = 0; //ついてるlamp
for (int lamp = 0; lamp < m; lamp++) {
int num = 0; // on
for (int x : S[lamp]) {
// lampの各スイッチ設定について
if (1 << x & onoff)
num++;
}
if (num % 2 == P[lamp]) {
rec++;
// DEBUG(onoff,lamp);
}
}
if (rec == m)
ans++;
}
debug(ans);
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 // 10^9+7
#define rep(i, n) for (int i = 0; i < (int)n; i++)
/* 一括cin */
template <class H> void CIN(H &h) { cin >> h; }
template <class H, class... T> void CIN(H &h, T &...t) {
cin >> h;
CIN(t...);
}
/* デバッグ */
namespace /* debug */ {
#define DEBUG(...) \
do { \
cout << #__VA_ARGS__ << " = "; \
debug(__VA_ARGS__); \
} while (0) //変数
#define ldebug(...) \
do { \
cout << "[" << setw(3) << __LINE__ << "] "; \
debug(__VA_ARGS__); \
} while (0) //行数
#define lDEBUG(...) \
do { \
cout << "[" << setw(3) << __LINE__ << "] " << #__VA_ARGS__ << " = "; \
debug(__VA_ARGS__); \
} while (0) //変数, 行数
template <class T> void show(T &x) { cout << x << " "; } //出力
template <class T> void showendl(T &x) { cout << x << endl; } //出力改行
template <class P, class Q> void show(pair<P, Q> &x) {
cout << "(" << x.first << ", " << x.second << ") ";
} // pair出力
template <class P, class Q> void showendl(pair<P, Q> &x) {
cout << "(" << x.first << ", " << x.second << ")" << endl;
} // pair出力改行
template <class H> void debug(H &&h) { showendl(h); } //引数1つ
template <class H, class... Ts> void debug(H &&h, Ts &&...ts) {
show(h);
debug(forward<Ts>(ts)...);
} //可変引数
template <class T> void debug(vector<T> &vt) {
int i = 0;
for (auto x : vt)
++i != vt.size() ? show(x) : showendl(x);
} // vector出力
template <class T> void debug(initializer_list<T> init) {
int i = 0;
for (auto x : init)
++i != init.size() ? show(x) : showendl(x);
} //初期化子リスト出力
} // namespace
using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
int main() {
int n, m;
CIN(n, m);
vvi S(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
S[i].push_back(s);
}
}
vi P;
rep(i, m) {
int p;
cin >> p;
P.push_back(p);
}
int ans = 0;
for (int onoff = 0; onoff < (1 << n); onoff++) {
//全てのonoffパターンについてbit全探索
int rec = 0; //ついてるlamp
for (int lamp = 0; lamp < m; lamp++) {
int num = 0; // on
for (int x : S[lamp]) {
// lampの各スイッチ設定について
if (1 << x & onoff)
num++;
}
if (num % 2 == P[lamp]) {
rec++;
// DEBUG(onoff,lamp);
}
}
if (rec == m)
ans++;
}
debug(ans);
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 840,996 | 840,997 | u271743799 | cpp |
p03031 | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define cout(x) cout << x << endl
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;
int main() {
//読み込み
int n, m;
cin >> n >> m;
vi k(m);
Mat s(m);
rep(i, m) {
cin >> k[i];
rep(j, k[i]) {
int s_;
cin >> s_;
s[i].push_back(s_);
}
}
vi p(m);
rep(i, m) cin >> p[i];
//スイッチの状態の組み合わせ(最大1024通り)を全探索.
bool can = true;
int ans;
for (int t = 0; t < (1 << n); ++t) {
can = true;
bitset<11> ss(t);
for (int i = 0; i < m; ++i) {
int sum = 0;
for (int j = 0; j < k[i]; ++j) {
if (ss.test(s[i][j] - 1))
sum += 1;
}
if (p[i] != sum % 2) {
can = false;
break;
}
}
if (can)
ans += 1;
}
cout(ans);
return 0;
} | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define cout(x) cout << x << endl
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;
int main() {
//読み込み
int n, m;
cin >> n >> m;
vi k(m);
Mat s(m);
rep(i, m) {
cin >> k[i];
rep(j, k[i]) {
int s_;
cin >> s_;
s[i].push_back(s_);
}
}
vi p(m);
rep(i, m) cin >> p[i];
//スイッチの状態の組み合わせ(最大1024通り)を全探索.
bool can = true;
int ans = 0;
for (int t = 0; t < (1 << n); ++t) {
can = true;
bitset<11> ss(t);
for (int i = 0; i < m; ++i) {
int sum = 0;
for (int j = 0; j < k[i]; ++j) {
if (ss.test(s[i][j] - 1))
sum += 1;
}
if (p[i] != sum % 2) {
can = false;
break;
}
}
if (can)
ans += 1;
}
cout(ans);
return 0;
} | [
"variable_declaration.value.change"
] | 841,009 | 841,010 | u000134728 | cpp |
p03031 | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define cout(x) cout << x << endl
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;
int main() {
//読み込み
int n, m;
cin >> n >> m;
vi k(m);
Mat s(m);
rep(i, m) {
cin >> k[i];
rep(j, k[i]) {
int s_;
cin >> s_;
s[i].push_back(s_);
}
}
vi p(m);
rep(i, m) cin >> p[i];
//スイッチの状態の組み合わせ(最大1024通り)を全探索.
bool can = true;
int ans;
for (int t = 0; t < (1 << n); ++t) {
can = true;
bitset<10> ss = t;
for (int i = 0; i < m; ++i) {
int sum = 0;
for (int j = 0; j < k[i]; ++j) {
if (ss.test(s[i][j] - 1))
sum += 1;
}
if (p[i] != sum % 2) {
can = false;
break;
}
}
if (can)
ans += 1;
}
cout(ans);
return 0;
} | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define cout(x) cout << x << endl
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using Mat = vector<vector<int>>;
int main() {
//読み込み
int n, m;
cin >> n >> m;
vi k(m);
Mat s(m);
rep(i, m) {
cin >> k[i];
rep(j, k[i]) {
int s_;
cin >> s_;
s[i].push_back(s_);
}
}
vi p(m);
rep(i, m) cin >> p[i];
//スイッチの状態の組み合わせ(最大1024通り)を全探索.
bool can = true;
int ans = 0;
for (int t = 0; t < (1 << n); ++t) {
can = true;
bitset<11> ss(t);
for (int i = 0; i < m; ++i) {
int sum = 0;
for (int j = 0; j < k[i]; ++j) {
if (ss.test(s[i][j] - 1))
sum += 1;
}
if (p[i] != sum % 2) {
can = false;
break;
}
}
if (can)
ans += 1;
}
cout(ans);
return 0;
} | [
"variable_declaration.value.change",
"literal.number.change"
] | 841,011 | 841,010 | u000134728 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「sからnまで」の降順の繰り返し
typedef long long ll;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
int main() {
int n, m, ans = 0;
cin >> n >> m;
vector<int> k(m), p(m);
vector<vector<int>> s(m, vector<int>(10));
rep(i, m) {
cin >> k[i];
rep(j, k[i]) {
cin >> s[i][j];
s[i][j]--;
}
}
rep(i, m) cin >> p[i];
rep(i, 1 << n) {
bool jdg = true;
rep(j, m) {
int cnt = 0;
rep(l, k[m]) {
if (i & (1 << s[j][l])) {
cnt++;
}
}
if (cnt % 2 != p[j])
jdg = false;
}
if (jdg)
ans++;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
// rep…「0からn-1まで」の繰り返し
#define rep2(i, s, n) for (long long i = s; i <= (long long)(n); i++)
// rep2…「sからnまで」の繰り返し
#define repr(i, s, n) for (long long i = s; i >= (long long)(n); i--)
// repr…「sからnまで」の降順の繰り返し
typedef long long ll;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
int main() {
int n, m, ans = 0;
cin >> n >> m;
vector<int> k(m), p(m);
vector<vector<int>> s(m, vector<int>(10));
rep(i, m) {
cin >> k[i];
rep(j, k[i]) {
cin >> s[i][j];
s[i][j]--;
}
}
rep(i, m) cin >> p[i];
rep(i, 1 << n) {
bool jdg = true;
rep(j, m) {
int cnt = 0;
rep(l, k[j]) {
if (i & (1 << s[j][l])) {
cnt++;
}
}
if (cnt % 2 != p[j])
jdg = false;
}
if (jdg)
ans++;
}
cout << ans << endl;
}
| [
"identifier.change"
] | 841,016 | 841,017 | u931071094 | cpp |
p03031 | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
out << v[i] << " ";
out << "\n";
return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N>> &v) {
for (size_t i = 0; i < v.size(); ++i)
out << "(" << v[i].first << ", " << v[i].second << ") ";
out << "\n";
return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T>> &v) {
for (size_t i = 0; i < v.size(); ++i) {
for (size_t j = 0; j < v[i].size(); ++j) {
out << v[i][j] << " ";
}
out << "\n";
}
return out;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vector<vector<int>> switches(m + 1, vector<int>());
int k;
for (int i = 1; i <= m; ++i) {
cin >> k;
int s;
for (int j = 0; j < k; ++j) {
cin >> s;
switches[i].push_back(s);
}
}
vector<int> p(m + 1);
for (int i = 1; i <= m; ++i) {
cin >> p[i];
}
int ways = 0;
for (int i = 1; i < (1 << n); ++i) {
vector<int> curr(n + 1);
for (int j = 0; j < n; ++j) {
if (i & (1 << j)) {
curr[j + 1] = 1;
}
}
bool valid = true;
for (int j = 1; j <= m; ++j) {
int on = 0;
for (int k = 0; k < switches[j].size(); ++k) {
if (curr[switches[j][k]] == 1) {
++on;
}
}
if (on % 2 != p[j]) {
valid = false;
break;
}
}
if (valid) {
++ways;
}
}
cout << ways << "\n";
return 0;
} | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
out << v[i] << " ";
out << "\n";
return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N>> &v) {
for (size_t i = 0; i < v.size(); ++i)
out << "(" << v[i].first << ", " << v[i].second << ") ";
out << "\n";
return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T>> &v) {
for (size_t i = 0; i < v.size(); ++i) {
for (size_t j = 0; j < v[i].size(); ++j) {
out << v[i][j] << " ";
}
out << "\n";
}
return out;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vector<vector<int>> switches(m + 1, vector<int>());
int k;
for (int i = 1; i <= m; ++i) {
cin >> k;
int s;
for (int j = 0; j < k; ++j) {
cin >> s;
switches[i].push_back(s);
}
}
vector<int> p(m + 1);
for (int i = 1; i <= m; ++i) {
cin >> p[i];
}
int ways = 0;
for (int i = 0; i < (1 << n); ++i) {
vector<int> curr(n + 1);
for (int j = 0; j < n; ++j) {
if (i & (1 << j)) {
curr[j + 1] = 1;
}
}
bool valid = true;
for (int j = 1; j <= m; ++j) {
int on = 0;
for (int k = 0; k < switches[j].size(); ++k) {
if (curr[switches[j][k]] == 1) {
++on;
}
}
if (on % 2 != p[j]) {
valid = false;
break;
}
}
if (valid) {
++ways;
}
}
cout << ways << "\n";
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 841,022 | 841,023 | u314543767 | cpp |
p03031 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
// O(MN)
vector<int> s[M];
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int x;
cin >> x;
s[j].push_back(x - 1);
}
}
// O(M)
int p[M];
for (int l = 0; l < M; l++) {
cin >> p[l];
}
// O(MN * 2^N)
int num = 0;
for (int b = 0; b < (1 << N); b++) {
// Each b contains info for the ith switch at bit position i from right
bool good = true;
for (int c = 0; c < M; c++) {
// For each light
int sum = 0;
for (int sw : s[c]) {
// For each switch connected to light
// Note: != takes precedence over &, be careful!
if ((b >> sw) & 1) {
++sum;
}
}
sum %= 2;
if (sum != p[c]) {
good = false;
}
}
if (good) {
num++;
}
}
cout << num << endl;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
// O(MN)
vector<int> s[M];
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int x;
cin >> x;
s[i].push_back(x - 1); // Wow. This one thing can ruin everything.
}
}
// O(M)
int p[M];
for (int l = 0; l < M; l++) {
cin >> p[l];
}
// O(MN * 2^N)
int num = 0;
for (int b = 0; b < (1 << N); b++) {
// Each b contains info for the ith switch at bit position i from right
bool good = true;
for (int c = 0; c < M; c++) {
// For each light
int sum = 0;
for (int sw : s[c]) {
// For each switch connected to light
// Note: != takes precedence over &, be careful!
if ((b >> sw) & 1) {
++sum;
}
}
sum %= 2;
if (sum != p[c]) {
good = false;
}
}
if (good) {
num++;
}
}
cout << num << endl;
} | [
"identifier.change",
"variable_access.subscript.index.change"
] | 841,024 | 841,025 | u376616698 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<int> k(M);
vector<vector<int>> s(N);
for (int i = 0; i < M; i++) {
cin >> k[i];
s[i].resize(k[i]);
for (int j = 0; j < k[i]; j++) {
cin >> s[i][j];
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p[i];
int ans = 0;
for (int bits = 0; bits < (1 << N); bits++) {
vector<bool> s_on(N, false);
bool ok = true;
for (int i = 0; i < N; i++) {
if ((bits >> i) & 1) {
s_on[i] = true;
}
}
for (int i = 0; i < M; i++) {
int sum = 0;
for (int j = 0; j < k[i]; j++) {
if (s_on[s[i][j] - 1])
sum++;
}
if (sum % 2 != p[i])
ok = false;
}
if (ok)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
int main() {
int N, M;
cin >> N >> M;
vector<int> k(M);
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
cin >> k[i];
s[i].resize(k[i]);
for (int j = 0; j < k[i]; j++) {
cin >> s[i][j];
}
}
vector<int> p(M);
for (int i = 0; i < M; i++)
cin >> p[i];
int ans = 0;
for (int bits = 0; bits < (1 << N); bits++) {
vector<bool> s_on(N, false);
bool ok = true;
for (int i = 0; i < N; i++) {
if ((bits >> i) & 1) {
s_on[i] = true;
}
}
for (int i = 0; i < M; i++) {
int sum = 0;
for (int j = 0; j < k[i]; j++) {
if (s_on[s[i][j] - 1])
sum++;
}
if (sum % 2 != p[i])
ok = false;
}
if (ok)
ans++;
}
cout << ans << endl;
return 0;
} | [] | 841,026 | 841,027 | u414689295 | cpp |
p03031 | #include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (long long i = 0; i < n; i++)
//#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> k(N);
vector<vector<int>> s(M);
rep(i, M) {
cin >> k[i];
rep(j, k[i]) {
int x;
cin >> x;
s[i].push_back(x);
}
}
vector<int> p(M);
rep(i, M) cin >> p[i];
int ans = 0;
rep(i, 1 << N) {
vector<int> v;
rep(j, N) {
if ((i >> j) & 1)
v.push_back(j);
}
bool f = true;
rep(kk, M) {
int fl = 0;
rep(l, k[kk]) {
rep(m, v.size()) {
if (s[kk][l] == v[m])
fl += 1;
}
}
if (fl % 2 != p[kk])
f = false;
}
if (f)
ans += 1;
}
cout << ans << endl;
return 0;
} | #include <cmath>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (long long i = 0; i < n; i++)
//#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> k(N);
vector<vector<int>> s(M);
rep(i, M) {
cin >> k[i];
rep(j, k[i]) {
int x;
cin >> x;
s[i].push_back(x);
}
}
vector<int> p(M);
rep(i, M) cin >> p[i];
int ans = 0;
rep(i, 1 << N) {
vector<int> v;
rep(j, N) {
if ((i >> j) & 1)
v.push_back(j);
}
bool f = true;
rep(kk, M) {
int fl = 0;
rep(l, k[kk]) {
rep(m, v.size()) {
if (s[kk][l] == v[m] + 1)
fl += 1;
}
}
if (fl % 2 != p[kk])
f = false;
}
if (f)
ans += 1;
}
cout << ans << endl;
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 841,032 | 841,033 | u214864255 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
a--;
s[i].push_back(a);
}
}
vector<int> p(m);
ll ans = 0;
rep(i, m) cin >> p[i];
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
rep(i, m) {
int cn = 0;
for (auto v : s[i]) {
if (bit && (1 << v))
cn++;
}
if (cn % 2 != p[i])
ok = false;
}
if (ok)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
a--;
s[i].push_back(a);
}
}
vector<int> p(m);
ll ans = 0;
rep(i, m) cin >> p[i];
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
rep(i, m) {
int cn = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
cn++;
}
if (cn % 2 != p[i])
ok = false;
}
if (ok)
ans++;
}
cout << ans << endl;
} | [
"control_flow.branch.if.condition.change"
] | 841,034 | 841,035 | u233586402 | cpp |
p03031 | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int f[11][11], b[11];
int main() {
int n, m, i, j, k, ans = 0;
cin >> n >> m;
int lim = (1 << n);
for (i = 1; i <= m; i++) {
cin >> k;
for (j = 1; j <= k; j++)
cin >> f[i][j];
}
for (i = 1; i <= m; i++)
cin >> b[i];
for (i = 0; i < lim; i++) {
int flg = 1;
for (j = 1; j <= m; j++) {
int t = b[j];
for (k = 1; k <= n; k++) {
t ^= (i >> (f[j][k] - 1));
}
if (t) {
flg = 0;
break;
}
}
if (flg)
ans++;
}
cout << ans;
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
int f[11][11], b[11];
int main() {
int n, m, i, j, k, ans = 0;
cin >> n >> m;
int lim = (1 << n);
for (i = 1; i <= m; i++) {
cin >> k;
for (j = 1; j <= k; j++)
cin >> f[i][j];
}
for (i = 1; i <= m; i++)
cin >> b[i];
for (i = 0; i < lim; i++) {
int flg = 1;
for (j = 1; j <= m; j++) {
int t = b[j];
for (k = 1; k <= n; k++) {
t ^= ((i >> (f[j][k] - 1)) & 1);
}
if (t) {
flg = 0;
break;
}
}
if (flg)
ans++;
}
cout << ans;
}
| [] | 841,040 | 841,041 | u973991908 | cpp |
p03031 | #include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <float.h>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define pLL pair<LL, LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<LL, vector<LL>, greater<LL>>
#define pb push_back
#define vecLL vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e, v) for (auto e : v)
#define rep(i, a, n) for (LL i = a; i < n; i++)
#define Arep(i, a, n) for (i = a; i < n; i++)
#define MOD 1000000007
#define INF LLONG_MAX / 2
#define DINF DBL_MAX / 2
using namespace std;
/*↓マイライブラリ↓*/
// clock_t start = clock();
//
// clock_t end = clock();
//
// const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
// 1000.0; printf("time %lf[ms]\n", time);
LL linp() {
LL x;
scanf("%lld", &x);
return x;
}
map<LL, LL> factalization(LL N) {
map<LL, LL> fac;
LL oriN = N;
LL div = 1;
for (LL i = 2; i * i <= N; ++i) {
while (N % i == 0) {
fac[i]++;
div *= i;
N /= i;
}
}
if (oriN / div != 1) {
fac[oriN / div]++;
}
return fac;
}
vecLL bit(LL i, LL N) {
vecLL biti(N);
rep(x, 0, N) { biti[N - 1 - x] = (i >> x) & 1; }
return biti;
}
void swap(LL &a, LL &b) {
LL t = a;
a = b;
b = t;
return;
}
LL mod(LL i) {
LL mi = i % MOD;
if (mi < 0)
mi += MOD;
return mi;
}
LL digit(LL x, LL n) {
LL count = 1;
while (x >= n) {
x = x / n;
count++;
}
return count;
}
LL gcd(LL i, LL j) {
if (j != 0)
return gcd(j, i % j);
else
return i;
}
pLL extgcd(LL a, LL b) { // ax+by = 1の解
pLL ans;
if (b != 0) {
pLL next = extgcd(b, a % b);
ans.first = next.second;
ans.second = next.first - (a / b) * next.second;
} else {
ans = pLL(1, 0);
}
return ans;
}
LL division(LL a, LL b, LL m) { return mod(mod(a) * mod(extgcd(b, m).first)); }
LL numperm_mod(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res = mod(res * mod(i));
}
return mod(res);
}
LL numperm(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res *= i;
}
return res;
}
LL pow_mod(LL x, LL y) {
x = mod(x);
if (y == 1) {
return mod(x);
}
LL res = mod(pow_mod(mod(x * x), y / 2));
if (y % 2 == 0) {
return res;
} else {
return mod(x * res);
}
}
LL pow(LL x, LL y) {
if (y == 1) {
return x;
}
if (y % 2 == 0) {
return pow(x * x, y / 2);
} else {
return x * pow(x * x, y / 2);
}
}
bool isPrime(LL X) {
rep(i, 2, (LL)(sqrt(X) + 1)) {
if (X % i == 0) {
return false;
}
}
return true;
}
vecLL Eratosthenes(LL n) { //素数のベクトルを返す
bool isPrime[n];
fill(isPrime, isPrime + n, true);
isPrime[0] = isPrime[1] = false;
rep(i, 2, sqrt(n) + 1) {
if (isPrime[i]) {
for (LL j = 2 * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
vecLL P;
rep(i, 2, n + 1) {
if (isPrime[i]) {
P.push_back(i);
}
}
return P;
}
struct edge { //枝
LL to, cost;
double dcost; //コストが整数でない場合に使う
};
struct vertex { //頂点(枝付き)
LL key;
double dkey; //キーが整数でない場合に使う
vector<edge> edges; //頂点から伸びる枝
};
class Graph {
public:
LL V; //頂点数
vertex *vertices; //グラフ
Graph(LL v) { //頂点数を指定してグラフの初期化
V = v; //頂点数
vertices = new vertex[V]; //頂点集合
rep(i, 0, V) {
vertices[i].key = -1; //キー初期値は-1
vertices[i].dkey = -1; //キー初期値は-1
}
}
void setDE(LL i, LL j, LL cos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.cost = cos;
vertices[i].edges.push_back(e);
return;
}
void setDE(LL i, LL j, double dcos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.dcost = dcos;
vertices[i].edges.push_back(e);
return;
}
void setUDE(LL i, LL j, LL cos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.cost = ej.cost = cos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setUDE(LL i, LL j, double dcos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.dcost = ej.dcost = dcos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setKey(LL i, LL newKey) { //キー変更
vertices[i].key = newKey;
}
void setKey(LL i, double newKey) { //キー変更
vertices[i].key = newKey;
}
edge getEdge(LL i, LL j) {
rep(a, 0, vertices[i].edges.size()) {
if (vertices[i].edges[a].to == j) {
return vertices[i].edges[a];
}
}
return (edge){j, INF, DINF}; //なければ,コストINFの枝を返す
}
void bellman_ford(LL s, LL b[]) {
fill(b, b + V, INF);
b[s] = 0;
while (true) {
bool update = false;
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
edge e = vertices[i].edges[j];
if (b[e.to] > b[i] + e.cost) {
b[e.to] = b[i] + e.cost;
update = true;
}
}
}
if (!update)
break;
}
return;
}
void dijkstra(LL s,
LL d[]) { //ダイクストラ(始点を入力とし、各点への最小距離を返す)
priority_queue<pLL, vector<pLL>, greater<pLL>> que;
fill(d, d + V, INF);
d[s] = 0;
que.push(pLL(0, s));
while (!que.empty()) {
pLL p = que.top();
que.pop();
LL v = p.second;
if (d[v] < p.first)
continue;
rep(i, 0, vertices[v].edges.size()) {
edge e = vertices[v].edges[i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(pLL(d[e.to], e.to));
}
}
}
return;
}
void warshall_floyd(LL **w) {
rep(i, 0, V) {
rep(j, 0, V) { w[i][j] = INF; }
}
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
w[i][vertices[i].edges[j].to] = vertices[i].edges[j].cost;
}
}
rep(i, 0, V) { w[i][i] = 0; }
rep(i, 0, V) {
rep(j, 0, V) {
rep(k, 0, V) { w[i][j] = min(w[i][j], w[i][k] + w[k][j]); }
}
}
}
};
class UF {
public:
LL N;
LL *par;
LL *rank;
UF(LL n) {
N = n;
par = new LL[N];
rank = new LL[N];
rep(i, 0, N) {
par[i] = i;
rank[i] = i;
}
return;
}
LL root(LL x) {
if (x == par[x])
return x;
else
return par[x] = root(par[x]);
}
bool same(LL x, LL y) { return (root(x) == root(y)); }
void Union(LL x, LL y) {
LL rtx = root(x);
LL rty = root(y);
if (rank[rtx] < rank[rty]) {
par[rtx] = rty;
} else {
par[rty] = rtx;
if (rank[rtx] == rank[rty]) {
rank[rtx]++;
}
}
}
};
class ST {};
/*↑マイライブラリ↑*/
LL solveA() {
LL A, P;
cin >> A >> P;
cout << (3 * A + P) / 2;
return 0;
}
bool comp(const pair<string, pLL> &sp1, const pair<string, pLL> &sp2) {
if (sp1.first < sp2.first) {
return true;
} else if (sp1.first == sp2.first) {
return sp1.second.first > sp2.second.first;
} else {
return false;
}
}
LL solveB() {
LL N = linp();
pair<string, pLL> SP[N];
rep(i, 0, N) {
string s;
LL p;
cin >> s >> p;
SP[i] = pair<string, pLL>(s, pLL(p, i + 1));
}
sort(SP, SP + N, comp);
rep(i, 0, N) { cout << SP[i].second.second << endl; }
return 0;
}
LL solveC() {
LL N, M;
cin >> N >> M;
vector<LL> light[M];
rep(i, 0, M) {
LL k = linp();
rep(j, 0, k) { light[i].push_back(linp() - 1); }
}
LL p[M];
rep(i, 0, M) { cin >> p[i]; }
LL count = 0;
rep(i, 0, pow(2, N)) {
vecLL biti;
biti = bit(i, N);
bool isOK = true;
rep(j, 0, M) {
LL onoff = 0;
rep(k, 0, light[j].size()) { onoff = biti[light[j][k]]; }
if (p[j] != onoff % 2) {
isOK = false;
}
}
if (isOK) {
count++;
}
}
cout << count;
return 0;
}
LL solveD() { return 0; }
LL solveE() { return 0; }
signed main() {
// solveA();
// solveB();
solveC();
// solveD();
// solveE();
return 0;
}
| #include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <float.h>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define pLL pair<LL, LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<LL, vector<LL>, greater<LL>>
#define pb push_back
#define vecLL vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e, v) for (auto e : v)
#define rep(i, a, n) for (LL i = a; i < n; i++)
#define Arep(i, a, n) for (i = a; i < n; i++)
#define MOD 1000000007
#define INF LLONG_MAX / 2
#define DINF DBL_MAX / 2
using namespace std;
/*↓マイライブラリ↓*/
// clock_t start = clock();
//
// clock_t end = clock();
//
// const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
// 1000.0; printf("time %lf[ms]\n", time);
LL linp() {
LL x;
scanf("%lld", &x);
return x;
}
map<LL, LL> factalization(LL N) {
map<LL, LL> fac;
LL oriN = N;
LL div = 1;
for (LL i = 2; i * i <= N; ++i) {
while (N % i == 0) {
fac[i]++;
div *= i;
N /= i;
}
}
if (oriN / div != 1) {
fac[oriN / div]++;
}
return fac;
}
vecLL bit(LL i, LL N) {
vecLL biti(N);
rep(x, 0, N) { biti[N - 1 - x] = (i >> x) & 1; }
return biti;
}
void swap(LL &a, LL &b) {
LL t = a;
a = b;
b = t;
return;
}
LL mod(LL i) {
LL mi = i % MOD;
if (mi < 0)
mi += MOD;
return mi;
}
LL digit(LL x, LL n) {
LL count = 1;
while (x >= n) {
x = x / n;
count++;
}
return count;
}
LL gcd(LL i, LL j) {
if (j != 0)
return gcd(j, i % j);
else
return i;
}
pLL extgcd(LL a, LL b) { // ax+by = 1の解
pLL ans;
if (b != 0) {
pLL next = extgcd(b, a % b);
ans.first = next.second;
ans.second = next.first - (a / b) * next.second;
} else {
ans = pLL(1, 0);
}
return ans;
}
LL division(LL a, LL b, LL m) { return mod(mod(a) * mod(extgcd(b, m).first)); }
LL numperm_mod(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res = mod(res * mod(i));
}
return mod(res);
}
LL numperm(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res *= i;
}
return res;
}
LL pow_mod(LL x, LL y) {
x = mod(x);
if (y == 1) {
return mod(x);
}
LL res = mod(pow_mod(mod(x * x), y / 2));
if (y % 2 == 0) {
return res;
} else {
return mod(x * res);
}
}
LL pow(LL x, LL y) {
if (y == 1) {
return x;
}
if (y % 2 == 0) {
return pow(x * x, y / 2);
} else {
return x * pow(x * x, y / 2);
}
}
bool isPrime(LL X) {
rep(i, 2, (LL)(sqrt(X) + 1)) {
if (X % i == 0) {
return false;
}
}
return true;
}
vecLL Eratosthenes(LL n) { //素数のベクトルを返す
bool isPrime[n];
fill(isPrime, isPrime + n, true);
isPrime[0] = isPrime[1] = false;
rep(i, 2, sqrt(n) + 1) {
if (isPrime[i]) {
for (LL j = 2 * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
vecLL P;
rep(i, 2, n + 1) {
if (isPrime[i]) {
P.push_back(i);
}
}
return P;
}
struct edge { //枝
LL to, cost;
double dcost; //コストが整数でない場合に使う
};
struct vertex { //頂点(枝付き)
LL key;
double dkey; //キーが整数でない場合に使う
vector<edge> edges; //頂点から伸びる枝
};
class Graph {
public:
LL V; //頂点数
vertex *vertices; //グラフ
Graph(LL v) { //頂点数を指定してグラフの初期化
V = v; //頂点数
vertices = new vertex[V]; //頂点集合
rep(i, 0, V) {
vertices[i].key = -1; //キー初期値は-1
vertices[i].dkey = -1; //キー初期値は-1
}
}
void setDE(LL i, LL j, LL cos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.cost = cos;
vertices[i].edges.push_back(e);
return;
}
void setDE(LL i, LL j, double dcos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.dcost = dcos;
vertices[i].edges.push_back(e);
return;
}
void setUDE(LL i, LL j, LL cos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.cost = ej.cost = cos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setUDE(LL i, LL j, double dcos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.dcost = ej.dcost = dcos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setKey(LL i, LL newKey) { //キー変更
vertices[i].key = newKey;
}
void setKey(LL i, double newKey) { //キー変更
vertices[i].key = newKey;
}
edge getEdge(LL i, LL j) {
rep(a, 0, vertices[i].edges.size()) {
if (vertices[i].edges[a].to == j) {
return vertices[i].edges[a];
}
}
return (edge){j, INF, DINF}; //なければ,コストINFの枝を返す
}
void bellman_ford(LL s, LL b[]) {
fill(b, b + V, INF);
b[s] = 0;
while (true) {
bool update = false;
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
edge e = vertices[i].edges[j];
if (b[e.to] > b[i] + e.cost) {
b[e.to] = b[i] + e.cost;
update = true;
}
}
}
if (!update)
break;
}
return;
}
void dijkstra(LL s,
LL d[]) { //ダイクストラ(始点を入力とし、各点への最小距離を返す)
priority_queue<pLL, vector<pLL>, greater<pLL>> que;
fill(d, d + V, INF);
d[s] = 0;
que.push(pLL(0, s));
while (!que.empty()) {
pLL p = que.top();
que.pop();
LL v = p.second;
if (d[v] < p.first)
continue;
rep(i, 0, vertices[v].edges.size()) {
edge e = vertices[v].edges[i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(pLL(d[e.to], e.to));
}
}
}
return;
}
void warshall_floyd(LL **w) {
rep(i, 0, V) {
rep(j, 0, V) { w[i][j] = INF; }
}
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
w[i][vertices[i].edges[j].to] = vertices[i].edges[j].cost;
}
}
rep(i, 0, V) { w[i][i] = 0; }
rep(i, 0, V) {
rep(j, 0, V) {
rep(k, 0, V) { w[i][j] = min(w[i][j], w[i][k] + w[k][j]); }
}
}
}
};
class UF {
public:
LL N;
LL *par;
LL *rank;
UF(LL n) {
N = n;
par = new LL[N];
rank = new LL[N];
rep(i, 0, N) {
par[i] = i;
rank[i] = i;
}
return;
}
LL root(LL x) {
if (x == par[x])
return x;
else
return par[x] = root(par[x]);
}
bool same(LL x, LL y) { return (root(x) == root(y)); }
void Union(LL x, LL y) {
LL rtx = root(x);
LL rty = root(y);
if (rank[rtx] < rank[rty]) {
par[rtx] = rty;
} else {
par[rty] = rtx;
if (rank[rtx] == rank[rty]) {
rank[rtx]++;
}
}
}
};
class ST {};
/*↑マイライブラリ↑*/
LL solveA() {
LL A, P;
cin >> A >> P;
cout << (3 * A + P) / 2;
return 0;
}
bool comp(const pair<string, pLL> &sp1, const pair<string, pLL> &sp2) {
if (sp1.first < sp2.first) {
return true;
} else if (sp1.first == sp2.first) {
return sp1.second.first > sp2.second.first;
} else {
return false;
}
}
LL solveB() {
LL N = linp();
pair<string, pLL> SP[N];
rep(i, 0, N) {
string s;
LL p;
cin >> s >> p;
SP[i] = pair<string, pLL>(s, pLL(p, i + 1));
}
sort(SP, SP + N, comp);
rep(i, 0, N) { cout << SP[i].second.second << endl; }
return 0;
}
LL solveC() {
LL N, M;
cin >> N >> M;
vector<LL> light[M];
rep(i, 0, M) {
LL k = linp();
rep(j, 0, k) { light[i].push_back(linp() - 1); }
}
LL p[M];
rep(i, 0, M) { cin >> p[i]; }
LL count = 0;
rep(i, 0, pow(2, N)) {
vecLL biti;
biti = bit(i, N);
bool isOK = true;
rep(j, 0, M) {
LL onoff = 0;
rep(k, 0, light[j].size()) { onoff += biti[light[j][k]]; }
if (p[j] != onoff % 2) {
isOK = false;
break;
}
}
if (isOK) {
count++;
}
}
cout << count;
return 0;
}
LL solveD() { return 0; }
LL solveE() { return 0; }
signed main() {
// solveA();
// solveB();
solveC();
// solveD();
// solveE();
return 0;
}
| [
"assignment.value.change"
] | 841,042 | 841,043 | u152577008 | cpp |
p03031 | #include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <float.h>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define pLL pair<LL, LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<LL, vector<LL>, greater<LL>>
#define pb push_back
#define vecLL vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e, v) for (auto e : v)
#define rep(i, a, n) for (LL i = a; i < n; i++)
#define Arep(i, a, n) for (i = a; i < n; i++)
#define MOD 1000000007
#define INF LLONG_MAX / 2
#define DINF DBL_MAX / 2
using namespace std;
/*↓マイライブラリ↓*/
// clock_t start = clock();
//
// clock_t end = clock();
//
// const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
// 1000.0; printf("time %lf[ms]\n", time);
LL linp() {
LL x;
scanf("%lld", &x);
return x;
}
map<LL, LL> factalization(LL N) {
map<LL, LL> fac;
LL oriN = N;
LL div = 1;
for (LL i = 2; i * i <= N; ++i) {
while (N % i == 0) {
fac[i]++;
div *= i;
N /= i;
}
}
if (oriN / div != 1) {
fac[oriN / div]++;
}
return fac;
}
vecLL bit(LL i, LL N) {
vecLL biti(N);
rep(x, 0, N) { biti[N - 1 - x] = (i >> x) & 1; }
return biti;
}
void swap(LL &a, LL &b) {
LL t = a;
a = b;
b = t;
return;
}
LL mod(LL i) {
LL mi = i % MOD;
if (mi < 0)
mi += MOD;
return mi;
}
LL digit(LL x, LL n) {
LL count = 1;
while (x >= n) {
x = x / n;
count++;
}
return count;
}
LL gcd(LL i, LL j) {
if (j != 0)
return gcd(j, i % j);
else
return i;
}
pLL extgcd(LL a, LL b) { // ax+by = 1の解
pLL ans;
if (b != 0) {
pLL next = extgcd(b, a % b);
ans.first = next.second;
ans.second = next.first - (a / b) * next.second;
} else {
ans = pLL(1, 0);
}
return ans;
}
LL division(LL a, LL b, LL m) { return mod(mod(a) * mod(extgcd(b, m).first)); }
LL numperm_mod(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res = mod(res * mod(i));
}
return mod(res);
}
LL numperm(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res *= i;
}
return res;
}
LL pow_mod(LL x, LL y) {
x = mod(x);
if (y == 1) {
return mod(x);
}
LL res = mod(pow_mod(mod(x * x), y / 2));
if (y % 2 == 0) {
return res;
} else {
return mod(x * res);
}
}
LL pow(LL x, LL y) {
if (y == 1) {
return x;
}
if (y % 2 == 0) {
return pow(x * x, y / 2);
} else {
return x * pow(x * x, y / 2);
}
}
bool isPrime(LL X) {
rep(i, 2, (LL)(sqrt(X) + 1)) {
if (X % i == 0) {
return false;
}
}
return true;
}
vecLL Eratosthenes(LL n) { //素数のベクトルを返す
bool isPrime[n];
fill(isPrime, isPrime + n, true);
isPrime[0] = isPrime[1] = false;
rep(i, 2, sqrt(n) + 1) {
if (isPrime[i]) {
for (LL j = 2 * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
vecLL P;
rep(i, 2, n + 1) {
if (isPrime[i]) {
P.push_back(i);
}
}
return P;
}
struct edge { //枝
LL to, cost;
double dcost; //コストが整数でない場合に使う
};
struct vertex { //頂点(枝付き)
LL key;
double dkey; //キーが整数でない場合に使う
vector<edge> edges; //頂点から伸びる枝
};
class Graph {
public:
LL V; //頂点数
vertex *vertices; //グラフ
Graph(LL v) { //頂点数を指定してグラフの初期化
V = v; //頂点数
vertices = new vertex[V]; //頂点集合
rep(i, 0, V) {
vertices[i].key = -1; //キー初期値は-1
vertices[i].dkey = -1; //キー初期値は-1
}
}
void setDE(LL i, LL j, LL cos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.cost = cos;
vertices[i].edges.push_back(e);
return;
}
void setDE(LL i, LL j, double dcos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.dcost = dcos;
vertices[i].edges.push_back(e);
return;
}
void setUDE(LL i, LL j, LL cos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.cost = ej.cost = cos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setUDE(LL i, LL j, double dcos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.dcost = ej.dcost = dcos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setKey(LL i, LL newKey) { //キー変更
vertices[i].key = newKey;
}
void setKey(LL i, double newKey) { //キー変更
vertices[i].key = newKey;
}
edge getEdge(LL i, LL j) {
rep(a, 0, vertices[i].edges.size()) {
if (vertices[i].edges[a].to == j) {
return vertices[i].edges[a];
}
}
return (edge){j, INF, DINF}; //なければ,コストINFの枝を返す
}
void bellman_ford(LL s, LL b[]) {
fill(b, b + V, INF);
b[s] = 0;
while (true) {
bool update = false;
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
edge e = vertices[i].edges[j];
if (b[e.to] > b[i] + e.cost) {
b[e.to] = b[i] + e.cost;
update = true;
}
}
}
if (!update)
break;
}
return;
}
void dijkstra(LL s,
LL d[]) { //ダイクストラ(始点を入力とし、各点への最小距離を返す)
priority_queue<pLL, vector<pLL>, greater<pLL>> que;
fill(d, d + V, INF);
d[s] = 0;
que.push(pLL(0, s));
while (!que.empty()) {
pLL p = que.top();
que.pop();
LL v = p.second;
if (d[v] < p.first)
continue;
rep(i, 0, vertices[v].edges.size()) {
edge e = vertices[v].edges[i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(pLL(d[e.to], e.to));
}
}
}
return;
}
void warshall_floyd(LL **w) {
rep(i, 0, V) {
rep(j, 0, V) { w[i][j] = INF; }
}
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
w[i][vertices[i].edges[j].to] = vertices[i].edges[j].cost;
}
}
rep(i, 0, V) { w[i][i] = 0; }
rep(i, 0, V) {
rep(j, 0, V) {
rep(k, 0, V) { w[i][j] = min(w[i][j], w[i][k] + w[k][j]); }
}
}
}
};
class UF {
public:
LL N;
LL *par;
LL *rank;
UF(LL n) {
N = n;
par = new LL[N];
rank = new LL[N];
rep(i, 0, N) {
par[i] = i;
rank[i] = i;
}
return;
}
LL root(LL x) {
if (x == par[x])
return x;
else
return par[x] = root(par[x]);
}
bool same(LL x, LL y) { return (root(x) == root(y)); }
void Union(LL x, LL y) {
LL rtx = root(x);
LL rty = root(y);
if (rank[rtx] < rank[rty]) {
par[rtx] = rty;
} else {
par[rty] = rtx;
if (rank[rtx] == rank[rty]) {
rank[rtx]++;
}
}
}
};
class ST {};
/*↑マイライブラリ↑*/
LL solveA() {
LL A, P;
cin >> A >> P;
cout << (3 * A + P) / 2;
return 0;
}
bool comp(const pair<string, pLL> &sp1, const pair<string, pLL> &sp2) {
if (sp1.first < sp2.first) {
return true;
} else if (sp1.first == sp2.first) {
return sp1.second.first > sp2.second.first;
} else {
return false;
}
}
LL solveB() {
LL N = linp();
pair<string, pLL> SP[N];
rep(i, 0, N) {
string s;
LL p;
cin >> s >> p;
SP[i] = pair<string, pLL>(s, pLL(p, i + 1));
}
sort(SP, SP + N, comp);
rep(i, 0, N) { cout << SP[i].second.second << endl; }
return 0;
}
LL solveC() {
LL N, M;
cin >> N >> M;
vector<LL> light[M];
rep(i, 0, M) {
LL k = linp();
rep(j, 0, k) { light[i].push_back(linp() - 1); }
}
LL p[M];
rep(i, 0, M) { cin >> p[i]; }
LL count = 0;
rep(i, 0, pow(2, N)) {
vecLL biti;
biti = bit(i, N);
bool isOK = true;
rep(j, 0, M) {
LL onoff = 0;
rep(k, 0, light[j].size()) { onoff = biti[light[j][k]]; }
if (p[j] != onoff % 2) {
isOK = false;
break;
}
}
if (isOK) {
count++;
}
}
cout << count;
return 0;
}
LL solveD() { return 0; }
LL solveE() { return 0; }
signed main() {
// solveA();
// solveB();
solveC();
// solveD();
// solveE();
return 0;
}
| #include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <float.h>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define pLL pair<LL, LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<LL, vector<LL>, greater<LL>>
#define pb push_back
#define vecLL vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e, v) for (auto e : v)
#define rep(i, a, n) for (LL i = a; i < n; i++)
#define Arep(i, a, n) for (i = a; i < n; i++)
#define MOD 1000000007
#define INF LLONG_MAX / 2
#define DINF DBL_MAX / 2
using namespace std;
/*↓マイライブラリ↓*/
// clock_t start = clock();
//
// clock_t end = clock();
//
// const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
// 1000.0; printf("time %lf[ms]\n", time);
LL linp() {
LL x;
scanf("%lld", &x);
return x;
}
map<LL, LL> factalization(LL N) {
map<LL, LL> fac;
LL oriN = N;
LL div = 1;
for (LL i = 2; i * i <= N; ++i) {
while (N % i == 0) {
fac[i]++;
div *= i;
N /= i;
}
}
if (oriN / div != 1) {
fac[oriN / div]++;
}
return fac;
}
vecLL bit(LL i, LL N) {
vecLL biti(N);
rep(x, 0, N) { biti[N - 1 - x] = (i >> x) & 1; }
return biti;
}
void swap(LL &a, LL &b) {
LL t = a;
a = b;
b = t;
return;
}
LL mod(LL i) {
LL mi = i % MOD;
if (mi < 0)
mi += MOD;
return mi;
}
LL digit(LL x, LL n) {
LL count = 1;
while (x >= n) {
x = x / n;
count++;
}
return count;
}
LL gcd(LL i, LL j) {
if (j != 0)
return gcd(j, i % j);
else
return i;
}
pLL extgcd(LL a, LL b) { // ax+by = 1の解
pLL ans;
if (b != 0) {
pLL next = extgcd(b, a % b);
ans.first = next.second;
ans.second = next.first - (a / b) * next.second;
} else {
ans = pLL(1, 0);
}
return ans;
}
LL division(LL a, LL b, LL m) { return mod(mod(a) * mod(extgcd(b, m).first)); }
LL numperm_mod(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res = mod(res * mod(i));
}
return mod(res);
}
LL numperm(LL x, LL y) {
LL res = 1;
for (LL i = x; i >= y; i--) {
res *= i;
}
return res;
}
LL pow_mod(LL x, LL y) {
x = mod(x);
if (y == 1) {
return mod(x);
}
LL res = mod(pow_mod(mod(x * x), y / 2));
if (y % 2 == 0) {
return res;
} else {
return mod(x * res);
}
}
LL pow(LL x, LL y) {
if (y == 1) {
return x;
}
if (y % 2 == 0) {
return pow(x * x, y / 2);
} else {
return x * pow(x * x, y / 2);
}
}
bool isPrime(LL X) {
rep(i, 2, (LL)(sqrt(X) + 1)) {
if (X % i == 0) {
return false;
}
}
return true;
}
vecLL Eratosthenes(LL n) { //素数のベクトルを返す
bool isPrime[n];
fill(isPrime, isPrime + n, true);
isPrime[0] = isPrime[1] = false;
rep(i, 2, sqrt(n) + 1) {
if (isPrime[i]) {
for (LL j = 2 * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
vecLL P;
rep(i, 2, n + 1) {
if (isPrime[i]) {
P.push_back(i);
}
}
return P;
}
struct edge { //枝
LL to, cost;
double dcost; //コストが整数でない場合に使う
};
struct vertex { //頂点(枝付き)
LL key;
double dkey; //キーが整数でない場合に使う
vector<edge> edges; //頂点から伸びる枝
};
class Graph {
public:
LL V; //頂点数
vertex *vertices; //グラフ
Graph(LL v) { //頂点数を指定してグラフの初期化
V = v; //頂点数
vertices = new vertex[V]; //頂点集合
rep(i, 0, V) {
vertices[i].key = -1; //キー初期値は-1
vertices[i].dkey = -1; //キー初期値は-1
}
}
void setDE(LL i, LL j, LL cos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.cost = cos;
vertices[i].edges.push_back(e);
return;
}
void setDE(LL i, LL j, double dcos) { // i→jにコストcosの有向枝を加える
edge e;
e.to = j;
e.dcost = dcos;
vertices[i].edges.push_back(e);
return;
}
void setUDE(LL i, LL j, LL cos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.cost = ej.cost = cos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setUDE(LL i, LL j, double dcos) { //(i,j)にコストcosの無向枝を加える
edge ei, ej;
ei.to = j;
ej.to = i;
ei.dcost = ej.dcost = dcos;
vertices[i].edges.push_back(ei);
vertices[j].edges.push_back(ej);
return;
}
void setKey(LL i, LL newKey) { //キー変更
vertices[i].key = newKey;
}
void setKey(LL i, double newKey) { //キー変更
vertices[i].key = newKey;
}
edge getEdge(LL i, LL j) {
rep(a, 0, vertices[i].edges.size()) {
if (vertices[i].edges[a].to == j) {
return vertices[i].edges[a];
}
}
return (edge){j, INF, DINF}; //なければ,コストINFの枝を返す
}
void bellman_ford(LL s, LL b[]) {
fill(b, b + V, INF);
b[s] = 0;
while (true) {
bool update = false;
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
edge e = vertices[i].edges[j];
if (b[e.to] > b[i] + e.cost) {
b[e.to] = b[i] + e.cost;
update = true;
}
}
}
if (!update)
break;
}
return;
}
void dijkstra(LL s,
LL d[]) { //ダイクストラ(始点を入力とし、各点への最小距離を返す)
priority_queue<pLL, vector<pLL>, greater<pLL>> que;
fill(d, d + V, INF);
d[s] = 0;
que.push(pLL(0, s));
while (!que.empty()) {
pLL p = que.top();
que.pop();
LL v = p.second;
if (d[v] < p.first)
continue;
rep(i, 0, vertices[v].edges.size()) {
edge e = vertices[v].edges[i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(pLL(d[e.to], e.to));
}
}
}
return;
}
void warshall_floyd(LL **w) {
rep(i, 0, V) {
rep(j, 0, V) { w[i][j] = INF; }
}
rep(i, 0, V) {
rep(j, 0, vertices[i].edges.size()) {
w[i][vertices[i].edges[j].to] = vertices[i].edges[j].cost;
}
}
rep(i, 0, V) { w[i][i] = 0; }
rep(i, 0, V) {
rep(j, 0, V) {
rep(k, 0, V) { w[i][j] = min(w[i][j], w[i][k] + w[k][j]); }
}
}
}
};
class UF {
public:
LL N;
LL *par;
LL *rank;
UF(LL n) {
N = n;
par = new LL[N];
rank = new LL[N];
rep(i, 0, N) {
par[i] = i;
rank[i] = i;
}
return;
}
LL root(LL x) {
if (x == par[x])
return x;
else
return par[x] = root(par[x]);
}
bool same(LL x, LL y) { return (root(x) == root(y)); }
void Union(LL x, LL y) {
LL rtx = root(x);
LL rty = root(y);
if (rank[rtx] < rank[rty]) {
par[rtx] = rty;
} else {
par[rty] = rtx;
if (rank[rtx] == rank[rty]) {
rank[rtx]++;
}
}
}
};
class ST {};
/*↑マイライブラリ↑*/
LL solveA() {
LL A, P;
cin >> A >> P;
cout << (3 * A + P) / 2;
return 0;
}
bool comp(const pair<string, pLL> &sp1, const pair<string, pLL> &sp2) {
if (sp1.first < sp2.first) {
return true;
} else if (sp1.first == sp2.first) {
return sp1.second.first > sp2.second.first;
} else {
return false;
}
}
LL solveB() {
LL N = linp();
pair<string, pLL> SP[N];
rep(i, 0, N) {
string s;
LL p;
cin >> s >> p;
SP[i] = pair<string, pLL>(s, pLL(p, i + 1));
}
sort(SP, SP + N, comp);
rep(i, 0, N) { cout << SP[i].second.second << endl; }
return 0;
}
LL solveC() {
LL N, M;
cin >> N >> M;
vector<LL> light[M];
rep(i, 0, M) {
LL k = linp();
rep(j, 0, k) { light[i].push_back(linp() - 1); }
}
LL p[M];
rep(i, 0, M) { cin >> p[i]; }
LL count = 0;
rep(i, 0, pow(2, N)) {
vecLL biti;
biti = bit(i, N);
bool isOK = true;
rep(j, 0, M) {
LL onoff = 0;
rep(k, 0, light[j].size()) { onoff += biti[light[j][k]]; }
if (p[j] != onoff % 2) {
isOK = false;
break;
}
}
if (isOK) {
count++;
}
}
cout << count;
return 0;
}
LL solveD() { return 0; }
LL solveE() { return 0; }
signed main() {
// solveA();
// solveB();
solveC();
// solveD();
// solveE();
return 0;
}
| [
"assignment.value.change"
] | 841,044 | 841,043 | u152577008 | cpp |
p03031 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
typedef long long ll;
#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template <typename T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
// return b ? gcd(b, a % b) : a;
}
template <typename T> T lcm(T a, T b) {
ll g = gcd(a, b);
return a / g * b; // Be careful not to overflow
// return a * b / gcd(a, b);
}
template <typename T> T binarysearch(vector<T> A, T key) {
ll left = 0;
ll right = 4;
ll mid;
while (left < right) {
mid = (left + right) / 2;
if (key == A[mid])
return 1;
if (key > A[mid])
left = mid + 1;
else if (key < A[mid])
right = mid;
}
return 0;
}
template <typename T> T finder(vector<T> vec, T number) {
auto itr = find(vec.begin(), vec.end(), number);
size_t index = distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
ll frac(ll n) //階乗
{
if (n == 0) {
return 1;
}
return (n * frac(n - 1)) % MOD;
}
template <typename T> T keta(T a) {
ll kazu = 1;
while (1) {
if (a / 10 != 0) {
a /= 10;
kazu++;
} else
break;
}
return kazu;
} //桁数
//素数判定
template <typename T> bool IsPrime(T num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
template <typename T> T nCr(ll n, T r) {
ll ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
yaju[i] = r[i] - '0';
}
*/
// vector<vector<int>> data(3, vector<int>(4));
// vector<vector<Type>> vv(n);
// cout << fixed << setprecision(20) << endl;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> k(M + 1), p(M + 1);
vector<vector<ll>> data(M + 1);
ll a = 0;
for (ll i = 0; i <= M; i++) {
cin >> k[i];
data[i].resize(k[i] + 1);
for (ll j = 1; j <= k[i]; j++) {
cin >> a;
a--;
data[i][j] = a;
}
}
ll bulb;
ll ans = 0;
bool ok = true;
for (ll i = 1; i <= M; i++)
cin >> p[i];
for (ll bit = 1; bit < (1 << N); bit++) {
ok = true;
for (ll i = 1; i <= M; i++) {
bulb = 0;
for (ll j = 1; j <= k[i]; j++) {
if (bit & (1 << data[i][j])) {
bulb++;
}
}
if (bulb % 2 != p[i]) {
ok = false;
break;
}
}
if (ok)
ans++;
}
cout << ans << endl;
}
| #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
typedef long long ll;
#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template <typename T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
// return b ? gcd(b, a % b) : a;
}
template <typename T> T lcm(T a, T b) {
ll g = gcd(a, b);
return a / g * b; // Be careful not to overflow
// return a * b / gcd(a, b);
}
template <typename T> T binarysearch(vector<T> A, T key) {
ll left = 0;
ll right = 4;
ll mid;
while (left < right) {
mid = (left + right) / 2;
if (key == A[mid])
return 1;
if (key > A[mid])
left = mid + 1;
else if (key < A[mid])
right = mid;
}
return 0;
}
template <typename T> T finder(vector<T> vec, T number) {
auto itr = find(vec.begin(), vec.end(), number);
size_t index = distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
ll frac(ll n) //階乗
{
if (n == 0) {
return 1;
}
return (n * frac(n - 1)) % MOD;
}
template <typename T> T keta(T a) {
ll kazu = 1;
while (1) {
if (a / 10 != 0) {
a /= 10;
kazu++;
} else
break;
}
return kazu;
} //桁数
//素数判定
template <typename T> bool IsPrime(T num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
template <typename T> T nCr(ll n, T r) {
ll ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
yaju[i] = r[i] - '0';
}
*/
// vector<vector<int>> data(3, vector<int>(4));
// vector<vector<Type>> vv(n);
// cout << fixed << setprecision(20) << endl;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> k(M + 1), p(M + 1);
vector<vector<ll>> data(M + 1);
ll a = 0;
for (ll i = 1; i <= M; i++) {
cin >> k[i];
data[i].resize(k[i] + 1);
for (ll j = 1; j <= k[i]; j++) {
cin >> a;
a--;
data[i][j] = a;
}
}
ll bulb;
ll ans = 0;
bool ok = true;
for (ll i = 1; i <= M; i++)
cin >> p[i];
for (ll bit = 0; bit < (1 << N); bit++) {
ok = true;
for (ll i = 1; i <= M; i++) {
bulb = 0;
for (ll j = 1; j <= k[i]; j++) {
if (bit & (1 << data[i][j])) {
bulb++;
}
}
if (bulb % 2 != p[i]) {
ok = false;
break;
}
}
if (ok)
ans++;
}
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 841,045 | 841,046 | u001858868 | cpp |
p03031 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
typedef long long ll;
#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template <typename T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
// return b ? gcd(b, a % b) : a;
}
template <typename T> T lcm(T a, T b) {
ll g = gcd(a, b);
return a / g * b; // Be careful not to overflow
// return a * b / gcd(a, b);
}
template <typename T> T binarysearch(vector<T> A, T key) {
ll left = 0;
ll right = 4;
ll mid;
while (left < right) {
mid = (left + right) / 2;
if (key == A[mid])
return 1;
if (key > A[mid])
left = mid + 1;
else if (key < A[mid])
right = mid;
}
return 0;
}
template <typename T> T finder(vector<T> vec, T number) {
auto itr = find(vec.begin(), vec.end(), number);
size_t index = distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
ll frac(ll n) //階乗
{
if (n == 0) {
return 1;
}
return (n * frac(n - 1)) % MOD;
}
template <typename T> T keta(T a) {
ll kazu = 1;
while (1) {
if (a / 10 != 0) {
a /= 10;
kazu++;
} else
break;
}
return kazu;
} //桁数
//素数判定
template <typename T> bool IsPrime(T num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
template <typename T> T nCr(ll n, T r) {
ll ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
yaju[i] = r[i] - '0';
}
*/
// vector<vector<int>> data(3, vector<int>(4));
// vector<vector<Type>> vv(n);
// cout << fixed << setprecision(20) << endl;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> k(M + 1), p(M + 1);
vector<vector<ll>> data(M + 1);
ll a = 0;
for (ll i = 1; i <= M; i++) {
cin >> k[i];
data[i].resize(k[i] + 1);
for (ll j = 1; j <= k[i]; j++) {
cin >> a;
a--;
data[i][j] = a;
}
}
ll bulb;
ll ans = 0;
bool ok = true;
for (ll i = 1; i <= M; i++)
cin >> p[i];
for (ll bit = 1; bit < (1 << N); bit++) {
ok = true;
for (ll i = 1; i <= M; i++) {
bulb = 0;
for (ll j = 1; j <= k[i]; j++) {
if (bit & (1 << data[i][j])) {
bulb++;
}
}
if (bulb % 2 != p[i]) {
ok = false;
break;
}
}
if (ok)
ans++;
}
cout << ans << endl;
}
| #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
typedef long long ll;
#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template <typename T> T gcd(T a, T b) {
if (b == 0)
return a;
return gcd(b, a % b);
// return b ? gcd(b, a % b) : a;
}
template <typename T> T lcm(T a, T b) {
ll g = gcd(a, b);
return a / g * b; // Be careful not to overflow
// return a * b / gcd(a, b);
}
template <typename T> T binarysearch(vector<T> A, T key) {
ll left = 0;
ll right = 4;
ll mid;
while (left < right) {
mid = (left + right) / 2;
if (key == A[mid])
return 1;
if (key > A[mid])
left = mid + 1;
else if (key < A[mid])
right = mid;
}
return 0;
}
template <typename T> T finder(vector<T> vec, T number) {
auto itr = find(vec.begin(), vec.end(), number);
size_t index = distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
ll frac(ll n) //階乗
{
if (n == 0) {
return 1;
}
return (n * frac(n - 1)) % MOD;
}
template <typename T> T keta(T a) {
ll kazu = 1;
while (1) {
if (a / 10 != 0) {
a /= 10;
kazu++;
} else
break;
}
return kazu;
} //桁数
//素数判定
template <typename T> bool IsPrime(T num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false; // 偶数はあらかじめ除く
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0) {
// 素数ではない
return false;
}
}
// 素数である
return true;
}
template <typename T> T nCr(ll n, T r) {
ll ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
yaju[i] = r[i] - '0';
}
*/
// vector<vector<int>> data(3, vector<int>(4));
// vector<vector<Type>> vv(n);
// cout << fixed << setprecision(20) << endl;
int main() {
ll N, M;
cin >> N >> M;
vector<ll> k(M + 1), p(M + 1);
vector<vector<ll>> data(M + 1);
ll a = 0;
for (ll i = 1; i <= M; i++) {
cin >> k[i];
data[i].resize(k[i] + 1);
for (ll j = 1; j <= k[i]; j++) {
cin >> a;
a--;
data[i][j] = a;
}
}
ll bulb;
ll ans = 0;
bool ok = true;
for (ll i = 1; i <= M; i++)
cin >> p[i];
for (ll bit = 0; bit < (1 << N); bit++) {
ok = true;
for (ll i = 1; i <= M; i++) {
bulb = 0;
for (ll j = 1; j <= k[i]; j++) {
if (bit & (1 << data[i][j])) {
bulb++;
}
}
if (bulb % 2 != p[i]) {
ok = false;
break;
}
}
if (ok)
ans++;
}
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 841,047 | 841,046 | u001858868 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; i++)
#define inf 1000000000
typedef long long ll;
int n, m;
vector<int> k(100), p(100);
vector<vector<int>> s(100, vector<int>(100));
ll sum = 0;
void dfs(int now, vector<int> sw) {
bool ok = true;
if (now == n + 1) {
for (int i = 0; i < m; i++) {
int count = 0;
for (int j = 0; j < k[i]; j++) {
if (sw[s[i][j]] == 1) {
count++;
}
}
if (p[i] != (count % 2)) {
return;
}
}
sum++;
return;
}
dfs(now + 1, sw);
sw[now] = 1;
dfs(now + 1, sw);
}
int main() {
cin >> n >> m;
vector<int> swt(n + 1, 0);
rep(i, 0, m) {
cin >> k[i];
rep(j, 0, k[i]) { cin >> s[j][i]; }
}
rep(i, 0, m) { cin >> p[i]; }
dfs(1, swt);
cout << sum << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; i++)
#define inf 1000000000
typedef long long ll;
int n, m;
vector<int> k(100), p(100);
vector<vector<int>> s(100, vector<int>(100));
ll sum = 0;
void dfs(int now, vector<int> sw) {
bool ok = true;
if (now == n + 1) {
for (int i = 0; i < m; i++) {
int count = 0;
for (int j = 0; j < k[i]; j++) {
if (sw[s[j][i]] == 1) {
count++;
}
}
if (p[i] != (count % 2)) {
return;
}
}
sum++;
return;
}
dfs(now + 1, sw);
sw[now] = 1;
dfs(now + 1, sw);
}
int main() {
cin >> n >> m;
vector<int> swt(n + 1, 0);
rep(i, 0, m) {
cin >> k[i];
rep(j, 0, k[i]) { cin >> s[j][i]; }
}
rep(i, 0, m) { cin >> p[i]; }
dfs(1, swt);
cout << sum << endl;
return 0;
} | [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 841,054 | 841,055 | u950411977 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; i++)
#define inf 1000000000
typedef long long ll;
int n, m;
vector<int> k(100), p(100);
vector<vector<int>> s(100, vector<int>(100));
ll sum = 0;
void dfs(int now, vector<int> sw, int f) {
if (now != 1) {
if (f == 1) {
sw[now - 1] = 1;
} else {
sw[now - 1] = 0;
}
}
bool ok = true;
if (now == n + 1) {
for (int i = 0; i < m; i++) {
int count = 0;
for (int j = 0; j < k[i]; j++) {
if (sw[s[i][j]] == 1) {
count++;
}
}
if (p[i] != (count % 2)) {
return;
}
}
sum++;
return;
}
dfs(now + 1, sw, 0);
dfs(now + 1, sw, 1);
}
int main() {
cin >> n >> m;
vector<int> swt(n + 1, 0);
rep(i, 0, m) {
cin >> k[i];
rep(j, 0, k[i]) { cin >> s[j][i]; }
}
rep(i, 0, m) { cin >> p[i]; }
dfs(1, swt, 0);
cout << sum << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; i++)
#define inf 1000000000
typedef long long ll;
int n, m;
vector<int> k(100), p(100);
vector<vector<int>> s(100, vector<int>(100));
ll sum = 0;
void dfs(int now, vector<int> sw, int f) {
if (now != 1) {
if (f == 1) {
sw[now - 1] = 1;
} else {
sw[now - 1] = 0;
}
}
bool ok = true;
if (now == n + 1) {
for (int i = 0; i < m; i++) {
int count = 0;
for (int j = 0; j < k[i]; j++) {
if (sw[s[j][i]] == 1) {
count++;
}
}
if (p[i] != (count % 2)) {
return;
}
}
sum++;
return;
}
dfs(now + 1, sw, 0);
dfs(now + 1, sw, 1);
}
int main() {
cin >> n >> m;
vector<int> swt(n + 1, 0);
rep(i, 0, m) {
cin >> k[i];
rep(j, 0, k[i]) { cin >> s[j][i]; }
}
rep(i, 0, m) { cin >> p[i]; }
dfs(1, swt, 0);
cout << sum << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 841,058 | 841,057 | u950411977 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (auto i = 0; i < n; i++)
#define inf 1000000000
typedef long long ll;
int main(void) {
int n, m, k;
cin >> n >> m;
vector<int> p(m + 5);
vector<vector<int>> suichi(m + 5);
rep(i, m) {
cin >> k;
rep(j, k) {
int s;
cin >> s;
suichi[i].push_back(s);
}
}
rep(i, m) { cin >> p[i]; }
ll sum = 0;
for (int bit = 1; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
ll count = 0;
for (auto v : suichi[i]) {
if (bit & (1 << (v - 1))) {
count++;
}
}
if (count % 2 != p[i]) {
ok = false;
}
}
if (ok) {
sum++;
}
}
cout << sum << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (auto i = 0; i < n; i++)
#define inf 1000000000
typedef long long ll;
int main(void) {
int n, m, k;
cin >> n >> m;
vector<int> p(m + 5);
vector<vector<int>> suichi(m + 5);
rep(i, m) {
cin >> k;
rep(j, k) {
int s;
cin >> s;
suichi[i].push_back(s);
}
}
rep(i, m) { cin >> p[i]; }
ll sum = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
ll count = 0;
for (auto v : suichi[i]) {
if (bit & (1 << (v - 1))) {
count++;
}
}
if (count % 2 != p[i]) {
ok = false;
}
}
if (ok) {
sum++;
}
}
cout << sum << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 841,059 | 841,060 | u950411977 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (auto i = 0; i < n; i++)
#define inf 1000000000
typedef long long ll;
int main(void) {
int n, m, k;
cin >> n >> m;
vector<int> p(m + 5);
vector<vector<int>> suichi(m + 5);
rep(i, m) {
cin >> k;
rep(j, k) {
int s;
cin >> s;
suichi[i].push_back(s);
}
}
rep(i, m) { cin >> p[i]; }
ll sum = 0;
for (int bit = 1; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
int count = 0;
for (auto v : suichi[i]) {
if (bit & (1 << (v - 1))) {
count++;
}
}
if (count % 2 != p[i]) {
ok = false;
}
}
if (ok) {
sum++;
}
}
cout << sum << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (auto i = 0; i < n; i++)
#define inf 1000000000
typedef long long ll;
int main(void) {
int n, m, k;
cin >> n >> m;
vector<int> p(m + 5);
vector<vector<int>> suichi(m + 5);
rep(i, m) {
cin >> k;
rep(j, k) {
int s;
cin >> s;
suichi[i].push_back(s);
}
}
rep(i, m) { cin >> p[i]; }
ll sum = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool ok = true;
for (int i = 0; i < m; i++) {
ll count = 0;
for (auto v : suichi[i]) {
if (bit & (1 << (v - 1))) {
count++;
}
}
if (count % 2 != p[i]) {
ok = false;
}
}
if (ok) {
sum++;
}
}
cout << sum << endl;
return 0;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"variable_declaration.type.change"
] | 841,061 | 841,060 | u950411977 | cpp |
p03031 | #include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
ll count_digits(ll n) {
int ans = 0;
while (n)
n /= 10, ans++;
return ans;
}
int main() {
int nb, ns, ans = 0, aux, k, cnt;
bool on;
bitset<11> b;
cin >> ns >> nb;
vector<int> v[11];
vector<int> resto(nb);
for (int i = 0; i < nb; i++) {
cin >> k;
for (int i = 0; i < k; i++) {
cin >> aux;
v[i].push_back(--aux);
}
}
for (auto &x : resto)
cin >> x;
for (int i = 0; i < (1 << ns); i++) {
b = i;
on = true;
for (int j = 0; j < nb; j++) {
cnt = 0;
for (auto x : v[j])
cnt += b[x];
if (cnt % 2 != resto[j]) {
on = false;
break;
}
}
if (on)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 100100;
const long double PI = acos(-1);
ll count_digits(ll n) {
int ans = 0;
while (n)
n /= 10, ans++;
return ans;
}
int main() {
int nb, ns, ans = 0, aux, k, cnt;
bool on;
bitset<11> b;
cin >> ns >> nb;
vector<int> v[11];
vector<int> resto(nb);
for (int i = 0; i < nb; i++) {
cin >> k;
for (int j = 0; j < k; j++) {
cin >> aux;
v[i].push_back(--aux);
}
}
for (auto &x : resto)
cin >> x;
for (int i = 0; i < (1 << ns); i++) {
b = i;
on = true;
for (int j = 0; j < nb; j++) {
cnt = 0;
for (auto x : v[j])
cnt += b[x];
if (cnt % 2 != resto[j]) {
on = false;
break;
}
}
if (on)
ans++;
}
cout << ans << endl;
return 0;
} | [
"variable_declaration.name.change",
"identifier.change",
"control_flow.loop.for.initializer.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 841,062 | 841,063 | u009937643 | cpp |
p03031 | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecst vector<string>
#define vecb vector<bool>
#define vec2(var, n, m) vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m) vector<vector<ll>> var(n, vector<ll>(m, 0))
#define rep(i, n) for (ll i = (ll)0; i < (ll)n; i++)
#define REP(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define arr(var, n) \
vec var(n); \
rep(i, n) { cin >> var[i]; }
#define arrll(var, n) \
vecll var(n); \
rep(i, n) { cin >> var[i]; }
#define arrst(var, n) \
vecst var(n); \
rep(i, n) { cin >> var[i]; }
#define all(var) (var).begin(), (var).end()
#define sortall(var) sort(all(var))
#define uniqueall(v) v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var) accumulate(all(var), 0)
#define f_sumll(var) accumulate(all(var), 0LL)
#define chmin(v1, v2) v1 = min(v1, v2)
#define chmax(v1, v2) v1 = max(v1, v2)
#define pb(var) push_back(var)
#define prt(var) cout << (var) << "\n"
#define prtd(n, var) cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var) cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2) cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v) \
rep(i, v.size()) { cout << v[i] << (i != v.size() - 1 ? " " : "\n"); }
void prtok(bool ok) { prt(ok ? "yes" : "no"); }
//----------------------------------------------------------------
#define bitrep(i, n) for (ll i = 0; i < (ll)(1 << n); i++)
#define bis(i, j) i &(1 << j)
int main(void) {
int n, m;
cin >> n >> m;
bool light[m][n];
rep(i, n) {
rep(j, n) { light[i][j] = false; }
}
rep(i, m) {
int num;
cin >> num;
rep(j, num) {
int tmp;
cin >> tmp;
tmp--;
light[i][tmp] = true;
}
}
arr(p, m);
int ans = 0;
bitrep(i, n) {
int lightnum = 0;
rep(j, m) {
int on = 0;
rep(k, n) {
if (bis(i, k)) {
if (light[j][k]) {
on++;
}
}
}
if (on % 2 == p[j]) {
lightnum++;
}
}
if (lightnum == m) {
ans++;
}
}
prt(ans);
}
| #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecst vector<string>
#define vecb vector<bool>
#define vec2(var, n, m) vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m) vector<vector<ll>> var(n, vector<ll>(m, 0))
#define rep(i, n) for (ll i = (ll)0; i < (ll)n; i++)
#define REP(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define arr(var, n) \
vec var(n); \
rep(i, n) { cin >> var[i]; }
#define arrll(var, n) \
vecll var(n); \
rep(i, n) { cin >> var[i]; }
#define arrst(var, n) \
vecst var(n); \
rep(i, n) { cin >> var[i]; }
#define all(var) (var).begin(), (var).end()
#define sortall(var) sort(all(var))
#define uniqueall(v) v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var) accumulate(all(var), 0)
#define f_sumll(var) accumulate(all(var), 0LL)
#define chmin(v1, v2) v1 = min(v1, v2)
#define chmax(v1, v2) v1 = max(v1, v2)
#define pb(var) push_back(var)
#define prt(var) cout << (var) << "\n"
#define prtd(n, var) cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var) cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2) cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v) \
rep(i, v.size()) { cout << v[i] << (i != v.size() - 1 ? " " : "\n"); }
void prtok(bool ok) { prt(ok ? "yes" : "no"); }
//----------------------------------------------------------------
#define bitrep(i, n) for (ll i = 0; i < (ll)(1 << n); i++)
#define bis(i, j) i &(1 << j)
int main(void) {
int n, m;
cin >> n >> m;
bool light[m][n];
rep(i, m) {
rep(j, n) { light[i][j] = false; }
}
rep(i, m) {
int num;
cin >> num;
rep(j, num) {
int tmp;
cin >> tmp;
tmp--;
light[i][tmp] = true;
}
}
arr(p, m);
int ans = 0;
bitrep(i, n) {
int lightnum = 0;
rep(j, m) {
int on = 0;
rep(k, n) {
if (bis(i, k)) {
if (light[j][k]) {
on++;
}
}
}
if (on % 2 == p[j]) {
lightnum++;
}
}
if (lightnum == m) {
ans++;
}
}
prt(ans);
}
| [] | 841,064 | 841,065 | u929977034 | cpp |
p03031 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> k(m);
vector<vector<int>> s(m, vector<int>(n));
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int sj;
cin >> sj;
sj--;
s[i][sj]++;
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int ans = 0;
for (int bit = 0; bit < 1 << n; bit++) {
vector<int> ons(n);
for (int i = 0; i < n; i++) {
if (bit & (1 << i)) {
ons[i]++;
}
}
int onsum = 0;
for (int i = 0; i < m; i++) {
int temp = 0;
for (int j = 0; j < n; j++) {
if (s[i][j] > 0 & ons[j] > 0) {
temp++;
}
}
if (p[i] == temp % 2)
onsum++;
}
if (onsum == m) {
ans++;
}
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> k(m);
vector<vector<int>> s(m, vector<int>(n));
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
int sj;
cin >> sj;
sj--;
s[i][sj]++;
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int ans = 0;
for (int bit = 0; bit < 1 << n; bit++) {
vector<int> ons(n);
for (int i = 0; i < n; i++) {
if (bit & (1 << i)) {
ons[i]++;
}
}
int onsum = 0;
for (int i = 0; i < m; i++) {
int temp = 0;
for (int j = 0; j < n; j++) {
if (s[i][j] > 0 & ons[j] > 0) {
temp++;
}
}
if (p[i] == temp % 2)
onsum++;
}
if (onsum == m) {
ans++;
}
}
cout << ans << endl;
return 0;
} | [] | 841,066 | 841,067 | u476027087 | cpp |
p03031 | #include <algorithm>
#include <bitset>
#include <cstring>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>
#define pi 3.141592653589793238
#include <chrono>
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
using namespace std;
ll n;
ll ncr(ll n, ll r) {
ll i, ans = 1, k = 0;
if (r == 0)
return 1;
else if (n < r)
return 0;
for (i = n; i >= n - r + 1; i--) {
ans *= i;
ans /= n - i + 1;
}
return ans;
}
void max_heapify(int a[100], int i) {
int l, r, largest = i;
l = 2 * i + 1;
r = 2 * i + 2;
if (l < n && a[l] > a[i])
largest = l;
if (r < n && a[r] > a[l])
largest = r;
if (largest != i) {
int k;
k = a[i];
a[i] = a[largest];
a[largest] = k;
max_heapify(a, largest);
}
}
int power(ll x, ll y, ll p) {
int res = 1;
x = x % p;
while (y > 0) {
if (y & 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
bool square(ll n) {
double x;
x = sqrt(n);
if (x == floor(x))
return true;
else
return false;
}
bool prime(ll n) {
ll i;
for (i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
ll modi(ll a, ll m) { return power(a, m - 2, m); }
void kmp(string s, ll p[]) {
int n = (int)s.length();
p[0] = 0;
for (int i = 1; i < n; i++) {
int j = p[i - 1];
while (j > 0 && s[i] != s[j])
j = p[j - 1];
if (s[i] == s[j])
j++;
p[i] = j;
}
}
void zfunc(string s, ll z[]) {
ll n = (ll)s.length();
z[0] = 0;
for (ll i = 1, l = 0, r = 0; i < n; ++i) {
if (i <= r)
z[i] = min(r - i + 1, z[i - l]);
while (i + z[i] < n && s[z[i]] == s[i + z[i]])
++z[i];
if (i + z[i] - 1 > r)
l = i, r = i + z[i] - 1;
}
}
struct pair_hash {
size_t operator()(const pair<int, int> &p) const noexcept {
return hash<ll>()((((ll)p.first) << 32) | ((ll)p.second));
}
};
bool palin(string s) {
ll i, n;
n = s.length();
for (i = 0; i <= n / 2; i++) {
if (s[i] != s[n - i - 1]) {
return false;
}
}
return true;
}
ll sum(ll n) {
ll i;
i = n;
ll sum = 0;
while (i > 0) {
sum += i % 10;
i = i / 10;
}
return sum;
}
ll nCr(ll n, ll r, ll p, ll fac[]) {
if (r == 0)
return 1;
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[n] * modi(fac[r], p) % p * modi(fac[n - r], p) % p) % p;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll mod(string num, ll a) {
ll res = 0;
for (ll i = 0; i < num.length(); i++)
res = (res * 10 + (ll)num[i] - '0') % a;
return res;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll parent[1000], sizer[1000];
ll findset(ll a) {
if (a == parent[a]) {
return a;
}
parent[a] = findset(parent[a]);
return parent[a];
}
void unionset(ll a, ll b) {
a = findset(a);
b = findset(b);
if (sizer[a] < sizer[b]) {
swap(a, b);
}
sizer[b] += sizer[a];
parent[b] = a;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct fenwick {
vector<ll> bit;
ll n;
fenwick(ll n, vector<ll> v) {
this->n = n;
bit.assign(n, 0);
for (ll it = 0; it < n; it++) {
add(it, v[it]);
}
}
ll sum(ll idx) {
if (idx < 0)
return 0;
ll ret = 0;
for (; idx >= 0; idx = (idx & (idx + 1)) - 1) {
ret += bit[idx];
}
return ret;
}
void add(ll idx, ll x) {
for (; idx < n; idx = idx | (idx + 1)) {
bit[idx] += x;
bit[idx] = max(0LL, bit[idx]);
}
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
fast;
ll T = 1, i, j;
// cin >> T;
while (T--) {
ll n, m;
cin >> n >> m;
vector<ll> k(m);
vector<vector<ll>> v(m);
vector<ll> p(m);
for (i = 0; i < m; i++) {
cin >> k[i];
ll x;
for (j = 0; j < k[i]; j++) {
cin >> x;
v[i].pb(x);
}
}
for (i = 0; i < m; i++) {
cin >> p[i];
}
ll ans = 0;
for (i = 1; i < (1 << n); i++) {
bitset<10> b = i;
ll count = 0;
for (j = 0; j < m; j++) {
ll num = 0;
for (auto u : v[j]) {
if (b[u - 1] == 1) {
num++;
}
}
if (num % 2 == p[j]) {
count++;
}
}
if (count == m) {
ans++;
}
}
cout << ans;
}
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cstring>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>
#define pi 3.141592653589793238
#include <chrono>
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
using namespace std;
ll n;
ll ncr(ll n, ll r) {
ll i, ans = 1, k = 0;
if (r == 0)
return 1;
else if (n < r)
return 0;
for (i = n; i >= n - r + 1; i--) {
ans *= i;
ans /= n - i + 1;
}
return ans;
}
void max_heapify(int a[100], int i) {
int l, r, largest = i;
l = 2 * i + 1;
r = 2 * i + 2;
if (l < n && a[l] > a[i])
largest = l;
if (r < n && a[r] > a[l])
largest = r;
if (largest != i) {
int k;
k = a[i];
a[i] = a[largest];
a[largest] = k;
max_heapify(a, largest);
}
}
int power(ll x, ll y, ll p) {
int res = 1;
x = x % p;
while (y > 0) {
if (y & 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
bool square(ll n) {
double x;
x = sqrt(n);
if (x == floor(x))
return true;
else
return false;
}
bool prime(ll n) {
ll i;
for (i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
ll modi(ll a, ll m) { return power(a, m - 2, m); }
void kmp(string s, ll p[]) {
int n = (int)s.length();
p[0] = 0;
for (int i = 1; i < n; i++) {
int j = p[i - 1];
while (j > 0 && s[i] != s[j])
j = p[j - 1];
if (s[i] == s[j])
j++;
p[i] = j;
}
}
void zfunc(string s, ll z[]) {
ll n = (ll)s.length();
z[0] = 0;
for (ll i = 1, l = 0, r = 0; i < n; ++i) {
if (i <= r)
z[i] = min(r - i + 1, z[i - l]);
while (i + z[i] < n && s[z[i]] == s[i + z[i]])
++z[i];
if (i + z[i] - 1 > r)
l = i, r = i + z[i] - 1;
}
}
struct pair_hash {
size_t operator()(const pair<int, int> &p) const noexcept {
return hash<ll>()((((ll)p.first) << 32) | ((ll)p.second));
}
};
bool palin(string s) {
ll i, n;
n = s.length();
for (i = 0; i <= n / 2; i++) {
if (s[i] != s[n - i - 1]) {
return false;
}
}
return true;
}
ll sum(ll n) {
ll i;
i = n;
ll sum = 0;
while (i > 0) {
sum += i % 10;
i = i / 10;
}
return sum;
}
ll nCr(ll n, ll r, ll p, ll fac[]) {
if (r == 0)
return 1;
fac[0] = 1;
for (int i = 1; i <= n; i++)
fac[i] = fac[i - 1] * i % p;
return (fac[n] * modi(fac[r], p) % p * modi(fac[n - r], p) % p) % p;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll mod(string num, ll a) {
ll res = 0;
for (ll i = 0; i < num.length(); i++)
res = (res * 10 + (ll)num[i] - '0') % a;
return res;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll parent[1000], sizer[1000];
ll findset(ll a) {
if (a == parent[a]) {
return a;
}
parent[a] = findset(parent[a]);
return parent[a];
}
void unionset(ll a, ll b) {
a = findset(a);
b = findset(b);
if (sizer[a] < sizer[b]) {
swap(a, b);
}
sizer[b] += sizer[a];
parent[b] = a;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct fenwick {
vector<ll> bit;
ll n;
fenwick(ll n, vector<ll> v) {
this->n = n;
bit.assign(n, 0);
for (ll it = 0; it < n; it++) {
add(it, v[it]);
}
}
ll sum(ll idx) {
if (idx < 0)
return 0;
ll ret = 0;
for (; idx >= 0; idx = (idx & (idx + 1)) - 1) {
ret += bit[idx];
}
return ret;
}
void add(ll idx, ll x) {
for (; idx < n; idx = idx | (idx + 1)) {
bit[idx] += x;
bit[idx] = max(0LL, bit[idx]);
}
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
fast;
ll T = 1, i, j;
// cin >> T;
while (T--) {
ll n, m;
cin >> n >> m;
vector<ll> k(m);
vector<vector<ll>> v(m);
vector<ll> p(m);
for (i = 0; i < m; i++) {
cin >> k[i];
ll x;
for (j = 0; j < k[i]; j++) {
cin >> x;
v[i].pb(x);
}
}
for (i = 0; i < m; i++) {
cin >> p[i];
}
ll ans = 0;
for (i = 0; i < (1 << n); i++) {
bitset<10> b = i;
ll count = 0;
for (j = 0; j < m; j++) {
ll num = 0;
for (auto u : v[j]) {
if (b[u - 1] == 1) {
num++;
}
}
if (num % 2 == p[j]) {
count++;
} else {
break;
}
}
if (count == m) {
ans++;
}
}
cout << ans;
}
return 0;
}
| [
"literal.number.change",
"assignment.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"control_flow.branch.else.add"
] | 841,068 | 841,069 | u734397606 | cpp |
p03031 | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> s(M);
for (int i = 0; i < M; ++i) {
int k;
cin >> k;
for (int j = 0; j < k; ++j) {
int a;
cin >> a;
s[i].push_back(a);
}
}
vector<int> p(M);
for (int i = 0; i < M; ++i)
cin >> p[i];
long long res = 0;
for (int bit = 0; bit < (1 << N); ++bit) {
bool ok = true;
for (int i = 0; i < M; ++i) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
++res;
}
cout << res << endl;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> s(M);
for (int i = 0; i < M; ++i) {
int k;
cin >> k;
for (int j = 0; j < k; ++j) {
int a;
cin >> a;
a--;
s[i].push_back(a);
}
}
vector<int> p(M);
for (int i = 0; i < M; ++i)
cin >> p[i];
long long res = 0;
for (int bit = 0; bit < (1 << N); ++bit) {
bool ok = true;
for (int i = 0; i < M; ++i) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
++res;
}
cout << res << endl;
}
| [
"expression.unary.arithmetic.add"
] | 841,070 | 841,071 | u348398921 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; 0 <= i; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; (ll)(b) <= i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main() {
int n, m;
cin >> n >> m;
vector<vector<bool>> light(m);
REP(i, m) {
int k;
cin >> k;
REP(j, k) {
int x;
cin >> x;
x--;
light[i].push_back(x);
}
}
vector<ll> p(m);
REP(i, m) cin >> p[i];
ll res = 0;
REP(i, 1 << n) {
vector<bool> sw(n, false);
REP(bit, n) {
if (i & 1 << bit)
sw[bit] = true;
}
bool flag = true;
REP(j, m) {
int cnt = 0;
for (auto x : light[j]) {
if (sw[x])
cnt += 1;
}
if (!cnt || cnt % 2 != p[j])
flag = false;
// cout << i << ' ' << cnt << endl;
}
if (flag)
res += 1;
}
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; 0 <= i; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; (ll)(b) <= i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int main() {
int n, m;
cin >> n >> m;
vector<vector<ll>> light(m);
REP(i, m) {
int k;
cin >> k;
REP(j, k) {
int x;
cin >> x;
x--;
light[i].push_back(x);
}
}
vector<ll> p(m);
REP(i, m) cin >> p[i];
ll res = 0;
REP(i, 1 << n) {
vector<bool> sw(n, false);
REP(bit, n) {
if (i & 1 << bit)
sw[bit] = true;
}
bool flag = true;
REP(j, m) {
int cnt = 0;
for (auto x : light[j]) {
if (sw[x])
cnt += 1;
}
if (cnt % 2 != p[j])
flag = false;
// cout << i << ' ' << cnt << endl;
}
if (flag)
res += 1;
}
cout << res << endl;
} | [
"expression.operation.binary.remove"
] | 841,072 | 841,073 | u050087249 | cpp |
p03031 | #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
int main() {
ll N, M;
ll res = 0;
cin >> N >> M;
vector<int> p(M + 4);
vector<vector<int>> s(M + 4);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[i].push_back(a - 1);
}
}
for (int i = 0; i < M; i++) {
cin >> p[M];
}
for (int bit = 0; bit < (1 << N); bit++) {
bool ok = true;
for (int i = 0; i < M; ++i) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
++res;
}
cout << res << endl;
} | #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
int main() {
ll N, M;
ll res = 0;
cin >> N >> M;
vector<int> p(M + 2);
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[i].push_back(a - 1);
}
}
for (int i = 0; i < M; i++) {
cin >> p[i];
}
for (int bit = 0; bit < (1 << N); bit++) {
bool ok = true;
for (int i = 0; i < M; ++i) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
++res;
}
cout << res << endl;
} | [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove",
"identifier.change",
"variable_access.subscript.index.change"
] | 841,074 | 841,075 | u503052349 | cpp |
p03031 | #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
int main() {
ll N, M;
ll res = 0;
cin >> N >> M;
vector<int> p(M + 4);
vector<vector<int>> s(M + 4);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[j].push_back(a - 1);
}
}
for (int i = 0; i < M; i++) {
cin >> p[M];
}
for (int bit = 0; bit < (1 << N); bit++) {
bool ok = true;
for (int i = 0; i < M; ++i) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
++res;
}
cout << res << endl;
} | #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
int main() {
ll N, M;
ll res = 0;
cin >> N >> M;
vector<int> p(M + 2);
vector<vector<int>> s(M);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int a;
cin >> a;
s[i].push_back(a - 1);
}
}
for (int i = 0; i < M; i++) {
cin >> p[i];
}
for (int bit = 0; bit < (1 << N); bit++) {
bool ok = true;
for (int i = 0; i < M; ++i) {
int con = 0;
for (auto v : s[i]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[i])
ok = false;
}
if (ok)
++res;
}
cout << res << endl;
} | [
"literal.number.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove",
"identifier.change",
"variable_access.subscript.index.change"
] | 841,076 | 841,075 | u503052349 | cpp |
p03031 | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m, vector<int>());
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int tmp;
cin >> tmp;
s[i].push_back(tmp);
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int sum = 0;
for (int i = 0; i < pow(2, n); i++) {
bool isOK = true;
for (int j = 0; j < m; j++) {
int nums = 0;
for (int k = 0; k < s[j].size(); k++) {
if (i >> (s[j][k] + 1) & 1)
nums++;
}
if (nums % 2 != p[j]) {
isOK = false;
break;
}
}
if (isOK)
sum++;
}
cout << sum << endl;
}
| #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m, vector<int>());
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int tmp;
cin >> tmp;
s[i].push_back(tmp);
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int sum = 0;
for (int i = 0; i < pow(2, n); i++) {
bool isOK = true;
for (int j = 0; j < m; j++) {
int nums = 0;
for (int k = 0; k < s[j].size(); k++) {
if (i >> (s[j][k] - 1) & 1)
nums++;
}
if (nums % 2 != p[j]) {
isOK = false;
break;
}
}
if (isOK)
sum++;
}
cout << sum << endl;
}
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 841,086 | 841,087 | u314960567 | cpp |
p03031 | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m, vector<int>());
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int tmp;
cin >> tmp;
s[i].push_back(tmp);
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int sum = 0;
for (int i = 0; i < pow(2, n); i++) {
bool isOK = true;
for (int j = 0; j < m; j++) {
int nums = 0;
for (int k = 0; k < s[j].size(); k++) {
if (i >> s[j][k] & 1)
nums++;
}
if (nums % 2 != p[j]) {
isOK = false;
break;
}
}
if (isOK)
sum++;
}
cout << sum << endl;
}
| #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m, vector<int>());
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int tmp;
cin >> tmp;
s[i].push_back(tmp);
}
}
for (int i = 0; i < m; i++) {
cin >> p[i];
}
int sum = 0;
for (int i = 0; i < pow(2, n); i++) {
bool isOK = true;
for (int j = 0; j < m; j++) {
int nums = 0;
for (int k = 0; k < s[j].size(); k++) {
if (i >> (s[j][k] - 1) & 1)
nums++;
}
if (nums % 2 != p[j]) {
isOK = false;
break;
}
}
if (isOK)
sum++;
}
cout << sum << endl;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 841,088 | 841,087 | u314960567 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int k[20], s[20][20], p[20];
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
cin >> s[i][j];
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int light = 0;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < k[i]; j++) {
if (bit & (1 << s[i][j]))
cnt++;
}
if (p[i] == 0 && (cnt % 2 == 0))
light++;
else if (p[i] == 1 && (cnt % 2 != 0))
light++;
}
if (light == m)
ans++;
}
cout << ans;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int k[20], s[20][20], p[20];
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
cin >> s[i][j];
}
}
for (int i = 0; i < m; i++)
cin >> p[i];
int ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
int light = 0;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int j = 0; j < k[i]; j++) {
if (bit & (1 << s[i][j] - 1))
cnt++;
}
if (p[i] == 0 && (cnt % 2 == 0))
light++;
if (p[i] == 1 && (cnt % 2 != 0))
light++;
}
if (light == m)
ans++;
}
cout << ans;
}
| [
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"misc.off_by_one",
"control_flow.branch.if.replace.add",
"control_flow.branch.else_if.replace.remove"
] | 841,111 | 841,112 | u639300218 | cpp |
p03031 | #include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int N, M;
vector<int> a[10];
int p[10];
int main() {
cin >> N >> M;
rep(i, M) {
int temp;
cin >> temp;
a[i].resize(temp);
rep(j, a[i].size()) { cin >> a[i][j]; }
}
rep(i, M) { cin >> p[i]; }
bool f = true;
int ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
f = true;
for (int j = 0; j < M; j++) {
int count = 0;
for (int i = 0; i < a[j].size(); i++) {
int temp = a[j][i] - 1;
if (bit & (1 << temp) != 0) {
count++;
// cout << bit << " " << a[j][i]-1 << endl;
}
}
// cout << count << endl;
if (count % 2 != p[j])
f = false;
}
if (f)
ans++;
// if(bit == 3) cout << endl << f << endl;
}
cout << ans << endl;
// cout << N << endl;
// cout << endl;
// cout << a[1][0] << endl;
// cout << a[0].size() << endl;
// cout << a[1].size() << endl;
return 0;
} | #include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int N, M;
vector<int> a[10];
int p[10];
int main() {
cin >> N >> M;
rep(i, M) {
int temp;
cin >> temp;
a[i].resize(temp);
rep(j, a[i].size()) { cin >> a[i][j]; }
}
rep(i, M) { cin >> p[i]; }
bool f = true;
int ans = 0;
for (int bit = 0; bit < (1 << N); bit++) {
f = true;
for (int j = 0; j < M; j++) {
int count = 0;
for (int i = 0; i < a[j].size(); i++) {
int temp = a[j][i] - 1;
if (bit & (1 << temp)) {
count++;
// cout << bit << " " << a[j][i]-1 << endl;
}
}
// cout << count << endl;
if (count % 2 != p[j])
f = false;
}
if (f)
ans++;
// if(bit == 3) cout << endl << f << endl;
}
cout << ans << endl;
// cout << N << endl;
// cout << endl;
// cout << a[1][0] << endl;
// cout << a[0].size() << endl;
// cout << a[1].size() << endl;
return 0;
} | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 841,118 | 841,119 | u605168157 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, counter, counter1, answer = 0;
int y = 0;
int aaa = 0;
cin >> N >> M;
int p[M] = {0};
int ss[M][N] = {{0}};
int k[M] = {0};
for (int j = 0; j < M; j++) {
cin >> k[j];
for (int i = 0; i < k[j]; i++) {
cin >> ss[j][i];
}
}
for (int i = 0; i < M; i++) {
cin >> p[i];
}
// すべての選び方を試して、総和がKになるものがあるかを調べる
for (int tmp = 0; tmp < (1 << N); tmp++) {
bitset<10> s(tmp);
for (int i = 0; i < M; i++) {
for (int j = 0; j < k[j]; j++) {
if (s.test(ss[i][j] - 1)) {
answer++;
}
}
if (answer % 2 == p[i]) {
aaa++;
}
answer = 0;
}
if (aaa == M) {
y++;
}
aaa = 0;
}
cout << y << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, answer = 0;
int y = 0;
int aaa = 0;
cin >> N >> M;
int p[M] = {0};
int ss[M][N] = {{0}};
int k[M] = {0};
for (int j = 0; j < M; j++) {
cin >> k[j];
for (int i = 0; i < k[j]; i++) {
cin >> ss[j][i];
}
}
for (int i = 0; i < M; i++) {
cin >> p[i];
}
// すべての選び方を試して、総和がKになるものがあるかを調べる
for (int tmp = 0; tmp < (1 << N); tmp++) {
bitset<10> s(tmp);
for (int i = 0; i < M; i++) {
for (int j = 0; j < k[i]; j++) {
if (s.test(ss[i][j] - 1)) {
answer++;
}
}
if (answer % 2 == p[i]) {
aaa++;
}
answer = 0;
}
if (aaa == M) {
y++;
}
aaa = 0;
}
cout << y << endl;
}
| [
"variable_declaration.remove",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 841,122 | 841,123 | u722640678 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int64_t large = 9223372036854775807;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> list(M, vector<int>());
int p, q;
for (int i = 0; i < M; i++) {
cin >> p;
list[i].push_back(p);
for (int j = 0; j < p; j++) {
cin >> q;
q--;
list[i].push_back(q);
}
}
vector<int> amari(M);
for (int i = 0; i < M; i++)
cin >> amari[i];
int ans = 0;
for (int tmp = 0; tmp < (1 << N); tmp++) {
bitset<10> s(tmp);
vector<int> on(M);
for (int i = 0; i < M; i++) {
for (int j = 1; j < list[i][0]; j++) {
if (s[list[i][j]])
on[i]++;
}
}
bool x = true;
for (int i = 0; i < M; i++) {
if (on[i] % 2 != amari[i])
x = false;
}
if (x)
ans++;
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int64_t large = 9223372036854775807;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> list(M, vector<int>());
int p, q;
for (int i = 0; i < M; i++) {
cin >> p;
list[i].push_back(p);
for (int j = 0; j < p; j++) {
cin >> q;
q--;
list[i].push_back(q);
}
}
vector<int> amari(M);
for (int i = 0; i < M; i++)
cin >> amari[i];
int ans = 0;
for (int tmp = 0; tmp < (1 << N); tmp++) {
bitset<10> s(tmp);
vector<int> on(M);
for (int i = 0; i < M; i++) {
for (int j = 1; j <= list[i][0]; j++) {
if (s[list[i][j]])
on[i]++;
}
}
bool x = true;
for (int i = 0; i < M; i++) {
if (on[i] % 2 != amari[i])
x = false;
}
if (x)
ans++;
}
cout << ans;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 841,126 | 841,127 | u058742919 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout << #x << " = " << (x) << " (L" << LINE << ")" << endl;
#define vdeb(x) \
{ \
cout << #x << " = { "; \
rep(i, x.size()) cout << x[i] << ' '; \
cout << '}' << " (L" << LINE << ")" << endl; \
}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
int main() {
ll N, M;
cin >> N >> M;
vllvll s(M, vll(0));
ll tmp;
ll k;
rep(i, 0, M) {
cin >> k;
rep(j, 0, k) {
cin >> tmp;
--tmp;
s[i].push_back(tmp);
}
}
vll p(M);
rep(i, 0, M) { cin >> p[i]; }
ll ans = 0;
rep(bit, 0, 1 << N) { // each pattern
vll switches(M, 0);
rep(i, 0, N) { // filter
if (bit & 1 << i) {
switches[i] = 1;
}
}
bool flg = true;
rep(i, 0, M) { // each bulb
ll sm = 0;
rep(j, 0, s[i].size()) { // each connected switch
sm += switches[s[i][j]];
}
if (sm % 2 != p[i]) {
flg = false;
break;
}
}
if (flg) {
++ans;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout << #x << " = " << (x) << " (L" << LINE << ")" << endl;
#define vdeb(x) \
{ \
cout << #x << " = { "; \
rep(i, x.size()) cout << x[i] << ' '; \
cout << '}' << " (L" << LINE << ")" << endl; \
}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
int main() {
ll N, M;
cin >> N >> M;
vllvll s(M, vll(0));
ll tmp;
ll k;
rep(i, 0, M) {
cin >> k;
rep(j, 0, k) {
cin >> tmp;
--tmp;
s[i].push_back(tmp);
}
}
vll p(M);
rep(i, 0, M) { cin >> p[i]; }
ll ans = 0;
rep(bit, 0, 1 << N) { // each pattern
vll switches(N, 0);
rep(i, 0, N) { // filter
if (bit & 1 << i) {
switches[i] = 1;
}
}
bool flg = true;
rep(i, 0, M) { // each bulb
ll sm = 0;
rep(j, 0, s[i].size()) { // each connected switch
sm += switches[s[i][j]];
}
if (sm % 2 != p[i]) {
flg = false;
break;
}
}
if (flg) {
++ans;
}
}
cout << ans << endl;
} | [
"identifier.change",
"call.arguments.change"
] | 841,133 | 841,134 | u976940619 | cpp |
p03031 | #include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for (ll i = 0, i##_len = (ll)(n); i < i##_len; i++)
#define repf(i, n) for (ll i = 1, i##_len = (ll)(n + 1); i < i##_len; i++)
#define per(i, n) for (ll i = ((ll)(n)) - 1; i >= 0; i--)
#define perf(i, n) for (ll i = ((ll)(n)); i > 0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
ll n, m, ans = 0;
cin >> n >> m;
vi k(n), p(m);
vvi s(n, vi());
// 入力処理
rep(i, m) {
cin >> k[i];
s[i].resize(k[i]);
rep(j, k[i]) {
cin >> s[i][j];
s[i][j]--;
}
}
rep(i, m) cin >> p[i];
// ビット全探索
for (ll bit = 0; bit < (1LL << (n)); bit++) {
vector<bool> sw(n, false);
vector<bool> light(m, false);
rep(j, n) {
ll mask = (1LL << j);
if (bit & mask)
sw[j] = true;
}
rep(i, m) {
ll cnt = 0;
rep(j, k[i]) if (sw[s[i][j]]) cnt++;
if (cnt % 2 == p[i])
light[i] = true;
}
bool tmp = 1;
rep(i, m) tmp = tmp & light[i];
ans += tmp;
}
// 答えの出力
cout << ans << endl;
} | #include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for (ll i = 0, i##_len = (ll)(n); i < i##_len; i++)
#define repf(i, n) for (ll i = 1, i##_len = (ll)(n + 1); i < i##_len; i++)
#define per(i, n) for (ll i = ((ll)(n)) - 1; i >= 0; i--)
#define perf(i, n) for (ll i = ((ll)(n)); i > 0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
ll n, m, ans = 0;
cin >> n >> m;
vi k(n), p(m);
vvi s(m, vi());
// 入力処理
rep(i, m) {
cin >> k[i];
s[i].resize(k[i]);
rep(j, k[i]) {
cin >> s[i][j];
s[i][j]--;
}
}
rep(i, m) cin >> p[i];
// ビット全探索
for (ll bit = 0; bit < (1LL << (n)); bit++) {
vector<bool> sw(n, false);
vector<bool> light(m, false);
rep(j, n) {
ll mask = (1LL << j);
if (bit & mask)
sw[j] = true;
}
rep(i, m) {
ll cnt = 0;
rep(j, k[i]) if (sw[s[i][j]]) cnt++;
if (cnt % 2 == p[i])
light[i] = true;
}
bool tmp = 1;
rep(i, m) tmp = tmp & light[i];
ans += tmp;
}
// 答えの出力
cout << ans << endl;
} | [] | 841,138 | 841,139 | u548791035 | cpp |
p03031 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;
int N, M;
vector<int> s[10];
int p[10];
int main(void) {
cin >> N >> M;
int k, t;
REP(i, M) {
cin >> k;
REP(j, k) {
cin >> t;
s[i].push_back(t - 1);
}
}
REP(i, M) cin >> p[i];
int count = 0;
int p1[10];
REP(i, pow(2, N)) {
REP(j, M) p1[j] = 0;
REP(j, N) {
if (((i >> j) & 1) == 1) {
for (int k = 0; k < s[j].size(); k++) {
p1[s[j][k]]++;
}
}
}
bool b = true;
REP(j, M) b &= (p1[j] % 2 == p[j]);
count += int(b);
}
cout << count << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;
int N, M;
vector<int> s[10];
int p[10];
int main(void) {
cin >> N >> M;
int k, t;
REP(i, M) {
cin >> k;
REP(j, k) {
cin >> t;
s[t - 1].push_back(i);
}
}
REP(i, M) cin >> p[i];
int count = 0;
int p1[10];
REP(i, pow(2, N)) {
REP(j, M) p1[j] = 0;
REP(j, N) {
if (((i >> j) & 1) == 1) {
for (int k = 0; k < s[j].size(); k++) {
p1[s[j][k]]++;
}
}
}
bool b = true;
REP(j, M) b &= (p1[j] % 2 == p[j]);
count += int(b);
}
cout << count << endl;
return 0;
}
| [
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 841,142 | 841,143 | u097408484 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int n, m;
int on[10], p[10];
vector<int> s[10];
int ans = 0;
void dfs(int i) {
if (i == n) {
// rep(j, 0, n) cout << on[j]; cout << endl;
bool ok = true;
rep(j, 0, m) {
int cnt = 0;
for (auto k : s[j])
if (on[k])
cnt++;
if (cnt % 2 != p[i])
ok = false;
}
if (ok)
ans++;
return;
}
on[i] = 0;
dfs(i + 1);
on[i] = 1;
dfs(i + 1);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n >> m;
rep(i, 0, m) {
int k;
cin >> k;
rep(j, 0, k) {
int t;
cin >> t;
--t;
s[i].push_back(t);
}
}
rep(i, 0, m) cin >> p[i];
dfs(0);
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int n, m;
int on[11], p[11];
vector<int> s[11];
int ans = 0;
void dfs(int i) {
if (i == n) {
// rep(j, 0, n) cout << on[j]; cout << endl;
bool ok = true;
rep(j, 0, m) {
int cnt = 0;
for (auto k : s[j])
if (on[k])
cnt++;
if (cnt % 2 != p[j])
ok = false;
}
if (ok)
ans++;
return;
}
on[i] = 0;
dfs(i + 1);
on[i] = 1;
dfs(i + 1);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n >> m;
rep(i, 0, m) {
int k;
cin >> k;
rep(j, 0, k) {
int t;
cin >> t;
--t;
s[i].push_back(t);
}
}
rep(i, 0, m) cin >> p[i];
dfs(0);
cout << ans << endl;
}
| [
"literal.number.change",
"variable_declaration.array_dimensions.change",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 841,148 | 841,149 | u729337236 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < n; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int temp;
cin >> temp;
temp--;
s[i].push_back(temp);
}
}
vector<int> p(m);
for (int i = 0; i < m; i++)
cin >> p[i];
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool flg = true;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int v : s[i]) {
if (bit & (1 << v))
cnt++;
}
if (cnt % 2 != p[i])
flg = false;
}
if (flg)
ans++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int temp;
cin >> temp;
temp--;
s[i].push_back(temp);
}
}
vector<int> p(m);
for (int i = 0; i < m; i++)
cin >> p[i];
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
bool flg = true;
for (int i = 0; i < m; i++) {
int cnt = 0;
for (int v : s[i]) {
if (bit & (1 << v))
cnt++;
}
if (cnt % 2 != p[i])
flg = false;
}
if (flg)
ans++;
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 841,164 | 841,165 | u255302563 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int s[100][100];
int p[100];
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int r;
cin >> r;
s[i][j] = r - 1;
}
}
for (int i = 0; i < M; i++) {
cin >> p[i];
}
int res = 0;
for (int bit = 0; bit < (1 << N); bit++) {
bool t = true;
for (int i = 0; i < M; i++) {
int counter = 0;
for (int j : s[i]) {
if (bit & (1 << j))
counter++;
}
if (counter % 2 == p[i])
t = true;
else {
t = false;
break;
}
}
if (t)
res++;
}
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int s[100][100];
int p[100];
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int r;
cin >> r;
s[i][j] = r;
}
}
for (int i = 0; i < M; i++) {
cin >> p[i];
}
int res = 0;
for (int bit = 0; bit < (1 << N); bit++) {
bool t = true;
for (int i = 0; i < M; i++) {
int counter = 0;
for (int j : s[i]) {
if (bit & (1 << j))
counter++;
}
if (counter % 2 == p[i])
t = true;
else {
t = false;
break;
}
}
if (t)
res++;
}
cout << res << endl;
} | [
"expression.operation.binary.remove"
] | 841,166 | 841,167 | u731665172 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> sw(M);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
vector<int> x(k);
for (int j = 0; j < k; j++) {
int num;
cin >> num;
num--;
x.at(j) = num;
}
sw.at(i) = x;
}
vector<int> m(M);
for (int i = 0; i < M; i++) {
cin >> m.at(i);
}
int cnt = 0;
for (int i = 0; i <= (1 << N); i++) {
bool al = true;
for (int j = 0; j < M; j++) {
int num = 0;
for (auto k : sw.at(j)) {
if (i & (1 << k)) {
num++;
}
}
if (num % 2 != m.at(j)) {
al = false;
break;
}
}
if (al) {
cnt++;
}
}
cout << cnt << endl;
}
| #include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
using ll = long long;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> sw(M);
for (int i = 0; i < M; i++) {
int k;
cin >> k;
vector<int> x(k);
for (int j = 0; j < k; j++) {
int num;
cin >> num;
num--;
x.at(j) = num;
}
sw.at(i) = x;
}
vector<int> m(M);
for (int i = 0; i < M; i++) {
cin >> m.at(i);
}
int cnt = 0;
for (int i = 0; i < (1 << N); i++) {
bool al = true;
for (int j = 0; j < M; j++) {
int num = 0;
for (auto k : sw.at(j)) {
if (i & (1 << k)) {
num++;
}
}
if (num % 2 != m.at(j)) {
al = false;
break;
}
}
if (al) {
cnt++;
}
}
cout << cnt << endl;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 841,170 | 841,171 | u787139585 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, s, n) for (int i = (s); i < (int)n; i++)
int INF = 1e9 + 7;
int N, M;
vector<int> k, p;
vector<vector<int>> s;
int ans = 0;
void dfs(vector<int> v) {
if (v.size() == N) {
bool flag = true;
rep(i, 0, M) {
int sum = 0;
rep(j, 0, k[i]) sum += v[s[i][j]];
if (sum % 2 != p[i])
flag = false;
}
if (flag)
ans++;
return;
}
v.push_back(0);
dfs(v);
v.pop_back();
v.push_back(1);
dfs(v);
}
int main() {
cin >> N >> M;
k = vector<int>(M);
p = vector<int>(M);
s = vector<vector<int>>(M);
rep(i, 0, M) {
cin >> k[i];
rep(j, 0, k[i]) {
int a;
cin >> a;
s[i].push_back(a);
}
}
rep(i, 0, M) cin >> p[i];
vector<int> v;
dfs(v);
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, s, n) for (int i = (s); i < (int)n; i++)
int INF = 1e9 + 7;
int N, M;
vector<int> k, p;
vector<vector<int>> s;
int ans = 0;
void dfs(vector<int> v) {
if (v.size() == N) {
bool flag = true;
rep(i, 0, M) {
int sum = 0;
rep(j, 0, k[i]) sum += v[s[i][j]];
if (sum % 2 != p[i])
flag = false;
}
if (flag)
ans++;
return;
}
v.push_back(0);
dfs(v);
v.pop_back();
v.push_back(1);
dfs(v);
}
int main() {
cin >> N >> M;
k = vector<int>(M);
p = vector<int>(M);
s = vector<vector<int>>(M);
rep(i, 0, M) {
cin >> k[i];
rep(j, 0, k[i]) {
int a;
cin >> a;
s[i].push_back(--a);
}
}
rep(i, 0, M) cin >> p[i];
vector<int> v;
dfs(v);
cout << ans << endl;
} | [
"call.arguments.change"
] | 841,176 | 841,177 | u236658355 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)
#define each(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()
#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define endl "\n"
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
typedef long long lint;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, ans = 0;
cin >> n >> m;
vector<int> s(m, 0);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int tmp;
cin >> tmp;
tmp--;
s[i] |= (1 << tmp);
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
rep(i, (1 << n) + 1) {
bool flag = true;
rep(j, m) {
if (!(pcount(i & s[j]) % 2 == p[j]))
flag = false;
}
if (flag)
ans++;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)
#define each(it, c) \
for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()
#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define endl "\n"
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
typedef long long lint;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, ans = 0;
cin >> n >> m;
vector<int> s(m, 0);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int tmp;
cin >> tmp;
tmp--;
s[i] |= (1 << tmp);
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
rep(i, (1 << n)) {
bool flag = true;
rep(j, m) {
if (!(pcount(i & s[j]) % 2 == p[j]))
flag = false;
}
if (flag)
ans++;
}
cout << ans << endl;
} | [
"expression.operation.binary.remove"
] | 841,178 | 841,179 | u545385408 | cpp |
p03031 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
bitset<10> connect[10];
int flag[10];
int main() {
int n, m, tmp;
cin >> n >> m;
REP(i, m) {
int k;
cin >> k;
REP(j, k) {
cin >> tmp;
connect[i].set(tmp);
}
}
int res = 0;
REP(i, m) cin >> flag[i];
REP(i, 1 << n) {
bitset<10> target(i);
bool isok = true;
REP(j, m) if ((target & connect[j]).count() % 2 != flag[j]) {
isok = false;
break;
}
if (isok)
res++;
}
cout << res << endl;
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
bitset<10> connect[10];
int flag[10];
int main() {
int n, m, tmp;
cin >> n >> m;
REP(i, m) {
int k;
cin >> k;
REP(j, k) {
cin >> tmp;
connect[i].set(tmp - 1);
}
}
int res = 0;
REP(i, m) cin >> flag[i];
REP(i, 1 << n) {
bitset<10> target(i);
bool isok = true;
REP(j, m) if ((target & connect[j]).count() % 2 != flag[j]) {
isok = false;
break;
}
if (isok)
res++;
}
cout << res << endl;
return 0;
} | [
"expression.operation.binary.add"
] | 841,180 | 841,181 | u199808440 | cpp |
p03031 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
bitset<10> connect[10];
int flag[10];
int main() {
int n, m, tmp;
cin >> n >> m;
REP(i, m) {
int k;
cin >> k;
REP(j, k) {
cin >> tmp;
connect[i].set(j);
}
}
int res = 0;
REP(i, m) cin >> flag[i];
REP(i, 1 << 10) {
bitset<10> target(i);
bool isok = true;
REP(j, m) {
if ((target & connect[j]).count() % 2 != flag[j]) {
isok = false;
break;
}
}
if (isok)
res++;
}
cout << res << endl;
return 0;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using ld = long double;
const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
bitset<10> connect[10];
int flag[10];
int main() {
int n, m, tmp;
cin >> n >> m;
REP(i, m) {
int k;
cin >> k;
REP(j, k) {
cin >> tmp;
connect[i].set(tmp - 1);
}
}
int res = 0;
REP(i, m) cin >> flag[i];
REP(i, 1 << n) {
bitset<10> target(i);
bool isok = true;
REP(j, m) if ((target & connect[j]).count() % 2 != flag[j]) {
isok = false;
break;
}
if (isok)
res++;
}
cout << res << endl;
return 0;
} | [
"call.arguments.change",
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.change"
] | 841,182 | 841,181 | u199808440 | cpp |
p03031 | #include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
ll n, m;
cin >> n >> m;
vector<vector<ll>> s(m);
vector<ll> k(m);
vector<ll> p(m);
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
ll a;
cin >> a;
a--;
s[i].push_back(a);
}
}
rep(i, m) cin >> p[i];
ll ans = 0;
for (ll bit = 0; bit < (1 << n); bit++) {
vector<ll> cnt(n, 0);
for (int j = 0; j < n; j++) {
if (bit & (1 << j)) {
cnt[j]++;
}
}
vector<ll> count(m, 0);
for (int a = 0; a < n; a++) {
for (int b = 0; b < k[a]; b++) {
count[a] += cnt[s[a][b]];
}
}
bool flag = true;
for (int x = 0; x < m; x++) {
if (count[x] % 2 == p[x]) {
flag = true;
} else {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
} | #include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
ll n, m;
cin >> n >> m;
vector<vector<ll>> s(m);
vector<ll> k(m);
vector<ll> p(m);
for (int i = 0; i < m; i++) {
cin >> k[i];
for (int j = 0; j < k[i]; j++) {
ll a;
cin >> a;
a--;
s[i].push_back(a);
}
}
rep(i, m) cin >> p[i];
ll ans = 0;
for (ll bit = 0; bit < (1 << n); bit++) {
vector<ll> cnt(n, 0);
for (int j = 0; j < n; j++) {
if (bit & (1 << j)) {
cnt[j]++;
}
}
vector<ll> count(m, 0);
for (int a = 0; a < m; a++) {
for (int b = 0; b < k[a]; b++) {
count[a] += cnt[s[a][b]];
}
}
bool flag = true;
for (int x = 0; x < m; x++) {
if (count[x] % 2 == p[x]) {
flag = true;
} else {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
} | [
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 841,194 | 841,195 | u225474226 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> c(m, vector<int>(n, 0));
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
c.at(i).at(s - 1) = 1;
}
}
vector<int> p(n);
for (int i = 0; i < m; i++)
cin >> p.at(i);
int a = 0;
for (int i = 0; i < (1 << n); i++) {
vector<int> b(n);
int x = i;
for (int d = 0; d < n; d++) {
b.at(d) = x % 2;
x /= 2;
}
bool f = 1;
for (int j = 0; j < m; j++) {
int s = 0;
for (int k = 0; k < n; k++)
s += b.at(k) * c.at(j).at(k);
f = (s % 2 == p.at(j) ? f : 0);
}
a += (f ? 1 : 0);
}
cout << a << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> c(m, vector<int>(n, 0));
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
c.at(i).at(s - 1) = 1;
}
}
vector<int> p(m);
for (int i = 0; i < m; i++)
cin >> p.at(i);
int a = 0;
for (int i = 0; i < (1 << n); i++) {
vector<int> b(n);
int x = i;
for (int d = 0; d < n; d++) {
b.at(d) = x % 2;
x /= 2;
}
bool f = 1;
for (int j = 0; j < m; j++) {
int s = 0;
for (int k = 0; k < n; k++)
s += b.at(k) * c.at(j).at(k);
f = (s % 2 == p.at(j) ? f : 0);
}
a += (f ? 1 : 0);
}
cout << a << endl;
} | [] | 841,196 | 841,197 | u145855676 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define yesno(flg) \
if (flg) { \
cout << "YES" << endl; \
} else { \
cout << "NO" << endl; \
}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<Pii, int> Piii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<string, int> Psi;
typedef pair<Psi, int> Psii;
const int inf = 1000000000;
struct edge {
int myc, to, c, cost;
};
struct pos {
int to, cost, color;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int f[MAX_N] = {};
int b[MAX_N] = {};
int main() {
int n, m;
cin >> n >> m;
int dp[10][10] = {};
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
dp[s - 1][i] = 1;
}
}
int p[m] = {};
rep(i, m) cin >> p[m];
int res = 0;
rep(i, (1 << n)) {
int d[m] = {};
rep(j, n) {
if ((i & (1 << j)) > 0) {
rep(k, m) { d[k] += dp[j][k]; }
}
}
bool flg = true;
rep(k, m) {
if (p[k] != (d[k] % 2))
flg = false;
}
if (flg)
res++;
}
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define yesno(flg) \
if (flg) { \
cout << "YES" << endl; \
} else { \
cout << "NO" << endl; \
}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<Pii, int> Piii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<string, int> Psi;
typedef pair<Psi, int> Psii;
const int inf = 1000000000;
struct edge {
int myc, to, c, cost;
};
struct pos {
int to, cost, color;
};
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int f[MAX_N] = {};
int b[MAX_N] = {};
int main() {
int n, m;
cin >> n >> m;
int dp[10][10] = {};
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
dp[s - 1][i] = 1;
}
}
int p[m] = {};
rep(i, m) cin >> p[i];
int res = 0;
rep(i, (1 << n)) {
int d[m] = {};
rep(j, n) {
if ((i & (1 << j)) > 0) {
rep(k, m) { d[k] += dp[j][k]; }
}
}
bool flg = true;
rep(k, m) {
if (p[k] != (d[k] % 2))
flg = false;
}
if (flg)
res++;
}
cout << res << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 841,198 | 841,199 | u707053380 | cpp |
p03031 | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << (x) << endl
int main() {
//入力受け取り
int n, m;
cin >> n >> m;
vector<vector<int>> vec(m); //各電球につながっているスイッチの種類
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int x;
cin >> x;
vec[i].push_back(x - 1);
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
// bit全探索開始
int count = 0;
for (int bit = 0; bit < (1 << n); ++bit) {
bool flag = true;
for (int j = 0; j < m; ++j) {
int con = 0;
for (int v : vec[j]) {
if (bit & (1 << v))
++con;
COUT(con);
}
if (con % 2 != p[j]) {
flag = false;
break;
}
}
if (flag)
++count;
}
COUT(count);
return 0;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << (x) << endl
int main() {
//入力受け取り
int n, m;
cin >> n >> m;
vector<vector<int>> vec(m); //各電球につながっているスイッチの種類
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int x;
cin >> x;
vec[i].push_back(x - 1);
}
}
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
// bit全探索開始
int count = 0;
for (int bit = 0; bit < (1 << n); ++bit) {
bool flag = true;
for (int j = 0; j < m; ++j) {
int con = 0;
for (int v : vec[j]) {
if (bit & (1 << v))
++con;
}
if (con % 2 != p[j]) {
flag = false;
break;
}
}
if (flag)
++count;
}
COUT(count);
return 0;
} | [
"call.remove"
] | 841,206 | 841,207 | u459105164 | cpp |
p03031 | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MOD (1000000007)
using namespace std;
typedef long long int Int;
constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
vector<int> B[20];
vector<int> P;
int main(void) {
int N, M;
cin >> N >> M;
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int b;
cin >> b;
B[i].push_back(b);
}
}
for (int i = 0; i < M; i++) {
int p;
cin >> p;
P.push_back(p);
}
int ans = 0;
for (int i = 1; i < (1 << N); i++) {
bool flag = true;
for (int m = 0; m < N; m++) {
int count = 0;
for (int j = 0; j < B[m].size(); j++) {
if ((i & 1 << (B[m][j] - 1))) {
count++;
}
}
if (count % 2 != P[m])
flag = false;
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MOD (1000000007)
using namespace std;
typedef long long int Int;
constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
vector<int> B[20];
vector<int> P;
int main(void) {
int N, M;
cin >> N >> M;
for (int i = 0; i < M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int b;
cin >> b;
B[i].push_back(b);
}
}
for (int i = 0; i < M; i++) {
int p;
cin >> p;
P.push_back(p);
}
int ans = 0;
for (int i = 0; i < (1 << N); i++) {
bool flag = true;
for (int m = 0; m < M; m++) {
int count = 0;
for (int j = 0; j < B[m].size(); j++) {
if ((i & 1 << (B[m][j] - 1))) {
count++;
}
}
if (count % 2 != P[m])
flag = false;
}
if (flag) {
ans++;
}
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"identifier.change",
"control_flow.loop.for.condition.change",
"expression.operation.binary.change"
] | 841,211 | 841,212 | u498141549 | cpp |
p03031 | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MOD (1000000007)
using namespace std;
typedef long long int Int;
constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
int N, M;
map<int, int> m[20];
int P[20];
int main(void) {
cin >> N >> M;
for (int i = 1; i <= M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
m[i][s] = 1;
}
}
for (int i = 1; i <= M; i++) {
int p;
cin >> p;
P[i] = p;
}
int d;
int ans = 0;
d = (1 << N);
for (int bit = 1; bit < d; bit++) {
int num = bit;
int score[M + 1] = {0};
for (int i = 0; i < N; i++) {
if ((num >> i) & 1) {
int swit = i + 1;
for (int j = 1; j <= M; j++) {
if (m[j].count(swit) != 0)
score[j]++;
}
}
}
bool flag = true;
for (int i = 1; i <= M; i++) {
if ((score[i] % 2) != P[i]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MOD (1000000007)
using namespace std;
typedef long long int Int;
constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
int N, M;
map<int, int> m[20];
int P[20];
int main(void) {
cin >> N >> M;
for (int i = 1; i <= M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
m[i][s] = 1;
}
}
for (int i = 1; i <= M; i++) {
int p;
cin >> p;
P[i] = p;
}
int d;
int ans = 0;
d = (1 << N);
for (int bit = 0; bit < d; bit++) {
int num = bit;
int score[M + 1] = {0};
for (int i = 0; i < N; i++) {
if ((num >> i) & 1) {
int swit = i + 1;
for (int j = 1; j <= M; j++) {
if (m[j].count(swit) != 0)
score[j]++;
}
}
}
bool flag = true;
for (int i = 1; i <= M; i++) {
if ((score[i] % 2) != P[i]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 841,213 | 841,214 | u498141549 | cpp |
p03031 | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MOD (1000000007)
using namespace std;
typedef long long int Int;
constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
int N, M;
map<int, int> m[20];
int P[20];
int main(void) {
cin >> N >> M;
for (int i = 1; i <= M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
m[i][s] = 1;
}
}
for (int i = 1; i <= M; i++) {
int p;
cin >> p;
P[i] = p;
}
int d;
int ans = 0;
d = (1 << N);
for (int bit = 1; bit < d; bit++) {
int num = bit;
int score[N + 1] = {0};
for (int i = 0; i < N; i++) {
if ((num >> i) & 1) {
int swit = i + 1;
for (int j = 1; j <= M; j++) {
if (m[j].count(swit) != 0)
score[j]++;
}
}
}
bool flag = true;
for (int i = 1; i <= M; i++) {
if (score[i] % 2 != P[i]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define MOD (1000000007)
using namespace std;
typedef long long int Int;
constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
int N, M;
map<int, int> m[20];
int P[20];
int main(void) {
cin >> N >> M;
for (int i = 1; i <= M; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int s;
cin >> s;
m[i][s] = 1;
}
}
for (int i = 1; i <= M; i++) {
int p;
cin >> p;
P[i] = p;
}
int d;
int ans = 0;
d = (1 << N);
for (int bit = 0; bit < d; bit++) {
int num = bit;
int score[M + 1] = {0};
for (int i = 0; i < N; i++) {
if ((num >> i) & 1) {
int swit = i + 1;
for (int j = 1; j <= M; j++) {
if (m[j].count(swit) != 0)
score[j]++;
}
}
}
bool flag = true;
for (int i = 1; i <= M; i++) {
if ((score[i] % 2) != P[i]) {
flag = false;
break;
}
}
if (flag)
ans++;
}
cout << ans << endl;
return 0;
}
| [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one",
"identifier.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change"
] | 841,215 | 841,214 | u498141549 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using ll = long long;
using P = pair<int, int>;
using mp = map<string, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
vector<int> P(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int x;
cin >> x;
x--;
s[j].push_back(x);
}
}
rep(i, m) { cin >> P[i]; }
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
bool ok = true;
rep(j, m) {
int cnt = 0;
for (auto &p : s[j]) {
if ((i >> p) & 1) {
cnt++;
}
}
if (cnt % 2 != P[j]) {
ok = false;
}
}
if (ok) {
ans++;
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
using ll = long long;
using P = pair<int, int>;
using mp = map<string, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
vector<vector<int>> s(m);
vector<int> P(m);
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int x;
cin >> x;
x--;
s[i].push_back(x);
}
}
rep(i, m) { cin >> P[i]; }
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
bool ok = true;
rep(j, m) {
int cnt = 0;
for (auto &p : s[j]) {
if ((i >> p) & 1) {
cnt++;
}
}
if (cnt % 2 != P[j]) {
ok = false;
}
}
if (ok) {
ans++;
}
}
cout << ans << endl;
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change"
] | 841,227 | 841,228 | u358859892 | cpp |
p03031 | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#define fir first
#define sec second
#define sz(s) (s).size();
#define pb push_back
#define get(n) scanf("%d", &n);
#define gets(s) \
string s; \
cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i, j) for (int(i) = 0; (i) < (j); (i)++)
#define repk(i, j, k) for (int(i) = (j); (i) < (k); (i)++)
#define repdown(i, j, k) for (int(i) = (j); (i) >= (j); (i)--)
#define dump(x) std::cout << #x << " = " << (x) << std::endl;
#define debug(x) \
cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
using ll = long long;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vd = std::vector<double>;
using vvd = std::vector<vd>;
using qi = std::queue<int>;
using vpii = std::vector<std::pair<int, int>>;
using namespace std;
const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const ll INF = 10241024;
long double INFD = 100100100;
//_____________________________________Templates_________________________________________//
template <class T1, class T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <class T1, class T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
template <class T1, class T2> inline void Abs(T1 &a) { a > 0 ? a : -a; }
// mainly use for dynamic prog
template <class T1, class T2> void update(T1 &a, T2 b) {
a += b;
if (a > Mod)
a %= Mod;
}
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
cin >> first;
IN(rest...);
return;
}
inline void OUT(void) {
cout << "\n";
return;
}
template <typename First, typename... Rest>
void OUT(First first, Rest... rest) {
cout << first << " ";
OUT(rest...);
return;
}
//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
vvi C(A.size(), vi(B.size()))
rep(i,A.size()){
rep(j,B.size()){
rep(k,B[0].size()){
C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
}
}
}
return C;
}
vvi pow(vvi A, ll n){
vvi B(A.size(), vi(A.size()));
rep(i=0;i<A.size();i++){
B[i][i] = 1;
}
while (n >0){
if (n & 1) B = mul(B, A);
A = mul(A, A);
n = n >> 1;
}
return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
int s = 0;
while(i > 0){
s += bit[i];
i -= i & -i;
}
return s;
}
void add(int i, int x){
while(i <= n){
bit[i] += x;
i += i & -i;
}
}
*/
//_____________________ following sorce code_________________________//
int n, m;
vvi vec;
vi modv;
void input() {
IN(n, m);
vec.resize(n);
modv.resize(m);
rep(i, m) {
int a;
IN(a);
rep(j, a) {
int b;
IN(b);
b--;
vec[b].pb(i);
}
}
rep(i, m) { IN(modv[i]); }
}
void solve() {
input();
int ans = 0;
for (int i = 0; i < (1 << n); i++) {
vi res(m);
bool ok = true;
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
for (auto c : vec[j]) {
res[c]++;
}
}
}
for (int j = 0; j < m; j++) {
res[j] %= 2;
if (res[j] != modv[j]) {
break;
ok = false;
}
}
if (ok)
ans++;
}
OUT(ans);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#define fir first
#define sec second
#define sz(s) (s).size();
#define pb push_back
#define get(n) scanf("%d", &n);
#define gets(s) \
string s; \
cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i, j) for (int(i) = 0; (i) < (j); (i)++)
#define repk(i, j, k) for (int(i) = (j); (i) < (k); (i)++)
#define repdown(i, j, k) for (int(i) = (j); (i) >= (j); (i)--)
#define dump(x) std::cout << #x << " = " << (x) << std::endl;
#define debug(x) \
cout << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
using ll = long long;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vd = std::vector<double>;
using vvd = std::vector<vd>;
using qi = std::queue<int>;
using vpii = std::vector<std::pair<int, int>>;
using namespace std;
const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const ll INF = 10241024;
long double INFD = 100100100;
//_____________________________________Templates_________________________________________//
template <class T1, class T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <class T1, class T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
template <class T1, class T2> inline void Abs(T1 &a) { a > 0 ? a : -a; }
// mainly use for dynamic prog
template <class T1, class T2> void update(T1 &a, T2 b) {
a += b;
if (a > Mod)
a %= Mod;
}
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
cin >> first;
IN(rest...);
return;
}
inline void OUT(void) {
cout << "\n";
return;
}
template <typename First, typename... Rest>
void OUT(First first, Rest... rest) {
cout << first << " ";
OUT(rest...);
return;
}
//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
vvi C(A.size(), vi(B.size()))
rep(i,A.size()){
rep(j,B.size()){
rep(k,B[0].size()){
C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
}
}
}
return C;
}
vvi pow(vvi A, ll n){
vvi B(A.size(), vi(A.size()));
rep(i=0;i<A.size();i++){
B[i][i] = 1;
}
while (n >0){
if (n & 1) B = mul(B, A);
A = mul(A, A);
n = n >> 1;
}
return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
int s = 0;
while(i > 0){
s += bit[i];
i -= i & -i;
}
return s;
}
void add(int i, int x){
while(i <= n){
bit[i] += x;
i += i & -i;
}
}
*/
//_____________________ following sorce code_________________________//
int n, m;
vvi vec;
vi modv;
void input() {
IN(n, m);
vec.resize(n);
modv.resize(m);
rep(i, m) {
int a;
IN(a);
rep(j, a) {
int b;
IN(b);
b--;
vec[b].pb(i);
}
}
rep(i, m) { IN(modv[i]); }
}
void solve() {
input();
int ans = 0;
for (int i = 0; i < (1 << n); i++) {
vi res(m);
bool ok = true;
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
for (auto c : vec[j]) {
res[c]++;
}
}
}
for (int j = 0; j < m; j++) {
res[j] %= 2;
if (res[j] != modv[j]) {
ok = false;
break;
}
}
if (ok)
ans++;
}
OUT(ans);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
solve();
return 0;
} | [
"control_flow.break.add"
] | 841,231 | 841,232 | u264405855 | cpp |
p03031 | #include "bits/stdc++.h"
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define DUMP(i, v) \
for (ll i = 0; i < v.size(); i++) \
cout << v[i] << " "
using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge {
ll from, to, cost;
};
ll mod(ll a, ll mod) {
ll res = a % mod;
if (res < 0)
res = res + mod;
return res;
}
ll modpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); }
ll gcd(ll a, ll b) {
ll r = a % b;
if (r == 0)
return b;
else
return gcd(b, a % b);
}
bool is_prime(ll n) {
ll i = 2;
if (n == 1)
return false;
if (n == 2)
return true;
bool res = true;
while (i * i < n) {
if (n % i == 0) {
res = false;
}
i = i + 1;
}
// if(i==1)res = false;
if (n % i == 0)
res = false;
return res;
}
/**************************************
** A main function starts from here **
***************************************/
int main() {
ll N, M;
cin >> N >> M;
vector<llvec> s(N);
rep(i, M) {
ll tmp;
cin >> tmp;
rep(i, tmp) {
ll a;
cin >> a;
a--;
s[a].push_back(i);
}
}
llvec p(M);
rep(i, M) { cin >> p[i]; }
ll cnt = 0;
rep(i, pow(2, N)) {
vector<ll> ans(M, 0);
// llvec dig(N);
rep(j, N) {
// dig[j]=i>>j&1;
if (i >> j & 1) {
rep(ii, s[j].size()) { ans[s[j][ii]] += 1; }
}
}
// DUMP(k, dig);
// DUMP(k, ans);cout << endl;
bool tmp = true;
rep(j, M) { tmp = tmp and (ans[j] % 2 == p[j]); }
if (tmp)
cnt++;
}
cout << cnt;
return 0;
}
| #include "bits/stdc++.h"
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define DUMP(i, v) \
for (ll i = 0; i < v.size(); i++) \
cout << v[i] << " "
using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge {
ll from, to, cost;
};
ll mod(ll a, ll mod) {
ll res = a % mod;
if (res < 0)
res = res + mod;
return res;
}
ll modpow(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll modinv(ll a, ll mod) { return modpow(a, mod - 2, mod); }
ll gcd(ll a, ll b) {
ll r = a % b;
if (r == 0)
return b;
else
return gcd(b, a % b);
}
bool is_prime(ll n) {
ll i = 2;
if (n == 1)
return false;
if (n == 2)
return true;
bool res = true;
while (i * i < n) {
if (n % i == 0) {
res = false;
}
i = i + 1;
}
// if(i==1)res = false;
if (n % i == 0)
res = false;
return res;
}
/**************************************
** A main function starts from here **
***************************************/
int main() {
ll N, M;
cin >> N >> M;
vector<llvec> s(N);
rep(i, M) {
ll tmp;
cin >> tmp;
rep(j, tmp) {
ll a;
cin >> a;
a--;
s[a].push_back(i);
}
}
llvec p(M);
rep(i, M) { cin >> p[i]; }
ll cnt = 0;
rep(i, pow(2, N)) {
vector<ll> ans(M, 0);
// llvec dig(N);
rep(j, N) {
// dig[j]=i>>j&1;
if (i >> j & 1) {
rep(ii, s[j].size()) { ans[s[j][ii]] += 1; }
}
}
// DUMP(k, dig);
// DUMP(k, ans);cout << endl;
bool tmp = true;
rep(j, M) { tmp = tmp and (ans[j] % 2 == p[j]); }
if (tmp)
cnt++;
}
cout << cnt;
return 0;
}
| [] | 841,235 | 841,236 | u225053756 | cpp |
p03031 | #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<vector<bool>> g(n, vector<bool>(m, false));
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
g[i][s] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> a(m, 0);
rep(i, n) {
if (bit & (1 << i)) {
rep(j, m) {
if (g[i][j])
a[j] ^= 1;
}
}
}
bool jud = true;
rep(i, m) {
if (p[i] != a[i])
jud = false;
}
if (jud)
ans++;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;
int main() {
int n, m;
cin >> n >> m;
vector<vector<bool>> g(n, vector<bool>(m, false));
rep(i, m) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
s--;
g[s][i] = true;
}
}
vector<int> p(m);
rep(i, m) cin >> p[i];
ll ans = 0;
for (int bit = 0; bit < (1 << n); bit++) {
vector<int> a(m, 0);
rep(i, n) {
if (bit & (1 << i)) {
rep(j, m) {
if (g[i][j])
a[j] ^= 1;
}
}
}
bool jud = true;
rep(i, m) {
if (p[i] != a[i])
jud = false;
}
if (jud)
ans++;
}
cout << ans << endl;
}
| [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 841,239 | 841,240 | u454081619 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> vv(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int h;
cin >> h;
vv[i].push_back(--h);
}
}
vector<int> swi(m);
for (auto &x : swi)
cin >> x;
int ret = 0;
for (int i = 0; i << n; i++) {
bool flag = true;
for (int j = 0; j < m; j++) {
int on = 0;
for (const auto &x : vv[j]) {
if (i >> x & 1)
on++;
}
if (on % 2 != swi[j])
flag = false;
}
if (flag)
ret++;
}
cout << ret << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> vv(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int h;
cin >> h;
vv[i].push_back(--h);
}
}
vector<int> swi(m);
for (auto &x : swi)
cin >> x;
int ret = 0;
for (int i = 0; i < 1 << n; i++) {
bool flag = true;
for (int j = 0; j < m; j++) {
int on = 0;
for (const auto &x : vv[j]) {
if (i >> x & 1)
on++;
}
if (on % 2 != swi[j])
flag = false;
}
if (flag)
ret++;
}
cout << ret << endl;
}
| [
"control_flow.loop.for.condition.change"
] | 841,243 | 841,242 | u595893956 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> vv(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int h;
cin >> h;
vv[i].push_back(--h);
}
}
vector<int> swi(n);
for (auto &x : swi)
cin >> x;
int ret = 0;
for (int i = 0; i << n; i++) {
bool flag = true;
for (int j = 0; j < m; j++) {
int on = 0;
for (const auto &x : vv[j]) {
if (i >> x & 1)
on++;
}
if (on % 2 != swi[j])
flag = false;
}
if (flag)
ret++;
}
cout << ret << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> vv(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int j = 0; j < k; j++) {
int h;
cin >> h;
vv[i].push_back(--h);
}
}
vector<int> swi(m);
for (auto &x : swi)
cin >> x;
int ret = 0;
for (int i = 0; i < 1 << n; i++) {
bool flag = true;
for (int j = 0; j < m; j++) {
int on = 0;
for (const auto &x : vv[j]) {
if (i >> x & 1)
on++;
}
if (on % 2 != swi[j])
flag = false;
}
if (flag)
ret++;
}
cout << ret << endl;
}
| [
"control_flow.loop.for.condition.change"
] | 841,244 | 841,242 | u595893956 | cpp |
p03031 | #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> S(N);
rep(i, M) {
int k;
cin >> k;
rep(i, k) {
int s;
cin >> s;
S[s - 1].push_back(i);
}
}
vector<int> p(M);
rep(i, M) cin >> p[i];
int cnt = 0;
for (int bit = 0; bit < (1 << N); ++bit) {
vector<int> X;
rep(i, N) {
if (bit & (1 << i))
X.push_back(i);
}
vector<int> P(M, 0);
for (int x : X) {
for (int y : S[x])
++P[y];
}
rep(i, M) P[i] %= 2;
bool judge = true;
rep(i, M) {
if (p[i] != P[i])
judge = false;
}
if (judge)
++cnt;
}
cout << cnt << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> S(N);
rep(i, M) {
int k;
cin >> k;
rep(j, k) {
int s;
cin >> s;
S[s - 1].push_back(i);
}
}
vector<int> p(M);
rep(i, M) cin >> p[i];
int cnt = 0;
for (int bit = 0; bit < (1 << N); ++bit) {
vector<int> X;
rep(i, N) {
if (bit & (1 << i))
X.push_back(i);
}
vector<int> P(M, 0);
for (int x : X) {
for (int y : S[x])
++P[y];
}
rep(i, M) P[i] %= 2;
bool judge = true;
rep(i, M) {
if (p[i] != P[i])
judge = false;
}
if (judge)
++cnt;
}
cout << cnt << endl;
return 0;
}
| [] | 841,245 | 841,246 | u826189900 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define INF 1000000000000 // 10^12
#define MOD 10000007 // 10^9+7
template <typename T> string printVector(const vector<T> &data) {
stringstream ss;
ostream_iterator<T> out_it(ss, ", ");
ss << "[";
std::copy(data.begin(), data.end() - 1, out_it);
ss << data.back() << "]";
return ss.str();
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, k;
cin >> n >> m;
vector<vector<int>> switches;
vector<int> p;
for (int i = 0; i < m; ++i) {
vector<int> input_switches;
cin >> k;
for (int j = 0; j < k; ++j) {
int t;
cin >> t;
input_switches.push_back(t);
}
switches.push_back(input_switches);
}
for (int i = 0; i < m; ++i) {
int t;
cin >> t;
p.push_back(t);
}
int ans = 0;
for (int i = 0; i <= pow(2, n); ++i) {
int ok = 0;
for (int j = 0; j < m; ++j) {
int acc = 0;
for (auto x : switches[j]) {
if (i & (1 << (x - 1))) {
acc++;
}
}
if (acc % 2 == p[j]) {
ok++;
}
}
if (ok == m)
ans++;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define INF 1000000000000 // 10^12
#define MOD 10000007 // 10^9+7
template <typename T> string printVector(const vector<T> &data) {
stringstream ss;
ostream_iterator<T> out_it(ss, ", ");
ss << "[";
std::copy(data.begin(), data.end() - 1, out_it);
ss << data.back() << "]";
return ss.str();
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, k;
cin >> n >> m;
vector<vector<int>> switches;
vector<int> p;
for (int i = 0; i < m; ++i) {
vector<int> input_switches;
cin >> k;
for (int j = 0; j < k; ++j) {
int t;
cin >> t;
input_switches.push_back(t);
}
switches.push_back(input_switches);
}
for (int i = 0; i < m; ++i) {
int t;
cin >> t;
p.push_back(t);
}
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
int ok = 0;
for (int j = 0; j < m; ++j) {
int acc = 0;
for (auto x : switches[j]) {
if (i & (1 << (x - 1))) {
acc++;
}
}
if (acc % 2 == p[j]) {
ok++;
}
}
if (ok == m)
ans++;
}
cout << ans << endl;
}
| [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 841,247 | 841,248 | u505420467 | cpp |
p03031 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
bitset<10> bb;
cin >> n >> m;
vector<bitset<10>> sw(m);
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int ii = 0; ii < k; ii++) {
int a;
cin >> a;
sw.at(i).set(a - 1);
}
}
for (int i = 0; i < m; i++)
cin >> p.at(i);
int cnt = 0;
for (int i = 1; i < (1 << n); i++) {
bb = i;
bool can = true;
for (int j = 0; j < m; j++) {
int tmpcnt = 0;
for (int k = 0; k < n; k++)
if (sw.at(j).test(k) && bb.test(k))
tmpcnt++;
if (tmpcnt % 2 != p.at(j))
can = false;
}
if (can)
cnt++;
}
cout << cnt << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
bitset<10> bb;
cin >> n >> m;
vector<bitset<10>> sw(m);
vector<int> p(m);
for (int i = 0; i < m; i++) {
int k;
cin >> k;
for (int ii = 0; ii < k; ii++) {
int a;
cin >> a;
sw.at(i).set(a - 1);
}
}
for (int i = 0; i < m; i++)
cin >> p.at(i);
int cnt = 0;
for (int i = 0; i < (1 << n); i++) {
bb = i;
bool can = true;
for (int j = 0; j < m; j++) {
int tmpcnt = 0;
for (int k = 0; k < n; k++)
if (sw.at(j).test(k) && bb.test(k))
tmpcnt++;
if (tmpcnt % 2 != p.at(j))
can = false;
}
if (can)
cnt++;
}
cout << cnt << endl;
} | [
"literal.number.change",
"variable_declaration.value.change",
"control_flow.loop.for.initializer.change",
"expression.off_by_one"
] | 841,249 | 841,250 | u119737518 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.