Datasets:

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 <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; auto k = vector<int>(m); auto s = vector<vector<int>>(m); auto p = vector<int>(m); for (int i = 0; i < m; i++) { cin >> k[i]; for (int j = 0; j < k[i]; j++) { int tmp; cin >> tmp; s[i].push_back(tmp); } } for (int i = 0; i < m; i++) { cin >> p[i]; } int ans = 0; int ok; for (int i = 0; i < (int)pow(2, n); i++) { ok = 1; for (int j = 0; j < m; j++) { int sum = 0; for (int l = 0; l < k[i]; l++) { sum = (sum + ((i / (int)pow(2, s[j][l])) % 2)) % 2; } if (sum != p[j]) { ok = 0; break; } } if (ok == 1) ans++; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; auto k = vector<int>(m); auto s = vector<vector<int>>(m); auto p = vector<int>(m); for (int i = 0; i < m; i++) { cin >> k[i]; for (int j = 0; j < k[i]; j++) { int tmp; cin >> tmp; s[i].push_back(tmp); } } for (int i = 0; i < m; i++) { cin >> p[i]; } int ans = 0; int ok; for (int i = 0; i < (int)pow(2, n); i++) { ok = 1; for (int j = 0; j < m; j++) { int sum = 0; for (int l = 0; l < k[j]; l++) { sum = (sum + ((i / (int)pow(2, s[j][l] - 1)) % 2)) % 2; } if (sum != p[j]) { ok = 0; break; } } if (ok == 1) ans++; } cout << ans << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change", "assignment.change" ]
841,821
841,820
u855985627
cpp
p03031
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef vector<int> VI; const ll MOD = 1e9 + 7; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int n, m; VI k(20), p(20); int s[20][20]; int sj[20] = {0}; int ans = 0; void dps(int i) { if (i == n) { int flag = 1; REP(j, m) { int os = 0; REP(l, k[j]) { os += sj[s[j][l]]; } if (os % 2 != p[j]) flag = 0; } if (flag) ans++; return; } sj[i] = 0; dps(i + 1); sj[i] = 1; dps(i + 1); return; } int main() { cin >> n >> m; REP(i, m) { cin >> k[i]; REP(j, k[i]) cin >> s[i][j]; } REP(i, m) cin >> p[i]; dps(0); cout << ans; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef vector<int> VI; const ll MOD = 1e9 + 7; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int n, m; VI k(20), p(20); int s[20][20]; int sj[20] = {0}; int ans = 0; void dps(int i) { if (i == n) { int flag = 1; REP(j, m) { int os = 0; REP(l, k[j]) { os += sj[s[j][l] - 1]; } if (os % 2 != p[j]) flag = 0; } if (flag) ans++; return; } sj[i] = 0; dps(i + 1); sj[i] = 1; dps(i + 1); return; } int main() { cin >> n >> m; REP(i, m) { cin >> k[i]; REP(j, k[i]) cin >> s[i][j]; } REP(i, m) cin >> p[i]; dps(0); cout << ans; }
[ "assignment.change" ]
841,825
841,826
u408650734
cpp
p03031
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef vector<int> VI; const ll MOD = 1e9 + 7; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int n, m; VI k(20), p(20); int s[20][20]; int sj[20] = {0}; int ans = 0; void dps(int i) { if (i == n) { int flag = 1; REP(j, m) { int os = 0; REP(l, k[j]) { os += sj[s[j][l]]; } if (os % 2 != p[m]) flag = 0; } if (flag) ans++; return; } sj[i] = 0; dps(i + 1); sj[i] = 1; dps(i + 1); return; } int main() { cin >> n >> m; REP(i, m) { cin >> k[i]; REP(j, k[i]) cin >> s[i][j]; } REP(i, m) cin >> p[i]; dps(0); cout << ans; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; typedef vector<int> VI; const ll MOD = 1e9 + 7; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int n, m; VI k(20), p(20); int s[20][20]; int sj[20] = {0}; int ans = 0; void dps(int i) { if (i == n) { int flag = 1; REP(j, m) { int os = 0; REP(l, k[j]) { os += sj[s[j][l] - 1]; } if (os % 2 != p[j]) flag = 0; } if (flag) ans++; return; } sj[i] = 0; dps(i + 1); sj[i] = 1; dps(i + 1); return; } int main() { cin >> n >> m; REP(i, m) { cin >> k[i]; REP(j, k[i]) cin >> s[i][j]; } REP(i, m) cin >> p[i]; dps(0); cout << ans; }
[ "assignment.change", "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
841,827
841,826
u408650734
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int bit, i, j, M, N; int number[10], switches[10][10], onoff[10]; int ultimatesum = 0; cin >> N >> M; for (i = 0; i < M; i++) { cin >> number[i]; for (j = 0; j < number[i]; j++) scanf("%d", &switches[i][j]); } for (i = 0; i < M; i++) cin >> onoff[i]; for (bit = 0; bit < pow(2.0, double(M)); bit++) { for (i = 0; i < M; i++) { int somesum1 = 0; for (j = 0; j < number[i]; j++) { int somesum2 = (bit >> (switches[i][j] - 1)) % 2; somesum1 += somesum2; } if (somesum1 % 2 != onoff[i]) break; } if (i == M) ultimatesum++; } cout << ultimatesum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int bit, i, j, M, N; int number[10], switches[10][10], onoff[10]; int ultimatesum = 0; cin >> N >> M; for (i = 0; i < M; i++) { cin >> number[i]; for (j = 0; j < number[i]; j++) scanf("%d", &switches[i][j]); } for (i = 0; i < M; i++) cin >> onoff[i]; for (bit = 0; bit < pow(2.0, (double)N); bit++) { for (i = 0; i < M; i++) { int somesum1 = 0; for (j = 0; j < number[i]; j++) { int somesum2 = (bit >> (switches[i][j] - 1)) % 2; somesum1 += somesum2; } if (somesum1 % 2 != onoff[i]) break; } if (i == M) ultimatesum++; } cout << ultimatesum << endl; return 0; }
[ "call.arguments.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
841,840
841,841
u399527001
cpp
p03031
#include <bits/stdc++.h> using namespace std; // おまじない #define INCANT \ cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), \ cout << fixed << setprecision(20); #define int long long // alias #define gcd __gcd #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() template <typename T> bool chmax(T &a, T b) { return (a = max(a, b)) == b; } template <typename T> bool chmin(T &a, T b) { return (a = min(a, b)) == b; } template <class T> int lb(vector<T> &x, T n) { return lower_bound(all(x), n) - x.begin(); } template <class T> int ub(vector<T> &x, T n) { return upper_bound(all(x), n) - x.begin(); } // for #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__) #define _rev(i, n) revi(i, n, 0) #define revi(i, a, b) for (int i = (int)(a - 1); i >= (int)(b); i--) #define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__) #define each(i, n) for (auto &&i : n) // 入力 void in() {} template <typename F, typename... R> bool in(F &f, R &...r) { if (cin >> f) { in(r...); return true; } else return false; } // 出力 #define out(x) cout << (x) #define space() cout << " " #define indent() cout << '\n' void print() {} template <typename F, typename... R> void print(F f, R... r) { out(f), indent(), print(r...); } // デバッグ出力 #define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": " #define debugout(x) cerr << (x) << " " #define debugindent() cerr << '\n' #define debug(x) debughead(x), debugout(x), debugindent() // 脳死 #define YN(x) out((x) ? "YES" : "NO"), indent() #define Yn(x) out((x) ? "Yes" : "No"), indent() #define yn(x) out((x) ? "yes" : "no"), indent() // const int INF = 1e18, MOD = 1e9 + 7; double EPS = 1e-15, PI = acos(-1); int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1}, dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1}; // 数学的な int lcm(int a, int b) { return a / gcd(a, b) * b; } int factorial(int a) { return a < 2 ? 1 : factorial(a - 1) * a; } int summation(int a) { return a < 1 ? 0 : (a * a + a) / 2; } int combination(int n, int r) { int res = 1; rep(i, 1, r + 1) { res *= n--, res /= i; } return res; } bool isPrime(int n) { rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } if (!(n % i)) { return false; } } return true; } vector<int> divisor(int n) { vector<int> ans; rep(i, 1, sqrt(n) + 1) { if (!(n % i)) { ans.pb(i); if (i * i < n) { ans.pb(n / i); } } } return ans; } map<int, int> factorization(int n) { map<int, int> ans; rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } while (!(n % i)) { ans[i]++, n /= i; } } if (n > 1) { ans[n]++; } return ans; } // MOD int int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1, y = 0; if (b) { g = extgcd(b, a % b, y, x); y -= a / b * x; } return g; } int invmod(int a, int m = MOD) { int x = 0, y = 0; extgcd(a, m, x, y); return (x + m) % m; } struct mint { int _num; mint(int x = 0) : _num() { _num = x % MOD; if (_num < 0) { _num += MOD; } } inline mint operator=(int x) { _num = x % MOD; if (_num < 0) { _num += MOD; } return *this; } inline mint operator=(mint x) { _num = x._num; return *this; } inline mint operator+(int x) { return mint(_num + x); } inline mint operator+(mint x) { int a = _num + x._num; if (a >= MOD) { a -= MOD; } return mint{a}; } inline mint operator+=(int x) { _num += x; _num %= MOD; if (_num < 0) { _num += MOD; } return *this; } inline mint operator+=(mint x) { _num += x._num; if (_num >= MOD) { _num -= MOD; } return *this; } inline mint operator++() { _num++; if (_num == MOD) { _num = 0; } return *this; } inline mint operator-(int x) { return mint(_num - x); } inline mint operator-(mint x) { int a = _num - x._num; if (a < 0) { a += MOD; } return mint{a}; } inline mint operator-=(int x) { _num -= x; _num %= MOD; if (_num < 0) { _num += MOD; } return *this; } inline mint operator-=(mint x) { _num -= x._num; if (_num < 0) { _num += MOD; } return *this; } inline mint operator--() { _num--; if (_num == -1) { _num = MOD - 1; } return *this; } inline mint operator*(int x) { return mint(_num * (x % MOD)); } inline mint operator*(mint x) { return mint{_num * x._num % MOD}; } inline mint operator*=(int x) { _num *= mint(x); _num %= MOD; return *this; } inline mint operator*=(mint x) { _num *= x._num; _num %= MOD; return *this; } inline mint operator/(int x) { return mint(_num * invmod(mint(x), MOD)); } inline mint operator/(mint x) { return mint{_num * invmod(x._num, MOD) % MOD}; } inline mint operator/=(int x) { _num *= invmod(mint(x), MOD); _num %= MOD; return *this; } inline mint operator/=(mint x) { _num *= invmod(x._num, MOD); _num %= MOD; return *this; } inline mint pow(int x) { mint ans = 1, cnt = *this; for (int i = 1; i < x + 1; i *= 2) { if (x & i) { ans *= cnt; x ^= i; } cnt *= cnt; } return ans; } inline operator int() { return _num; } }; vector<mint> fac(1, 1), inv(1, 1); void reserve(int a) { if (fac.size() >= a) return; if (a < fac.size() * 2) a = fac.size() * 2; if (a >= MOD) a = MOD; while (fac.size() < a) fac.push_back(fac.back() * (int)(fac.size())); inv.resize(fac.size()); inv.back() = mint(1) / fac.back(); for (int i = inv.size() - 1; !inv[i - 1]; i--) inv[i - 1] = inv[i] * i; } mint fact(int n) { if (n < 0) return 0; reserve(n + 1); return fac[n]; } mint perm(int n, int r) { if (r < 0 || n < r) return 0; reserve(n + 1); return fac[n] * inv[n - r]; } mint comb(int n, int r) { if (r < 0 || n < r) return 0; reserve(n + 1); return fac[n] * inv[r] * inv[n - r]; } mint mcomb(int n, int r) { return comb(n + r - 1, n - 1); } // r個をn部屋に分ける // UnionFind struct UF { vector<int> t; UF(int size) : t(size, -1) {} int root(int x) { return t[x] < 0 ? x : t[x] = root(t[x]); } int size(int x) { return -t[root(x)]; } bool isSame(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x), y = root(y); if (x != y) { if (t[y] < t[x]) { swap(x, y); } t[x] += t[y], t[y] = x; } return x != y; } }; // main main() { INCANT; int n, m, k, a, res = 0; in(n, m); int s[m], p[m]; rep(i, m) { for (cin >> k; k; k--) { in(a); s[i] |= 1 << a; } } rep(i, m) { in(p[i]); } for (int i = 0; i < 2 << n; i += 2) { int cnt = 0; for (int j = 0; j < m; j++) { a = i & s[j], k = 0; for (; a; a >>= 1) { k += a % 2; } if (k % 2 == p[j]) { cnt++; } } if (cnt == m) { res++; } } print(res); }
#include <bits/stdc++.h> using namespace std; // おまじない #define INCANT \ cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), \ cout << fixed << setprecision(20); #define int long long // alias #define gcd __gcd #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() template <typename T> bool chmax(T &a, T b) { return (a = max(a, b)) == b; } template <typename T> bool chmin(T &a, T b) { return (a = min(a, b)) == b; } template <class T> int lb(vector<T> &x, T n) { return lower_bound(all(x), n) - x.begin(); } template <class T> int ub(vector<T> &x, T n) { return upper_bound(all(x), n) - x.begin(); } // for #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__) #define _rev(i, n) revi(i, n, 0) #define revi(i, a, b) for (int i = (int)(a - 1); i >= (int)(b); i--) #define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__) #define each(i, n) for (auto &&i : n) // 入力 void in() {} template <typename F, typename... R> bool in(F &f, R &...r) { if (cin >> f) { in(r...); return true; } else return false; } // 出力 #define out(x) cout << (x) #define space() cout << " " #define indent() cout << '\n' void print() {} template <typename F, typename... R> void print(F f, R... r) { out(f), indent(), print(r...); } // デバッグ出力 #define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": " #define debugout(x) cerr << (x) << " " #define debugindent() cerr << '\n' #define debug(x) debughead(x), debugout(x), debugindent() // 脳死 #define YN(x) out((x) ? "YES" : "NO"), indent() #define Yn(x) out((x) ? "Yes" : "No"), indent() #define yn(x) out((x) ? "yes" : "no"), indent() // const int INF = 1e18, MOD = 1e9 + 7; double EPS = 1e-15, PI = acos(-1); int dx[] = {0, 0, 1, 0, -1, -1, 1, 1, -1}, dy[] = {0, -1, 0, 1, 0, -1, -1, 1, 1}; // 数学的な int lcm(int a, int b) { return a / gcd(a, b) * b; } int factorial(int a) { return a < 2 ? 1 : factorial(a - 1) * a; } int summation(int a) { return a < 1 ? 0 : (a * a + a) / 2; } int combination(int n, int r) { int res = 1; rep(i, 1, r + 1) { res *= n--, res /= i; } return res; } bool isPrime(int n) { rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } if (!(n % i)) { return false; } } return true; } vector<int> divisor(int n) { vector<int> ans; rep(i, 1, sqrt(n) + 1) { if (!(n % i)) { ans.pb(i); if (i * i < n) { ans.pb(n / i); } } } return ans; } map<int, int> factorization(int n) { map<int, int> ans; rep(i, 2, sqrt(n) + 1) { if (i > 3) { i++; } while (!(n % i)) { ans[i]++, n /= i; } } if (n > 1) { ans[n]++; } return ans; } // MOD int int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1, y = 0; if (b) { g = extgcd(b, a % b, y, x); y -= a / b * x; } return g; } int invmod(int a, int m = MOD) { int x = 0, y = 0; extgcd(a, m, x, y); return (x + m) % m; } struct mint { int _num; mint(int x = 0) : _num() { _num = x % MOD; if (_num < 0) { _num += MOD; } } inline mint operator=(int x) { _num = x % MOD; if (_num < 0) { _num += MOD; } return *this; } inline mint operator=(mint x) { _num = x._num; return *this; } inline mint operator+(int x) { return mint(_num + x); } inline mint operator+(mint x) { int a = _num + x._num; if (a >= MOD) { a -= MOD; } return mint{a}; } inline mint operator+=(int x) { _num += x; _num %= MOD; if (_num < 0) { _num += MOD; } return *this; } inline mint operator+=(mint x) { _num += x._num; if (_num >= MOD) { _num -= MOD; } return *this; } inline mint operator++() { _num++; if (_num == MOD) { _num = 0; } return *this; } inline mint operator-(int x) { return mint(_num - x); } inline mint operator-(mint x) { int a = _num - x._num; if (a < 0) { a += MOD; } return mint{a}; } inline mint operator-=(int x) { _num -= x; _num %= MOD; if (_num < 0) { _num += MOD; } return *this; } inline mint operator-=(mint x) { _num -= x._num; if (_num < 0) { _num += MOD; } return *this; } inline mint operator--() { _num--; if (_num == -1) { _num = MOD - 1; } return *this; } inline mint operator*(int x) { return mint(_num * (x % MOD)); } inline mint operator*(mint x) { return mint{_num * x._num % MOD}; } inline mint operator*=(int x) { _num *= mint(x); _num %= MOD; return *this; } inline mint operator*=(mint x) { _num *= x._num; _num %= MOD; return *this; } inline mint operator/(int x) { return mint(_num * invmod(mint(x), MOD)); } inline mint operator/(mint x) { return mint{_num * invmod(x._num, MOD) % MOD}; } inline mint operator/=(int x) { _num *= invmod(mint(x), MOD); _num %= MOD; return *this; } inline mint operator/=(mint x) { _num *= invmod(x._num, MOD); _num %= MOD; return *this; } inline mint pow(int x) { mint ans = 1, cnt = *this; for (int i = 1; i < x + 1; i *= 2) { if (x & i) { ans *= cnt; x ^= i; } cnt *= cnt; } return ans; } inline operator int() { return _num; } }; vector<mint> fac(1, 1), inv(1, 1); void reserve(int a) { if (fac.size() >= a) return; if (a < fac.size() * 2) a = fac.size() * 2; if (a >= MOD) a = MOD; while (fac.size() < a) fac.push_back(fac.back() * (int)(fac.size())); inv.resize(fac.size()); inv.back() = mint(1) / fac.back(); for (int i = inv.size() - 1; !inv[i - 1]; i--) inv[i - 1] = inv[i] * i; } mint fact(int n) { if (n < 0) return 0; reserve(n + 1); return fac[n]; } mint perm(int n, int r) { if (r < 0 || n < r) return 0; reserve(n + 1); return fac[n] * inv[n - r]; } mint comb(int n, int r) { if (r < 0 || n < r) return 0; reserve(n + 1); return fac[n] * inv[r] * inv[n - r]; } mint mcomb(int n, int r) { return comb(n + r - 1, n - 1); } // r個をn部屋に分ける // UnionFind struct UF { vector<int> t; UF(int size) : t(size, -1) {} int root(int x) { return t[x] < 0 ? x : t[x] = root(t[x]); } int size(int x) { return -t[root(x)]; } bool isSame(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x), y = root(y); if (x != y) { if (t[y] < t[x]) { swap(x, y); } t[x] += t[y], t[y] = x; } return x != y; } }; // main main() { INCANT; int n, m, k, a, res = 0; in(n, m); int s[m] = {}, p[m]; rep(i, m) { for (cin >> k; k; k--) { in(a); s[i] |= 1 << a; } } rep(i, m) { in(p[i]); } for (int i = 0; i < 2 << n; i += 2) { int cnt = 0; for (int j = 0; j < m; j++) { a = i & s[j], k = 0; for (; a; a >>= 1) { k += a % 2; } if (k % 2 == p[j]) { cnt++; } } if (cnt == m) { res++; } } print(res); }
[ "variable_declaration.value.change" ]
841,850
841,851
u303059352
cpp
p03031
#include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<vector<int>> v(k); int x; for (int i = 0; i < k; ++i) { cin >> x; v[i].resize(x); for (int j = 0; j < x; ++j) { cin >> v[i][j]; --v[i][j]; } } vector<int> p(k); for (int i = 0; i < k; ++i) cin >> p[i]; int ans = 0; for (int i = 0; i < (1 << n); ++i) { bool f = true; for (int j = 0; j < k && f; ++j) { int sum = 0; for (int l = 0; l < v[j].size(); ++l) sum += (i >> v[j][l]) & 1; f = ((sum & 1) != p[j]); } ans += f; } cout << ans << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; vector<vector<int>> v(k); int x; for (int i = 0; i < k; ++i) { cin >> x; v[i].resize(x); for (int j = 0; j < x; ++j) { cin >> v[i][j]; --v[i][j]; } } vector<int> p(k); for (int i = 0; i < k; ++i) cin >> p[i]; int ans = 0; for (int i = 0; i < (1 << n); ++i) { bool f = true; for (int j = 0; j < k && f; ++j) { int sum = 0; for (int l = 0; l < v[j].size(); ++l) sum += ((i >> v[j][l]) & 1); f = ((sum & 1) == p[j]); } ans += f; } cout << ans << endl; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "assignment.value.change", "expression.operation.binary.change" ]
841,856
841,857
u146240825
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int s[M] = {}, tmps, k, p[M]; for (int i = 0; i < M; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> tmps; s[i] |= 1 << (tmps - 1); } } for (int i = 0; i < M; i++) { cin >> p[i]; } int ans = 0; bool all_on; for (int i = 1; i < 1 << N; i++) { all_on = true; for (int j = 0; j < M; j++) { int sw_on = s[j] & i; int count = 0; for (int k = 0; k < N; k++) { if (sw_on & (1 << k)) count++; } if (count % 2 != p[j]) { all_on = false; break; } } if (all_on) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int s[M] = {}, tmps, k, p[M]; for (int i = 0; i < M; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> tmps; s[i] |= 1 << (tmps - 1); } } for (int i = 0; i < M; i++) { cin >> p[i]; } int ans = 0; bool all_on; for (int i = 0; i < 1 << N; i++) { all_on = true; for (int j = 0; j < M; j++) { int sw_on = s[j] & i; int count = 0; for (int k = 0; k < N; k++) { if (sw_on & (1 << k)) count++; } if (count % 2 != p[j]) { all_on = false; break; } } if (all_on) ans++; } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
841,859
841,860
u303454114
cpp
p03031
#include <bitset> #include <iostream> #include <vector> using namespace std; int main() { int n, m, n_pow = 0, ans = 0; cin >> n >> m; vector<vector<int>> s(m); vector<int> p(m); for (auto &ss : s) { int k; cin >> k; for (int j = 0; j < k; ++j) { int tmp; cin >> tmp; ss.push_back(tmp - 1); } } for (auto &tp : p) cin >> tp; n_pow = (1 << n); for (int i = 0; i < n_pow; ++i) { bitset<10> bs(i); int index = 0; bool fail = false; for (auto &ss : s) { int t = 0; for (auto &ts : ss) t += (int)bs[ts]; if (t % 2 != p[index++]) { fail = true; break; } ans += !fail; } } cout << ans << endl; }
#include <bitset> #include <iostream> #include <vector> using namespace std; int main() { int n, m, n_pow = 0, ans = 0; cin >> n >> m; vector<vector<int>> s(m); vector<int> p(m); for (auto &ss : s) { int k; cin >> k; for (int j = 0; j < k; ++j) { int tmp; cin >> tmp; ss.push_back(tmp - 1); } } for (auto &tp : p) cin >> tp; n_pow = (1 << n); for (int i = 0; i < n_pow; ++i) { bitset<10> bs(i); int index = 0; bool fail = false; for (auto &ss : s) { int t = 0; for (auto &ts : ss) t += (int)bs[ts]; if (t % 2 != p[index++]) { fail = true; break; } } ans += !fail; } cout << ans << endl; }
[]
841,861
841,862
u911828387
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> vec(M); for (int i = 0; i < M; ++i) { int k; 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]; int ans = 0; for (int i = 0; i < (1 << N); ++i) { bool ok = true; for (int j = 0; j < M; ++j) { int c = 0; for (int id = 0; id < vec[j].size(); id++) { if ((i >> vec[id][j]) & 1) { ++c; } } c %= 2; if (c != p[j]) { ok = false; } } if (ok) { ++ans; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> vec(M); for (int i = 0; i < M; ++i) { int k; 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]; int ans = 0; for (int i = 0; i < (1 << N); ++i) { bool ok = true; for (int j = 0; j < M; ++j) { int c = 0; for (int id = 0; id < vec[j].size(); id++) { if ((i >> vec[j][id]) & 1) { ++c; } } c %= 2; if (c != p[j]) { ok = false; } } if (ok) { ++ans; } } cout << ans << endl; return 0; }
[ "control_flow.branch.if.condition.change", "identifier.change", "variable_access.subscript.index.change" ]
841,863
841,864
u031920644
cpp
p03031
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <complex> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <cassert> #include <functional> typedef long long ll; using namespace std; #ifndef LOCAL #define debug(x) ; #else #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &p) { out << "{" << p.first << ", " << p.second << "}"; return out; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) { out << '{'; for (const T &item : v) out << item << ", "; out << "\b\b}"; return out; } #endif #define mod 1000000007 // 1e9+7(prime number) #define INF 1000000000 // 1e9 #define LLINF 2000000000000000000LL // 2e18 #define SIZE 200010 int light[SIZE]; int p[SIZE]; int main() { 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 s; cin >> s; light[j] |= 1 << (s - 1); } } 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++) { ok &= __builtin_popcount(light[j] & i) % 2 == p[j]; } ans += ok; } cout << ans << endl; return 0; }
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <complex> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <cassert> #include <functional> typedef long long ll; using namespace std; #ifndef LOCAL #define debug(x) ; #else #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &p) { out << "{" << p.first << ", " << p.second << "}"; return out; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) { out << '{'; for (const T &item : v) out << item << ", "; out << "\b\b}"; return out; } #endif #define mod 1000000007 // 1e9+7(prime number) #define INF 1000000000 // 1e9 #define LLINF 2000000000000000000LL // 2e18 #define SIZE 200010 int light[SIZE]; int p[SIZE]; int main() { 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 s; cin >> s; light[i] |= 1 << (s - 1); } } 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++) { ok &= __builtin_popcount(light[j] & i) % 2 == p[j]; } ans += ok; } cout << ans << endl; return 0; }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
841,870
841,871
u378419207
cpp
p03031
#include <bits/stdc++.h> 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; } using namespace std; #define min_3(a, b, c) min(a, min(b, c)) typedef long long ll; const int mod = 1e9 + 7; int main() { int n, m; cin >> n >> m; vector<vector<int>> connect(n); vector<int> p(m); for (int i = 0; i < m; i++) { int k; cin >> k; connect[i].resize(k); for (int j = 0; j < k; j++) { cin >> connect[i][j]; connect[i][j]--; } } for (int i = 0; i < m; i++) cin >> p[i]; int ans = 0; for (int i = 0; i < (1 << n); i++) // 2^n通り試す { bool ok = true; //光る? for (int j = 0; j < m; j++) { int count = 0; for (int id : connect[j]) { if ((i >> id) & 1) count++; //繋がっているものの中でonの個数 } count %= 2; if (count != p[j]) ok = false; } if (ok == 1) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> 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; } using namespace std; #define min_3(a, b, c) min(a, min(b, c)) typedef long long ll; const int mod = 1e9 + 7; int main() { int n, m; cin >> n >> m; vector<vector<int>> connect(m); vector<int> p(m); for (int i = 0; i < m; i++) { int k; cin >> k; connect[i].resize(k); for (int j = 0; j < k; j++) { cin >> connect[i][j]; connect[i][j]--; } } for (int i = 0; i < m; i++) cin >> p[i]; int ans = 0; for (int i = 0; i < (1 << n); i++) // 2^n通り試す { bool ok = true; //光る? for (int j = 0; j < m; j++) { int count = 0; for (int id : connect[j]) { if ((i >> id) & 1) count++; //繋がっているものの中でonの個数 } count %= 2; if (count != p[j]) ok = false; } if (ok == 1) ans++; } cout << ans << endl; return 0; }
[]
841,874
841,875
u170650966
cpp
p03031
#include <iostream> using namespace std; int n, m, k[15], s[15][15], p[15], ans; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> k[i]; for (int j = 1; j <= k[i]; j++) { cin >> s[i][j]; } } for (int i = 1; i <= m; i++) cin >> p[i]; for (int i = 1; i < (1 << (n)); i++) { bool fl = 1; for (int j = 1; j <= m; j++) { int cnt = 0; for (int a = 1; a <= k[j]; a++) { if ((1 << (s[j][a] - 1)) & i) cnt++; } if (cnt % 2 != p[j]) { fl = 0; break; } } if (fl) ans++; } cout << ans << endl; return 0; }
#include <iostream> using namespace std; int n, m, k[15], s[15][15], p[15], ans; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> k[i]; for (int j = 1; j <= k[i]; j++) { cin >> s[i][j]; } } for (int i = 1; i <= m; i++) cin >> p[i]; for (int i = 0; i < (1 << (n)); i++) { bool fl = 1; for (int j = 1; j <= m; j++) { int cnt = 0; for (int a = 1; a <= k[j]; a++) { if ((1 << (s[j][a] - 1)) & i) cnt++; } if (cnt % 2 != p[j]) { fl = 0; break; } } if (fl) ans++; } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
841,876
841,877
u790515578
cpp
p03031
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef unsigned long ul; typedef unsigned int ui; typedef pair<int, int> P; typedef pair<ll, ll> LP; #define All(v) (v).begin(), (v).end() #define Rep(i, n) for (int i = 0; i < (int)n; i++) #define Reps(i, n) for (int i = 1; i <= (int)n; i++) #define For(i, m, n) for (int i = m; i < n; i++) #define Fors(i, m, n) for (int i = m; i <= n; i++) #define Inf 2e9 #define F first #define S second #define pb push_back #define mp make_pair struct speed { speed() { cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } speed; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { int n, m; cin >> n >> m; vector<vector<int>> s(m); vector<int> p(m); Rep(i, m) { int cnt; cin >> cnt; Rep(j, cnt) { int tmp; cin >> tmp; s[i].pb(tmp); } } Rep(i, m) { cin >> p[i]; } int ans = 0; Rep(i, (1 << n)) { int flag = 1; Rep(j, m) { int cnt = 0; Rep(k, s[j].size()) { if (i & (1 << s[j][k])) { cnt++; } } if (cnt % 2 != p[j]) { flag = 0; break; } } if (flag) ans++; } cout << ans << "\n"; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef unsigned long ul; typedef unsigned int ui; typedef pair<int, int> P; typedef pair<ll, ll> LP; #define All(v) (v).begin(), (v).end() #define Rep(i, n) for (int i = 0; i < (int)n; i++) #define Reps(i, n) for (int i = 1; i <= (int)n; i++) #define For(i, m, n) for (int i = m; i < n; i++) #define Fors(i, m, n) for (int i = m; i <= n; i++) #define Inf 2e9 #define F first #define S second #define pb push_back #define mp make_pair struct speed { speed() { cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } speed; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; ll gcd(ll a, ll b) { if (b == 0) return a; else return gcd(b, a % b); } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } int main() { int n, m; cin >> n >> m; vector<vector<int>> s(m); vector<int> p(m); Rep(i, m) { int cnt; cin >> cnt; Rep(j, cnt) { int tmp; cin >> tmp; s[i].pb(tmp); } } Rep(i, m) { cin >> p[i]; } int ans = 0; Rep(i, (1 << n)) { int flag = 1; Rep(j, m) { int cnt = 0; Rep(k, s[j].size()) { if (i & (1 << s[j][k] - 1)) { cnt++; } } if (cnt % 2 != p[j]) { flag = 0; break; } } if (flag) ans++; } cout << ans << "\n"; }
[ "control_flow.branch.if.condition.change" ]
841,890
841,891
u658899890
cpp
p03031
#include <iostream> #include <vector> using namespace std; vector<int> v[15]; int p[20]; int N, M; int main() { cin >> N >> M; for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int x; cin >> x; v[i].push_back(x); } } 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 : v[j]) { if (i & (1 << k)) cnt++; } if (cnt % 2 != p[j]) ok = false; } if (ok) ans++; } cout << ans << endl; return 0; }
#include <iostream> #include <vector> using namespace std; vector<int> v[15]; int p[20]; int N, M; int main() { cin >> N >> M; for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int x; cin >> x; x--; v[i].push_back(x); } } 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 : v[j]) { if (i & (1 << k)) cnt++; } if (cnt % 2 != p[j]) ok = false; } if (ok) ans++; } cout << ans << endl; return 0; }
[ "expression.unary.arithmetic.add" ]
841,903
841,904
u090967649
cpp
p03031
#include <iostream> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> k(m); vector<vector<int>> s(m); vector<int> p(m); for (int i = 0; i < m; i++) { cin >> k[i]; for (int j = 0; j < k[i]; j++) { int tmp; cin >> tmp; s[i].push_back(tmp); } } for (int i = 0; i < m; i++) { cin >> p[i]; } int ans = 0; for (int mask = 0; mask < (1 << n); mask++) { bool check = true; for (int i = 0; i < m; i++) { int cnt = 0; for (int j = 0; j < k[i]; j++) { if (mask & (1 << s[i][j])) { cnt++; } } if (cnt % 2 != p[i]) { check = false; break; } } if (check == true) { ans++; } } cout << ans << endl; return 0; }
#include <iostream> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> k(m); vector<vector<int>> s(m); vector<int> p(m); for (int i = 0; i < m; i++) { cin >> k[i]; for (int j = 0; j < k[i]; j++) { int tmp; cin >> tmp; tmp--; s[i].push_back(tmp); } } for (int i = 0; i < m; i++) { cin >> p[i]; } int ans = 0; for (int mask = 0; mask < (1 << n); mask++) { bool check = true; for (int i = 0; i < m; i++) { int cnt = 0; for (int j = 0; j < k[i]; j++) { if (mask & (1 << s[i][j])) { cnt++; } } if (cnt % 2 != p[i]) { check = false; break; } } if (check == true) { ans++; } } cout << ans << endl; return 0; }
[ "expression.unary.arithmetic.add" ]
841,905
841,906
u195054737
cpp
p03031
#include <bits/stdc++.h> using namespace std; void check(int &ans, int N, int &M, vector<int> sw, vector<vector<int>> &vec, vector<int> &p) { if (N == 0) { bool x = true; for (int i = 0; i < M; i++) { int y; for (int j = 0; j < vec[i].size(); j++) { y += sw[vec[i][j] - 1]; } if (y % 2 != p[i]) { x = false; break; } } if (x) { ans++; } return; } check(ans, N - 1, M, sw, vec, p); sw[N - 1] = (sw[N - 1] + 1) % 2; check(ans, N - 1, M, sw, vec, p); } int main() { int N, M; cin >> N >> M; vector<vector<int>> vec(M); for (int i = 0; i < M; i++) { int k; cin >> k; vec[i].resize(k); for (int j = 0; j < k; j++) { cin >> vec[i][j]; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } int ans = 0; vector<int> sw(N, 0); check(ans, N, M, sw, vec, p); cout << ans; }
#include <bits/stdc++.h> using namespace std; void check(int &ans, int N, int &M, vector<int> sw, vector<vector<int>> &vec, vector<int> &p) { if (N == 0) { bool x = true; for (int i = 0; i < M; i++) { int y = 0; for (int j = 0; j < vec[i].size(); j++) { y += sw[vec[i][j] - 1]; } if (y % 2 != p[i]) { x = false; break; } } if (x) { ans++; } return; } check(ans, N - 1, M, sw, vec, p); sw[N - 1] = (sw[N - 1] + 1) % 2; check(ans, N - 1, M, sw, vec, p); } int main() { int N, M; cin >> N >> M; vector<vector<int>> vec(M); for (int i = 0; i < M; i++) { int k; cin >> k; vec[i].resize(k); for (int j = 0; j < k; j++) { cin >> vec[i][j]; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } int ans = 0; vector<int> sw(N, 0); check(ans, N, M, sw, vec, p); cout << ans; }
[ "variable_declaration.value.change" ]
841,909
841,910
u664207511
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, s; cin >> n >> m; vector<vector<int>> light(m); vector<int> p(n); for (int i = 0; i < m; i++) { cin >> k; light[i] = vector<int>(k); for (int j = 0; j < k; j++) cin >> light[i][j]; } for (int i = 0; i < m; i++) cin >> p[i]; int cnt = 0; for (int r = 0; r < (1 << n); r++) { bitset<10> pt(r); for (int i = 0; i < m; i++) { int sm = 0; for (int j : light[i]) { sm ^= pt[j]; } if (p[i] != sm) { cnt--; break; } } cnt++; } cout << cnt << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, s; cin >> n >> m; vector<vector<int>> light(m); vector<int> p(n); for (int i = 0; i < m; i++) { cin >> k; light[i] = vector<int>(k); for (int j = 0; j < k; j++) cin >> light[i][j]; } for (int i = 0; i < m; i++) cin >> p[i]; int cnt = 0; for (int r = 0; r < (1 << n); r++) { bitset<10> pt(r); for (int i = 0; i < m; i++) { int sm = 0; for (int j : light[i]) { sm ^= pt[--j]; } if (p[i] != sm) { cnt--; break; } } cnt++; } cout << cnt << endl; }
[]
841,924
841,925
u798086274
cpp
p03031
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; // typedefリスト typedef long long llint; typedef vector<long long int> vint; typedef vector<vector<int>> vvint; typedef vector<string> vstr; int main(void) { int N, M, ss, num, ans; ans = 0; num = 0; cin >> N >> M; vint K(M), P(M); vvint s(M); for (int i = 0; i < M; i++) { cin >> K[i]; for (int j = 0; j < K[i]; j++) { cin >> ss; s[i].push_back(ss); } } for (int i = 0; i < M; i++) cin >> P[i]; for (int i = 0; i < pow(2, N); i++) { int num = 0; if (i == 0) { for (int j = 0; j < M; j++) { if (P[j] == '0') num++; } } else { for (int k = 0; k < M; k++) { int cou = 0; for (int j = 0; j < N; j++) { if (i & (1 << j)) { for (int l = 0; l < K[k]; l++) { if (s[k][l] == j + 1) cou++; } } } if (P[k] == cou % 2) num++; } } if (num == M) ans++; } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; // typedefリスト typedef long long llint; typedef vector<long long int> vint; typedef vector<vector<int>> vvint; typedef vector<string> vstr; int main(void) { int N, M, ss, num, ans; ans = 0; num = 0; cin >> N >> M; vint K(M), P(M); vvint s(M); for (int i = 0; i < M; i++) { cin >> K[i]; for (int j = 0; j < K[i]; j++) { cin >> ss; s[i].push_back(ss); } } for (int i = 0; i < M; i++) cin >> P[i]; for (int i = 0; i < pow(2, N); i++) { int num = 0; if (i == 0) { for (int j = 0; j < M; j++) { if (P[j] == 0) num++; } } else { for (int k = 0; k < M; k++) { int cou = 0; for (int j = 0; j < N; j++) { if (i & (1 << j)) { for (int l = 0; l < K[k]; l++) { if (s[k][l] == j + 1) cou++; } } } if (P[k] == cou % 2) num++; } } if (num == M) ans++; } cout << ans << endl; }
[ "control_flow.branch.if.condition.change" ]
841,930
841,931
u846679133
cpp
p03031
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; // typedefリスト typedef long long llint; typedef vector<long long int> vint; typedef vector<vector<int>> vvint; typedef vector<string> vstr; int main(void) { int N, M, ss, num, ans; ans = 0; num = 0; cin >> N >> M; vint K(M), P(M); vvint s(M); for (int i = 0; i < M; i++) { cin >> K[i]; for (int j = 0; j < K[i]; j++) { cin >> ss; s[i].push_back(ss); } } for (int i = 0; i < M; i++) cin >> P[i]; for (int i = 0; i < pow(2, N); i++) { int num = 0; if (i == 0) { for (int j = 0; j < M; j++) { if (P[j] == '0') num++; } } else { for (int k = 0; k < M; k++) { int cou = 0; for (int j = 0; j < N; j++) { if (i & (1 << j)) { for (int l = 0; l < K[k]; l++) { if (s[k][l] == j + 1) cou++; } } } if (P[k] == cou % 2) num++; } } if (num == M) ans++; } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <sstream> #include <stdio.h> #include <string> #include <vector> using namespace std; // typedefリスト typedef long long llint; typedef vector<long long int> vint; typedef vector<vector<int>> vvint; typedef vector<string> vstr; int main(void) { int N, M, ss, num, ans; ans = 0; num = 0; cin >> N >> M; vint K(M), P(M); vvint s(M); for (int i = 0; i < M; i++) { cin >> K[i]; for (int j = 0; j < K[i]; j++) { cin >> ss; s[i].push_back(ss); } } for (int i = 0; i < M; i++) cin >> P[i]; for (int i = 0; i < pow(2, N); i++) { int num = 0; if (i == 0) { for (int j = 0; j < M; j++) { if (P[j] == 0) num++; } } else { for (int k = 0; k < M; k++) { int cou = 0; for (int j = 0; j < N; j++) { if (i & (1 << j)) { for (int l = 0; l < K[k]; l++) { if (s[k][l] == j + 1) cou++; } } } if (P[k] == cou % 2) num++; } } if (num == M) ans++; } cout << ans << endl; }
[ "control_flow.branch.if.condition.change" ]
841,932
841,931
u846679133
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cin.sync_with_stdio(false); 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]; for (int j = 0; j < k[i]; j++) { int x; cin >> x; x--; s[i].push_back(x); } } vector<int> p(m); for (int i = 0; i < n; i++) { cin >> p[i]; } const int bsm = 1 << n; int ret = 0; for (int bs = 0; bs < bsm; bs++) { bool flg = false; for (int i = 0; i < m; i++) { int tmp = 0; for (int j = 0; j < k[i]; j++) { tmp ^= (bs >> s[i][j]) & 1; } if (tmp != p[i]) { flg = true; break; } } if (!flg) ret++; } cout << ret << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cin.sync_with_stdio(false); 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]; for (int j = 0; j < k[i]; j++) { int x; cin >> x; x--; s[i].push_back(x); } } vector<int> p(m); for (int i = 0; i < m; i++) { cin >> p[i]; } const int bsm = 1 << n; int ret = 0; for (int bs = 0; bs < bsm; bs++) { bool flg = false; for (int i = 0; i < m; i++) { int tmp = 0; for (int j = 0; j < k[i]; j++) { tmp ^= (bs >> s[i][j]) & 1; } if (tmp != p[i]) { flg = true; break; } } if (!flg) ret++; } cout << ret << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
841,935
841,936
u846041485
cpp
p03031
#include <bitset> #include <iostream> #include <iterator> #include <sstream> #include <vector> using namespace std; int main(void) { int N, M; cin >> N >> M; vector<vector<int>> s(N, vector<int>()); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int n; cin >> n; n--; s[n].push_back(i); } } vector<int> p(M); for (int i = 0; i < M; i++) cin >> p[i]; int ans = 0; for (int i = (1 << N); i >= 0; i--) { bitset<10> state(i); vector<int> cnt(M, 0); for (int j = 0; j < N; j++) { if (state[j] == false) continue; for (auto index : s[j]) cnt[index]++; } bool ok = true; for (int j = 0; j < M; j++) { ok &= (cnt[j] % 2 == p[j]); } if (ok == true) ans++; } cout << ans << endl; return 0; }
#include <bitset> #include <iostream> #include <iterator> #include <sstream> #include <vector> using namespace std; int main(void) { int N, M; cin >> N >> M; vector<vector<int>> s(N, vector<int>()); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int n; cin >> n; n--; s[n].push_back(i); } } vector<int> p(M); for (int i = 0; i < M; i++) cin >> p[i]; int ans = 0; for (int i = (1 << N) - 1; i >= 0; i--) { bitset<10> state(i); vector<int> cnt(M, 0); for (int j = 0; j < N; j++) { if (state[j] == false) continue; for (auto index : s[j]) cnt[index]++; } bool ok = true; for (int j = 0; j < M; j++) { ok &= (cnt[j] % 2 == p[j]); } if (ok == true) ans++; } cout << ans << endl; return 0; }
[ "control_flow.loop.for.initializer.change" ]
841,939
841,940
u013936801
cpp
p03031
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; int *k = new int[m]; vector<vector<int>> s; int *p = new int[m]; int max = 1; for (int i = 0; i < n; i++) max *= 2; for (int i = 0; i < m; i++) { cin >> k[i]; vector<int> ss; for (int j = 0; j < k[i]; j++) { int x; cin >> x; ss.emplace_back(x); } s.emplace_back(ss); } for (int i = 0; i < m; i++) { cin >> p[i]; } int flag = 0; int pattern = 0; for (int i = 0; i < max; i++) { int onNum = 0; for (int j = 0; j < m; j++) { // ビットonが点いているスイッチ int count = 0; for (int ii = 0; ii < k[j]; ii++) { int f = flag; if ((f >> (s[j][ii] - 1)) % 2 == 1) { count++; } } if (count % 2 == p[j]) continue; onNum++; } if (onNum == m) pattern++; flag++; } cout << pattern << '\n'; delete[] k; delete[] p; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; int *k = new int[m]; vector<vector<int>> s; int *p = new int[m]; int max = 1; for (int i = 0; i < n; i++) max *= 2; for (int i = 0; i < m; i++) { cin >> k[i]; vector<int> ss; for (int j = 0; j < k[i]; j++) { int x; cin >> x; ss.emplace_back(x); } s.emplace_back(ss); } for (int i = 0; i < m; i++) { cin >> p[i]; } int flag = 0; int pattern = 0; for (int i = 0; i < max; i++) { int onNum = 0; for (int j = 0; j < m; j++) { // ビットonが点いているスイッチ int count = 0; for (int ii = 0; ii < k[j]; ii++) { int f = flag; if ((f >> (s[j][ii] - 1)) % 2 == 1) { count++; } } if (count % 2 != p[j]) continue; onNum++; } if (onNum == m) pattern++; flag++; } cout << pattern << '\n'; delete[] k; delete[] p; return 0; }
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
841,947
841,948
u961816320
cpp
p03031
#include <bits/stdc++.h> #define ll long long #define ra return a; #define pb push_back #define sti stack<ll> #define spi stack<pair<ll, ll>> #define S second #define msi map<string, ll> #define msi map<string, ll> #define mii map<ll, ll> #define dbg(x) \ { cerr << #x << ": " << x << endl; } #define dbg2(x, y) \ { cerr << #x << ": " << x << " , " << #y << ": " << y << endl; } #define dbg3(x, y, z) \ { \ cerr << #x << ": " << x << " , " << #y << ": " << y << " , " << #z << ": " \ << z << endl; \ } #define mis map<ll, string> #define rep(i, a, b) for (ll i = a; i < b; i++) #define mpi map<pair<ll, ll>, ll> #define pii pair<ll, ll> #define ppb pop_back #define F first #define vi vector<ll> #define vii vector<pair<ll, ll>> #define si set<ll> #define vs vector<string> #define all(a) (a).begin(), (a).end() #define sz(x) (ll) x.size() #define hell 1000000007 #define bs binary_search #define mp make_pair #define qi queue<ll> #define qs queue<string> #define qpi queue<pair<ll, ll>> #define qps queue<pair<ll, string>> #define endl '\n' #define itr(a, it) \ for (typeof(a.begin()) it = a.begin(); it != a.end(); \ it++) // This will produce const_iterator for const object and normal // iterator for non-const object #define ss set<string> using namespace std; #define N 11 ll p[N]; bool check(ll a, vi b, ll c) { ll cnt = 0; for (auto i : b) { if (a & (1 << i)) cnt++; } if (cnt % 2 == p[c]) return true; else return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; // cin>>t; while (t--) { ll n, m; cin >> n >> m; ll k[m]; vi v[m]; rep(i, 0, m) { cin >> k[i]; rep(j, 0, k[i]) { ll a; cin >> a; v[i].pb(a - 1); } } rep(i, 0, m) cin >> p[i]; ll ans = 0; rep(i, 1, (ll)pow(2, n)) { ll cnt = 0; rep(j, 0, m) { if (check(i, v[j], j) == true) cnt++; } if (cnt == m) ans++; } cout << ans; } return 0; }
#include <bits/stdc++.h> #define ll long long #define ra return a; #define pb push_back #define sti stack<ll> #define spi stack<pair<ll, ll>> #define S second #define msi map<string, ll> #define msi map<string, ll> #define mii map<ll, ll> #define dbg(x) \ { cerr << #x << ": " << x << endl; } #define dbg2(x, y) \ { cerr << #x << ": " << x << " , " << #y << ": " << y << endl; } #define dbg3(x, y, z) \ { \ cerr << #x << ": " << x << " , " << #y << ": " << y << " , " << #z << ": " \ << z << endl; \ } #define mis map<ll, string> #define rep(i, a, b) for (ll i = a; i < b; i++) #define mpi map<pair<ll, ll>, ll> #define pii pair<ll, ll> #define ppb pop_back #define F first #define vi vector<ll> #define vii vector<pair<ll, ll>> #define si set<ll> #define vs vector<string> #define all(a) (a).begin(), (a).end() #define sz(x) (ll) x.size() #define hell 1000000007 #define bs binary_search #define mp make_pair #define qi queue<ll> #define qs queue<string> #define qpi queue<pair<ll, ll>> #define qps queue<pair<ll, string>> #define endl '\n' #define itr(a, it) \ for (typeof(a.begin()) it = a.begin(); it != a.end(); \ it++) // This will produce const_iterator for const object and normal // iterator for non-const object #define ss set<string> using namespace std; #define N 11 ll p[N]; bool check(ll a, vi b, ll c) { ll cnt = 0; for (auto i : b) { if (a & (1 << i)) cnt++; } if (cnt % 2 == p[c]) return true; else return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; // cin>>t; while (t--) { ll n, m; cin >> n >> m; ll k[m]; vi v[m]; rep(i, 0, m) { cin >> k[i]; rep(j, 0, k[i]) { ll a; cin >> a; v[i].pb(a - 1); } } rep(i, 0, m) cin >> p[i]; ll ans = 0; rep(i, 0, (ll)pow(2, n)) { ll cnt = 0; rep(j, 0, m) { if (check(i, v[j], j) == true) cnt++; } if (cnt == m) ans++; } cout << ans; } return 0; }
[ "literal.number.change", "call.arguments.change" ]
841,958
841,959
u231573377
cpp
p03031
#include <iostream> using namespace std; int N, M; int bulb[11]; int p[11]; int countbit(int v) { unsigned int c; // c accumulates the total bits set in v for (c = 0; v; c++) v &= v - 1; // clear the least significant bit set return c; } int main() { 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; bulb[i] |= (1 << s); } } for (int i = 1; i <= M; i++) cin >> p[i]; int ans = 0; for (int i = 0; i <= (1 << (N + 1)); i += 2) { bool success = true; for (int j = 1; j <= M; j++) if (countbit(bulb[j] & i) % 2 != p[j]) success = false; ans += success; } cout << ans; }
#include <iostream> using namespace std; int N, M; int bulb[11]; int p[11]; int countbit(int v) { unsigned int c; // c accumulates the total bits set in v for (c = 0; v; c++) v &= v - 1; // clear the least significant bit set return c; } int main() { 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; bulb[i] |= (1 << s); } } for (int i = 1; i <= M; i++) cin >> p[i]; int ans = 0; for (int i = 0; i < (1 << (N + 1)); i += 2) { bool success = true; for (int j = 1; j <= M; j++) if (countbit(bulb[j] & i) % 2 != p[j]) success = false; ans += success; } cout << ans; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
841,979
841,980
u081249228
cpp
p03031
// wawando's template #include <algorithm> #include <cctype> #include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> //clock_t , clock() , CLOCKS_PER_SEC #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> // MACROS #define pb push_back #define mp make_pair #define INF 1000000000 // 1 billion safer for floyd warshall, avoid overflow using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; int main() { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); ios::sync_with_stdio(false); cin.tie(0); int N, M; vector<vi> bulbs; vi p; cin >> N >> M; bulbs.assign(N, vi()); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; bulbs[i].pb(s - 1); } } for (int i = 0; i < M; i++) { int pi; cin >> pi; p.pb(pi); } int ans = 0; for (int mask = 0; mask < (1 << N); mask++) { bool isOn = true; for (int i = 0; i < M; i++) { int onCount = 0; for (int j = 0; j < (int)bulbs[i].size(); j++) { if (mask & (1 << bulbs[i][j])) onCount++; } isOn &= (onCount % 2 == p[i]); } ans += (isOn ? 1 : 0); } cout << ans << endl; return 0; }
// wawando's template #include <algorithm> #include <cctype> #include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> //clock_t , clock() , CLOCKS_PER_SEC #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> // MACROS #define pb push_back #define mp make_pair #define INF 1000000000 // 1 billion safer for floyd warshall, avoid overflow using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; int main() { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); ios::sync_with_stdio(false); cin.tie(0); int N, M; vector<vi> bulbs; vi p; cin >> N >> M; bulbs.assign(M, vi()); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; bulbs[i].pb(s - 1); } } for (int i = 0; i < M; i++) { int pi; cin >> pi; p.pb(pi); } int ans = 0; for (int mask = 0; mask < (1 << N); mask++) { bool isOn = true; for (int i = 0; i < M; i++) { int onCount = 0; for (int j = 0; j < (int)bulbs[i].size(); j++) { if (mask & (1 << bulbs[i][j])) onCount++; } isOn &= (onCount % 2 == p[i]); } ans += (isOn ? 1 : 0); } cout << ans << endl; return 0; }
[ "identifier.change", "call.arguments.change" ]
841,985
841,986
u109770730
cpp
p03031
#include <bits/stdc++.h> #include <bitset> #include <iostream> #include <vector> using namespace std; using Int = long long; signed main() { Int n, m; cin >> n >> m; vector<vector<Int>> k_s; vector<Int> p; for (Int i = 0; i < m; i++) { Int tmp_k; cin >> tmp_k; vector<Int> tmp_vs; tmp_vs.push_back(tmp_k); for (Int j = 0; j < tmp_k; j++) { Int tmp_s; cin >> tmp_s; tmp_vs.push_back(tmp_s); } k_s.push_back(tmp_vs); } for (Int i = 0; i < m; i++) { Int tmp_p; cin >> tmp_p; p.push_back(tmp_p); } Int ans = 0; for (Int i = 0; i < n * n; i++) { bitset<10> switches = static_cast<bitset<10>>(i); bool light_on = true; for (Int j = 0; j < m; j++) { Int tmp = 0; for (Int k = 1; k <= k_s[j][0]; k++) { if (switches[k_s[j][k] - 1]) tmp += 1; } if (tmp % 2 != p[j]) { light_on = false; break; } } if (light_on) ans += 1; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #include <bitset> #include <iostream> #include <vector> using namespace std; using Int = long long; signed main() { Int n, m; cin >> n >> m; vector<vector<Int>> k_s; vector<Int> p; for (Int i = 0; i < m; i++) { Int tmp_k; cin >> tmp_k; vector<Int> tmp_vs; tmp_vs.push_back(tmp_k); for (Int j = 0; j < tmp_k; j++) { Int tmp_s; cin >> tmp_s; tmp_vs.push_back(tmp_s); } k_s.push_back(tmp_vs); } for (Int i = 0; i < m; i++) { Int tmp_p; cin >> tmp_p; p.push_back(tmp_p); } Int ans = 0; for (Int i = 0; i < pow(2, n); i++) { bitset<10> switches = static_cast<bitset<10>>(i); bool light_on = true; for (Int j = 0; j < m; j++) { Int tmp = 0; for (Int k = 1; k <= k_s[j][0]; k++) { if (switches[k_s[j][k] - 1]) tmp += 1; } if (tmp % 2 != p[j]) { light_on = false; break; } } if (light_on) ans += 1; } cout << ans << endl; return 0; }
[ "control_flow.loop.for.condition.change", "call.arguments.add", "call.arguments.change" ]
841,987
841,988
u148215098
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int k; int s; std::vector<int> mask(M, 0); std::vector<int> p(M); for (int i = 0; i < M; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> s; mask.at(i) |= (1 << s); } } for (int i = 0; i < M; i++) { cin >> p.at(i); } int jogen = pow(2, N); int count = 0; for (int i = 1; i < jogen; i++) { bool flag = true; for (int j = 0; j < M; j++) { int light = __builtin_popcount((i << 1) & mask.at(j)); if (light % 2 != p.at(j)) { flag = false; break; } // // cout << endl; // cout << bitset<8>(i<<1) << endl; // cout << bitset<8>(m) << endl; // cout << bitset<8>(light) << endl; } count += flag; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int k; int s; std::vector<int> mask(M, 0); std::vector<int> p(M); for (int i = 0; i < M; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> s; mask.at(i) |= (1 << s); } } for (int i = 0; i < M; i++) { cin >> p.at(i); } int jogen = pow(2, N); int count = 0; for (int i = 0; i < jogen; i++) { bool flag = true; for (int j = 0; j < M; j++) { int light = __builtin_popcount((i << 1) & mask.at(j)); if (light % 2 != p.at(j)) { flag = false; break; } // cout << endl; // cout << bitset<8>(i<<1) << endl; // cout << bitset<8>(mask.at(j)) << endl; // cout << bitset<8>(mask.at(j) & (i<<1)) << endl; // cout << p.at(j) << endl; } count += flag; } cout << count << endl; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
841,989
841,990
u578276786
cpp
p03031
#include <iostream> #include <vector> int main() { int N, M; std::cin >> N >> M; std::vector<std::vector<int>> sij(M); std::vector<int> p(M); for (int i = 0; i < M; ++i) { int k, s; std::cin >> k; sij[i].reserve(k); for (int j = 0; j < k; ++j) { std::cin >> s; sij[i].push_back(s - 1); } } for (int i = 0; i < M; ++i) { std::cin >> p[i]; } int result = 0; for (int sw = 0, end = 2 << (N - 1); sw <= end; ++sw) { bool ok = true; for (int i = 0; i < sij.size(); ++i) { auto &sj = sij[i]; int sum = 0; for (auto s : sj) { sum += sw >> s; } if ((sum % 2) != p[i]) { ok = false; break; } } if (ok) { ++result; } } std::cout << result << std::endl; return 0; }
#include <iostream> #include <vector> int main() { int N, M; std::cin >> N >> M; std::vector<std::vector<int>> sij(M); std::vector<int> p(M); for (int i = 0; i < M; ++i) { int k, s; std::cin >> k; sij[i].reserve(k); for (int j = 0; j < k; ++j) { std::cin >> s; sij[i].push_back(s - 1); } } for (int i = 0; i < M; ++i) { std::cin >> p[i]; } int result = 0; for (int sw = 0, end = 1 << N; sw < end; ++sw) { bool ok = true; for (int i = 0; i < sij.size(); ++i) { auto &sj = sij[i]; int sum = 0; for (auto s : sj) { sum += sw >> s; } if ((sum % 2) != p[i]) { ok = false; break; } } if (ok) { ++result; } } std::cout << result << std::endl; return 0; }
[ "control_flow.loop.for.initializer.change", "expression.operation.binary.remove", "expression.operation.binary.change", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one" ]
841,993
841,994
u477096296
cpp
p03031
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int s[100][100]; int main() { int n, m; ll ans = 0; cin >> n >> m; int k[m]; rep(i, m) { cin >> k[i]; rep(j, k[i]) { cin >> s[i][j]; s[i][j]--; } } int p[m]; rep(i, m) cin >> p[i]; for (int bit = 0; bit < (1 << n); ++bit) { int on[m] = {}; for (int i = 0; i < n; ++i) { if (bit & (1 << i)) { // i が bit に入るかどうか on[i]++; } } bool ok = true; rep(i, m) { int cnt = 0; rep(l, k[i]) { if (on[s[i][l]] > 0) cnt++; } if (cnt % 2 != p[i]) ok = false; } if (ok) { ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int s[100][100]; int main() { int n, m; ll ans = 0; cin >> n >> m; int k[m]; rep(i, m) { cin >> k[i]; rep(j, k[i]) { cin >> s[i][j]; s[i][j]--; } } int p[m]; rep(i, m) cin >> p[i]; for (int bit = 0; bit < (1 << n); ++bit) { int on[n] = {}; for (int i = 0; i < n; ++i) { if (bit & (1 << i)) { // i が bit に入るかどうか on[i]++; } } bool ok = true; rep(i, m) { int cnt = 0; rep(l, k[i]) { if (on[s[i][l]] > 0) cnt++; } if (cnt % 2 != p[i]) ok = false; } if (ok) { ans++; } } cout << ans << endl; return 0; }
[ "identifier.change", "variable_declaration.array_dimensions.change" ]
841,999
842,000
u906208439
cpp
p03031
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int s[100][100]; int main() { int n, m; ll ans = 0; cin >> n >> m; int k[m]; rep(i, m) { cin >> k[i]; rep(j, k[i]) { cin >> s[i][j]; s[i][j]--; } } int p[m]; rep(i, m) cin >> p[i]; for (int bit = 0; bit < (1 << m); ++bit) { int on[m] = {}; for (int i = 0; i < m; ++i) { if (bit & (1 << i)) { // i が bit に入るかどうか on[i]++; } } bool ok = true; rep(i, m) { int cnt = 0; rep(l, k[i]) { if (on[s[i][l]] > 0) cnt++; } if (cnt % 2 != p[i]) ok = false; } if (ok) { ans++; } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define REP(i, m, n) for (int i = (int)m; i < (int)n; ++i) #define rep(i, n) REP(i, 0, n) typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, int> pli; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; int s[100][100]; int main() { int n, m; ll ans = 0; cin >> n >> m; int k[m]; rep(i, m) { cin >> k[i]; rep(j, k[i]) { cin >> s[i][j]; s[i][j]--; } } int p[m]; rep(i, m) cin >> p[i]; for (int bit = 0; bit < (1 << n); ++bit) { int on[n] = {}; for (int i = 0; i < n; ++i) { if (bit & (1 << i)) { // i が bit に入るかどうか on[i]++; } } bool ok = true; rep(i, m) { int cnt = 0; rep(l, k[i]) { if (on[s[i][l]] > 0) cnt++; } if (cnt % 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", "variable_declaration.array_dimensions.change" ]
842,001
842,000
u906208439
cpp
p03031
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; int main() { int N, M; cin >> N >> M; bool a[M][N]; rep(i, M) rep(j, N) a[i][j] = false; rep(i, M) { int k; cin >> k; rep(i, k) { int x; cin >> x; x--; a[i][x] = true; } } int b[M]; rep(i, M) { cin >> b[i]; } int ans = 0; rep(i, (1 << N)) { bool f = true; rep(j, M) { int cnt = 0; rep(k, N) { if ((i >> k) & 1 == 1) if (a[j][k] == true) cnt++; } if (cnt % 2 != b[j]) f = false; } if (f) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; int main() { int N, M; cin >> N >> M; bool a[M][N]; rep(i, M) rep(j, N) a[i][j] = false; rep(i, M) { int k; cin >> k; rep(j, k) { int x; cin >> x; x--; a[i][x] = true; } } int b[M]; rep(i, M) { cin >> b[i]; } int ans = 0; rep(i, (1 << N)) { bool f = true; rep(j, M) { int cnt = 0; rep(k, N) { if ((i >> k) & 1 == 1) if (a[j][k] == true) cnt++; } if (cnt % 2 != b[j]) f = false; } if (f) ans++; } cout << ans << endl; return 0; }
[]
842,002
842,003
u944316525
cpp
p03031
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int n, m, k[11], s[11][11], p[11], sum = 0; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> k[i]; for (int j = 1; j <= k[i]; j++) { cin >> s[i][j]; } } for (int i = 1; i <= m; i++) { cin >> p[i]; } for (int i = 0; i < (1 << m); i++) { int t = 0; for (int j = 1; j <= m; j++) { int count = 0; for (int k = 1; k <= m; k++) { if (i & (1 << (s[j][k] - 1))) count++; } if (count % 2 == p[j]) t++; else break; } if (t == m) sum++; } cout << sum; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int n, m, k[20], s[20][20], p[20], sum = 0; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> k[i]; for (int j = 1; j <= k[i]; j++) { cin >> s[i][j]; } } for (int i = 1; i <= m; i++) { cin >> p[i]; } for (int i = 0; i < (1 << n); i++) { int t = 0; for (int j = 1; j <= m; j++) { int count = 0; for (int k = 1; k <= n; k++) { if (i & (1 << (s[j][k] - 1))) count++; } if (count % 2 == p[j]) t++; else break; } if (t == m) sum++; } cout << sum; return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
842,008
842,009
u064722905
cpp
p03031
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int n, m, k[11], s[11][11], p[11], sum = 0; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> k[i]; for (int j = 1; j <= k[i]; j++) { cin >> s[i][j]; } } for (int i = 1; i <= m; i++) { cin >> p[i]; } for (int i = 0; i < (1 << m); i++) { int t = 0; for (int j = 1; j <= m; j++) { int count = 0; for (int k = 1; k <= m; k++) { if (i & (1 << (s[j][k] - 1))) count++; } if (count % 2 == p[j]) t++; else break; } if (t == m) sum++; } cout << sum; return 0; }
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int n, m, k[20], s[20][20], p[20], sum = 0; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> k[i]; for (int j = 1; j <= k[i]; j++) { cin >> s[i][j]; } } for (int i = 1; i <= m; i++) { cin >> p[i]; } for (int i = 0; i < (1 << n); i++) { int t = 0; for (int j = 1; j <= m; j++) { int count = 0; for (int k = 1; k <= m; k++) { if (i & (1 << (s[j][k] - 1))) count++; } if (count % 2 == p[j]) t++; else break; } if (t == m) sum++; } cout << sum; return 0; }
[ "literal.number.change", "variable_declaration.array_dimensions.change", "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
842,008
842,010
u064722905
cpp
p03031
#include <bits/stdc++.h> #include <cmath> #define MAX(a, b) (a > b ? a : b) #define MIN(a, b) (a > b ? b : a) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (lint i = (lint)(n); i > 0; --i) #define reps(i, a, b) for (lint i = a; i <= (lint)(b); i++) typedef long long lint; typedef long double ld; using namespace std; const ld PI = acos(-1.0); const lint MOD = 1000000007; int main() { int N, M; cin >> N >> M; vector<int> k(M), p(M); vector<vector<int>> s; s = vector<vector<int>>(M, vector<int>(N, 0)); rep(i, M) { cin >> k[i]; rep(j, k[i]) cin >> s[i][j]; } rep(i, M) cin >> p[i]; int cnt = 0; bool chk = true; reps(i, 1, pow(2, N) - 1) { rep(j, M) { int sum = 0; rep(l, k[j]) { sum += (i / (int)(pow(2, s[j][l] - 1))) - (i / (int)(pow(2, s[j][l]))) * 2; } if (sum % 2 != p[j]) { chk = false; break; } } if (chk) cnt++; chk = true; } cout << cnt << endl; return 0; }
#include <bits/stdc++.h> #include <cmath> #define MAX(a, b) (a > b ? a : b) #define MIN(a, b) (a > b ? b : a) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, n) for (lint i = (lint)(n); i > 0; --i) #define reps(i, a, b) for (lint i = a; i <= (lint)(b); i++) typedef long long lint; typedef long double ld; using namespace std; const ld PI = acos(-1.0); const lint MOD = 1000000007; int main() { int N, M; cin >> N >> M; vector<int> k(M), p(M); vector<vector<int>> s; s = vector<vector<int>>(M, vector<int>(N, 0)); rep(i, M) { cin >> k[i]; rep(j, k[i]) cin >> s[i][j]; } rep(i, M) cin >> p[i]; int cnt = 0; bool chk = true; reps(i, 0, pow(2, N) - 1) { rep(j, M) { int sum = 0; rep(l, k[j]) { sum += (i / (int)(pow(2, s[j][l] - 1))) - (i / (int)(pow(2, s[j][l]))) * 2; } if (sum % 2 != p[j]) { chk = false; break; } } if (chk) cnt++; chk = true; } cout << cnt << endl; return 0; }
[ "literal.number.change", "call.arguments.change" ]
842,036
842,037
u365694286
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, k, kazu, kari, amari, max = 1, gomi, hantei, kotae, ans = 0; cin >> n >> m; int a[m][n], p[m]; for (i = 0; i < n; i++) { max *= 2; } for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { a[i][j] = 0; } } for (i = 0; i < m; i++) { cin >> gomi; for (j = 0; j < gomi; j++) { cin >> k; a[i][k] = 1; } } for (i = 0; i < m; i++) { cin >> p[i]; } for (kazu = 0; kazu < max; kazu++) { kotae = 1; for (i = 0; i < m; i++) { hantei = 0; kari = kazu; for (j = n - 1; j >= 0; j--) { amari = kari % 2; kari /= 2; if (a[i][j] == 1 && amari == 1) { hantei++; } } if (hantei % 2 != p[i]) { kotae *= 0; } } ans += kotae; } cout << ans; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, k, kazu, kari, amari, max = 1, gomi, hantei, kotae, ans = 0; cin >> n >> m; int a[m][n], p[m]; for (i = 0; i < n; i++) { max *= 2; } for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { a[i][j] = 0; } } for (i = 0; i < m; i++) { cin >> gomi; for (j = 0; j < gomi; j++) { cin >> k; a[i][k - 1] = 1; } } for (i = 0; i < m; i++) { cin >> p[i]; } for (kazu = 0; kazu < max; kazu++) { kotae = 1; for (i = 0; i < m; i++) { hantei = 0; kari = kazu; for (j = n - 1; j >= 0; j--) { amari = kari % 2; kari /= 2; if (a[i][j] == 1 && amari == 1) { hantei++; } } if (hantei % 2 != p[i]) { kotae *= 0; } } ans += kotae; } cout << ans; }
[ "assignment.change" ]
842,043
842,044
u016726316
cpp
p03031
#include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> K(M); vector<int> S(10000000, 0); for (int i = 0; i < M; i++) { cin >> K[i]; // cout << K[i] << " "; for (int j = M * i; j < M * i + K[i]; j++) { cin >> S[j]; // cout << S[j] << " "; } // cout << endl; } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } int ans = 0; for (int i = 1; i < (1 << N); i++) { bool flag = true; for (int j = 0; j < M; j++) { int cnt = 0; for (int k = M * j; k < M * j + K[j]; k++) { if ((1 << (S[k] - 1)) & i) cnt++; } if (cnt % 2 != p[j]) { flag = false; break; } } if (flag) ans++; } cout << ans << endl; }
#include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> K(M); vector<int> S(M * N + 10, 0); for (int i = 0; i < M; i++) { cin >> K[i]; for (int j = M * i; j < M * i + K[i]; j++) { cin >> S[j]; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } int ans = 0; for (int i = 1; i <= (1 << N); i++) { bool flag = true; for (int j = 0; j < M; j++) { int cnt = 0; for (int k = M * j; k < M * j + K[j]; k++) { if ((1 << (S[k] - 1)) & i) cnt++; } if (cnt % 2 != p[j]) { flag = false; break; } } if (flag) ans++; } cout << ans << endl; }
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,047
842,048
u190018920
cpp
p03031
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF = (long long)1E17; #define i_7 (long long)(1E9 + 7) long mod(long a) { long long c = a % i_7; if (c >= 0) return c; return c + i_7; } using namespace std; bool prime(int n) { if (n == 1) { return false; } else if (n == 2) { return true; } else { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } } long long gcd(long long a, long long b) { if (a < b) { swap(a, b); } if (a % b == 0) { return b; } else { return gcd(b, a % b); } } long long lcm(long long x, long long y) { return (x / gcd(x, y)) * y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)]; //先祖をrootで取っておきたい。 } // AとBをくっ付ける bool connect(int A, int B) { // AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); // Aのサイズを更新する Parent[A] += Parent[B]; // Bの親をAに変更する Parent[B] = A; return true; } }; int main() { int n, m; cin >> n >> m; int k[m]; vector<vector<int>> s; int ts; int p[m]; REP(i, m) { cin >> k[i]; REP(j, k[i]) { cin >> ts; ts--; s[i].push_back(ts); } } REP(i, m) { cin >> p[i]; } int ans = 0; int cnt = 0; bool flag = true; for (int i = 0; i < (1 << 10); i++) { //スイッチのon/offを全通り試す。 REP(j, m) { //ある電球がonかどうかを確かめる。 for (int r = 0; r < k[j]; r++) { //電球jにつながっているスイッチでonになっているものを数える。 if (i >> s[j][r] & 1) { cnt++; } } if (cnt % 2 == p[j]) { //電球jが点灯している場合 cnt = 0; continue; } else { cnt = 0; flag = false; break; } } if (flag) { ans++; } else { flag = true; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF = (long long)1E17; #define i_7 (long long)(1E9 + 7) long mod(long a) { long long c = a % i_7; if (c >= 0) return c; return c + i_7; } using namespace std; bool prime(int n) { if (n == 1) { return false; } else if (n == 2) { return true; } else { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { return false; } } return true; } } long long gcd(long long a, long long b) { if (a < b) { swap(a, b); } if (a % b == 0) { return b; } else { return gcd(b, a % b); } } long long lcm(long long x, long long y) { return (x / gcd(x, y)) * y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } // Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)]; //先祖をrootで取っておきたい。 } // AとBをくっ付ける bool connect(int A, int B) { // AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); // Aのサイズを更新する Parent[A] += Parent[B]; // Bの親をAに変更する Parent[B] = A; return true; } }; int main() { int n, m; cin >> n >> m; int k[m]; vector<vector<int>> s(m); int ts; int p[m]; REP(i, m) { cin >> k[i]; REP(j, k[i]) { cin >> ts; ts--; s[i].push_back(ts); } } REP(i, m) { cin >> p[i]; } int ans = 0; int cnt = 0; bool flag = true; for (int i = 0; i < (1 << n); i++) { //スイッチのon/offを全通り試す。 REP(j, m) { //ある電球がonかどうかを確かめる。 for (int r = 0; r < k[j]; r++) { //電球jにつながっているスイッチでonになっているものを数える。 if (i >> s[j][r] & 1) { cnt++; } } if (cnt % 2 == p[j]) { //電球jが点灯している場合 cnt = 0; continue; } else { cnt = 0; flag = false; break; } } if (flag) { ans++; } else { flag = true; } } cout << ans << endl; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
842,049
842,050
u222293734
cpp
p03031
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <deque> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <vector> using namespace std; #define mp make_pair #define pb push_back #define ll long long int #define db double #define ldb long double #define MOD 1000000007 #define Fi first #define Se second #define INF INT_MAX #define NINF INT_MIN #define L_INF LLONG_MAX #define L_NINF LLONG_MIN #define gc getchar #define sz(x) (int)(x).size() #define pii pair<int, int> #define pll pair<ll, ll> void fsscan() { ios_base::sync_with_stdio(false); cin.tie(NULL); } void scani(int &x) { register int c = gc(); x = 0; int neg = 0; for (; ((c < 48 || c > 57) && c != '-'); c = gc()) ; if (c == '-') { neg = 1; c = gc(); } for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; } if (neg) x = -x; } ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } vector<int> decToBinary(int n, int l) { vector<int> v(l, 0); int i = 0; while (n > 0) { v[i] = (n % 2); n = n / 2; i++; } reverse(v.begin(), v.end()); return v; } int main() { fsscan(); int n, m; cin >> n >> m; vector<int> bulbs[m]; for (int i = 0; i < m; i++) { int s; cin >> s; while (s--) { int x; cin >> x; bulbs[i].pb(x); } } int p[m]; for (int i = 0; i < m; i++) { cin >> p[i]; } int s = 0; for (int i = 0; i <= pow(2, n); i++) { vector<int> v = decToBinary(i, n); int c = 0; for (int j = 0; j < m; j++) { int count = 0; for (int k = 0; k < bulbs[j].size(); k++) { int index_val = bulbs[j][k]; count += v[index_val - 1]; } if (count % 2 == p[j]) c++; } if (c == m) s++; } cout << s; return 0; }
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <deque> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <vector> using namespace std; #define mp make_pair #define pb push_back #define ll long long int #define db double #define ldb long double #define MOD 1000000007 #define Fi first #define Se second #define INF INT_MAX #define NINF INT_MIN #define L_INF LLONG_MAX #define L_NINF LLONG_MIN #define gc getchar #define sz(x) (int)(x).size() #define pii pair<int, int> #define pll pair<ll, ll> void fsscan() { ios_base::sync_with_stdio(false); cin.tie(NULL); } void scani(int &x) { register int c = gc(); x = 0; int neg = 0; for (; ((c < 48 || c > 57) && c != '-'); c = gc()) ; if (c == '-') { neg = 1; c = gc(); } for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; } if (neg) x = -x; } ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } vector<int> decToBinary(int n, int l) { vector<int> v(l, 0); int i = 0; while (n > 0) { v[i] = (n % 2); n = n / 2; i++; } reverse(v.begin(), v.end()); return v; } int main() { fsscan(); int n, m; cin >> n >> m; vector<int> bulbs[m]; for (int i = 0; i < m; i++) { int s; cin >> s; while (s--) { int x; cin >> x; bulbs[i].pb(x); } } int p[m]; for (int i = 0; i < m; i++) { cin >> p[i]; } int s = 0; for (int i = 0; i < pow(2, n); i++) { vector<int> v = decToBinary(i, n); int c = 0; for (int j = 0; j < m; j++) { int count = 0; for (int k = 0; k < bulbs[j].size(); k++) { int index_val = bulbs[j][k]; count += v[index_val - 1]; } if (count % 2 == p[j]) c++; } // cout<<i<<" "<<c<<endl; if (c == m) s++; } cout << s; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,058
842,059
u194463155
cpp
p03031
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define MP make_pair #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORR(x, arr) for (auto &x : arr) #define VI vector<int> #define PII pair<int, int> #define FI first #define SE second #define ALL(x) (x).begin(), (x).end() const int INF = 1 << 30; const ll LINF = 1LL << 60; const ll MOD = 1e9 + 7; 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; } //------------------- bool rel[30][30]; int p[30]; int onoff[30]; int n, m; bool judge() { // bool ret = true; FOR(i, 1, m) { // bool ok = true; int now = 0; FOR(j, 1, n) { if (rel[i][j] == true) { now += onoff[j]; } } if (now % 2 != p[i]) { return false; } } return true; } int main() { cin >> n >> m; FOR(i, 1, m) { int k; cin >> k; FOR(j, 1, k) { int s; cin >> s; rel[i][s] = true; } } FOR(i, 1, m) { cin >> p[i]; } int ret = 0; FOR(i, 0, (1 << n)) { int cur = (i << 1); FOR(j, 1, n) { if (cur & (1 << j)) { onoff[j] = 1; } else { onoff[j] = 0; } } if (judge() == true) { ret += 1; } } cout << ret << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; #define MP make_pair #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FORR(x, arr) for (auto &x : arr) #define VI vector<int> #define PII pair<int, int> #define FI first #define SE second #define ALL(x) (x).begin(), (x).end() const int INF = 1 << 30; const ll LINF = 1LL << 60; const ll MOD = 1e9 + 7; 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; } //------------------- bool rel[30][30]; int p[30]; int onoff[30]; int n, m; bool judge() { // bool ret = true; FOR(i, 1, m) { int now = 0; FOR(j, 1, n) { if (rel[i][j] == true) { now += onoff[j]; } } if (now % 2 != p[i]) { return false; } } return true; } int main() { cin >> n >> m; FOR(i, 1, m) { int k; cin >> k; FOR(j, 1, k) { int s; cin >> s; rel[i][s] = true; } } FOR(i, 1, m) { cin >> p[i]; } int ret = 0; FOR(i, 0, (1 << n) - 1) { int cur = (i << 1); FOR(j, 1, n) { if (cur & (1 << j)) { onoff[j] = 1; } else { onoff[j] = 0; } } if (judge() == true) { ret += 1; } } cout << ret << endl; return 0; }
[ "expression.operation.binary.add" ]
842,062
842,063
u297590902
cpp
p03031
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 5, mod = 1e9 + 7; vector<int> vi[15]; int a[15], p[15]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, k, x; cin >> n >> m; for (int i = 1; i <= m; ++i) { cin >> k; while (k--) { cin >> x; vi[i].push_back(x); } } for (int i = 1; i <= m; ++i) cin >> p[i]; int ans = 0; for (int i = 1; i < (1 << n); ++i) { int pos = 1, t = i; while (t) { if (t & 1) { a[pos] = 1; } else a[pos] = 0; ++pos; t >>= 1; } bool exist = 0; for (int i = 1; i <= m; ++i) { int cnt = 0; for (int j = 0; j < vi[i].size(); ++j) { if (a[vi[i][j]]) ++cnt; } if (cnt % 2 != p[i]) { exist = 1; break; } } if (!exist) ++ans; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 5, mod = 1e9 + 7; vector<int> vi[15]; int a[15], p[15]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, k, x; cin >> n >> m; for (int i = 1; i <= m; ++i) { cin >> k; while (k--) { cin >> x; vi[i].push_back(x); } } for (int i = 1; i <= m; ++i) cin >> p[i]; int ans = 0; for (int i = 0; i < (1 << n); ++i) { int pos = 1, t = i; while (t) { if (t & 1) { a[pos] = 1; } else a[pos] = 0; ++pos; t >>= 1; } bool exist = 0; for (int i = 1; i <= m; ++i) { int cnt = 0; for (int j = 0; j < vi[i].size(); ++j) { if (a[vi[i][j]]) ++cnt; } if (cnt % 2 != p[i]) { exist = 1; break; } } if (!exist) ++ans; } cout << ans << endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
842,066
842,067
u187582424
cpp
p03031
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define ull unsigned long long #define up(i, a, b) for (int i = (a); i <= (b); i++) #define down(i, a, b) for (int i = (a); i >= (b); i--) #define mem(x, y) memset(x, (y), sizeof x) #define ff first #define ss second #define mp(x, y) make_pair(x, y) #define pb(x) push_back(x) #define sc(a) scanf("%d", &a) #define scl(a) scanf("%lld", &a) #define scs(a) scanf("%s", a) #define pr(a, b) printf("%d%c", a, b) #define prl(a, b) printf("%lld%c", a, b) #define PQ priority_queue #define ld long double #define all(v) v.begin(), v.end() #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) typedef pair<int, int> pii; typedef map<int, int> mii; typedef vector<int> V; int a[20][20], pp[20]; int main() { IOS; int n, m, ans = 0; cin >> n >> m; up(i, 1, m) { cin >> a[i][0]; up(o, 1, a[i][0]) cin >> a[i][o]; } up(i, 1, m) cin >> pp[i]; up(i, 1, (1 << n) - 1) { int cmp = i, cur[20], cnt = 0; up(o, 1, 10) cur[o] = 0; while (cmp) cur[++cnt] = cmp & 1, cmp >>= 1; int light[20]; up(o, 1, 10) light[o] = 0; up(o, 1, m) up(p, 1, a[o][0]) light[o] += cur[a[o][p]]; int gg = 0; up(o, 1, m) if ((light[o] % 2) != pp[o]) { gg++; break; } if (!gg) ans++; } cout << ans << "\n"; }
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define ull unsigned long long #define up(i, a, b) for (int i = (a); i <= (b); i++) #define down(i, a, b) for (int i = (a); i >= (b); i--) #define mem(x, y) memset(x, (y), sizeof x) #define ff first #define ss second #define mp(x, y) make_pair(x, y) #define pb(x) push_back(x) #define sc(a) scanf("%d", &a) #define scl(a) scanf("%lld", &a) #define scs(a) scanf("%s", a) #define pr(a, b) printf("%d%c", a, b) #define prl(a, b) printf("%lld%c", a, b) #define PQ priority_queue #define ld long double #define all(v) v.begin(), v.end() #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) typedef pair<int, int> pii; typedef map<int, int> mii; typedef vector<int> V; int a[20][20], pp[20]; int main() { IOS; int n, m, ans = 0; cin >> n >> m; up(i, 1, m) { cin >> a[i][0]; up(o, 1, a[i][0]) cin >> a[i][o]; } up(i, 1, m) cin >> pp[i]; up(i, 0, (1 << n) - 1) { int cmp = i, cur[20], cnt = 0; up(o, 1, 10) cur[o] = 0; while (cmp) cur[++cnt] = cmp & 1, cmp >>= 1; int light[20]; up(o, 1, 10) light[o] = 0; up(o, 1, m) up(p, 1, a[o][0]) light[o] += cur[a[o][p]]; int gg = 0; up(o, 1, m) if ((light[o] % 2) != pp[o]) { gg++; break; } if (!gg) ans++; } cout << ans << "\n"; }
[ "literal.number.change", "call.arguments.change" ]
842,069
842,070
u084557456
cpp
p03031
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using std::cerr; using std::cin; using std::cout; using std::endl; int main(void) { cout << std::fixed << std::setprecision(10); cin.tie(0); std::ios::sync_with_stdio(false); int n, m; cin >> n >> m; std::vector<int> bulb[10]; std::vector<int> mod; for (int i = 0; i < m; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; bulb[i].push_back(s); } } for (int i = 0; i < m; i++) { int p; cin >> p; mod.push_back(i); } int result = 0; for (int state = 0; state < (1 << n); state++) { bool all_on = true; for (int i = 0; i < m; i++) { std::vector<int> tgt_bulb = bulb[i]; int on_count = 0; for (auto x : tgt_bulb) { int mask = 1 << (x - 1); if (mask & state) { on_count++; } } if (on_count % 2 != mod[i]) { all_on = false; break; } } if (all_on) { result++; } } cout << result << endl; return 0; }
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using std::cerr; using std::cin; using std::cout; using std::endl; int main(void) { cout << std::fixed << std::setprecision(10); cin.tie(0); std::ios::sync_with_stdio(false); int n, m; cin >> n >> m; std::vector<int> bulb[10]; std::vector<int> mod; for (int i = 0; i < m; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; bulb[i].push_back(s); } } for (int i = 0; i < m; i++) { int p; cin >> p; mod.push_back(p); } int result = 0; for (int state = 0; state < (1 << n); state++) { bool all_on = true; for (int i = 0; i < m; i++) { std::vector<int> tgt_bulb = bulb[i]; int on_count = 0; for (auto x : tgt_bulb) { int mask = 1 << (x - 1); if (mask & state) { on_count++; } } if (on_count % 2 != mod[i]) { all_on = false; break; } } if (all_on) { result++; } } cout << result << endl; return 0; }
[ "identifier.change", "call.arguments.change" ]
842,075
842,076
u844133200
cpp
p03031
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> II; typedef vector<II> VII; typedef vector<int> VI; typedef vector<VI> VVI; typedef long long int LL; #define PB push_back #define MP make_pair #define F first #define S second #define SZ(a) (int)(a.size()) #define ALL(a) a.begin(), a.end() #define SET(a, b) memset(a, b, sizeof(a)) #define si(n) scanf("%d", &n) #define dout(n) printf("%d\n", n) #define sll(n) scanf("%lld", &n) #define lldout(n) printf("%lld\n", n) #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) #endif #define fast_io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define endl '\n' constexpr int N = 11; int mask[N], p[N]; int main() { fast_io; int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { int k; cin >> k; for (int i = 0; i < k; i++) { int a; cin >> a; a -= 1; mask[i] |= 1 << a; } } for (int i = 0; i < m; i++) { cin >> p[i]; } int ans = 0; for (int i = 0; i < (1 << n); ++i) { int cnt = 0; for (int j = 0; j < m; j++) { int msk = (mask[j] & i); int n_on = __builtin_popcount(msk); if ((n_on & 1) == p[j]) cnt++; } if (cnt == m) { ans++; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> II; typedef vector<II> VII; typedef vector<int> VI; typedef vector<VI> VVI; typedef long long int LL; #define PB push_back #define MP make_pair #define F first #define S second #define SZ(a) (int)(a.size()) #define ALL(a) a.begin(), a.end() #define SET(a, b) memset(a, b, sizeof(a)) #define si(n) scanf("%d", &n) #define dout(n) printf("%d\n", n) #define sll(n) scanf("%lld", &n) #define lldout(n) printf("%lld\n", n) #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) #endif #define fast_io \ ios_base::sync_with_stdio(false); \ cin.tie(NULL) #define endl '\n' constexpr int N = 11; int mask[N], p[N]; int main() { fast_io; 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 a; cin >> a; a -= 1; mask[i] |= 1 << a; } } for (int i = 0; i < m; i++) { cin >> p[i]; } int ans = 0; for (int i = 0; i < (1 << n); ++i) { int cnt = 0; for (int j = 0; j < m; j++) { int msk = (mask[j] & i); int n_on = __builtin_popcount(msk); if ((n_on & 1) == p[j]) cnt++; } if (cnt == m) { 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" ]
842,090
842,091
u665172861
cpp
p03031
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <deque> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <algorithm> using namespace std; int main(int argc, char *argv[]) { int n, m; cin >> n >> m; vector<vector<int>> vv; for (int i = 0; i < m; i++) { vector<int> v; int k; cin >> k; for (int j = 0; j < k; j++) { int t; cin >> t; v.push_back(t); } vv.push_back(v); } vector<int> b; for (int i = 0; i < m; i++) { int t; cin >> t; b.push_back(t); } int res = 0; for (int i = 0; i < pow(2, n); i++) { vector<int> sw(n, 0); int ii = i; int index = 0; while (ii > 0) { sw[index++] = ii % 2; ii /= 2; } int flag = 1; for (int j = 0; j < m; j++) { int c = 0; for (int k = 0; k < vv[j].size(); k++) { if (sw[vv[j][k]] == 1) { c = 1 - c; } } if (c != b[j]) flag = 0; if (flag == 0) break; } res += flag; } cout << res << endl; }
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <deque> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <algorithm> using namespace std; int main(int argc, char *argv[]) { int n, m; cin >> n >> m; vector<vector<int>> vv; for (int i = 0; i < m; i++) { vector<int> v; int k; cin >> k; for (int j = 0; j < k; j++) { int t; cin >> t; v.push_back(t - 1); } vv.push_back(v); } vector<int> b; for (int i = 0; i < m; i++) { int t; cin >> t; b.push_back(t); } int res = 0; for (int i = 0; i < pow(2, n); i++) { vector<int> sw(n, 0); int ii = i; int index = 0; while (ii > 0) { sw[index++] = ii % 2; ii /= 2; } int flag = 1; for (int j = 0; j < m; j++) { int c = 0; for (int k = 0; k < vv[j].size(); k++) { if (sw[vv[j][k]] == 1) { c = 1 - c; } } if (c != b[j]) flag = 0; if (flag == 0) break; } res += flag; } cout << res << endl; }
[ "expression.operation.binary.add" ]
842,092
842,093
u495704746
cpp
p03031
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> adj[15]; int nyala[15]; bool cek(int x) { for (int i = 1; i <= m; i++) { int tmp = 0; for (int j = 0; j < adj[i].size(); j++) { int cur = adj[i][j]; if ((1 << cur) & x) tmp++; } if (nyala[i] != tmp % 2) return 0; } return 1; } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int x; scanf("%d", &x); for (int j = 1; j <= x; j++) { int y; scanf("%d", &y); adj[i].push_back(y); } } for (int i = 1; i <= m; i++) { scanf("%d", &nyala[i]); } int ans = 0; for (int i = 0; i < (1 << n); i++) { if (cek(i)) ans++; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> adj[15]; int nyala[15]; bool cek(int x) { for (int i = 1; i <= m; i++) { int tmp = 0; for (int j = 0; j < adj[i].size(); j++) { int cur = adj[i][j] - 1; if ((1 << cur) & x) tmp++; } if (nyala[i] != tmp % 2) return 0; } return 1; } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int x; scanf("%d", &x); for (int j = 1; j <= x; j++) { int y; scanf("%d", &y); adj[i].push_back(y); } } for (int i = 1; i <= m; i++) { scanf("%d", &nyala[i]); } int ans = 0; for (int i = 0; i < (1 << n); i++) { if (cek(i)) ans++; } printf("%d\n", ans); return 0; }
[ "assignment.change" ]
842,094
842,095
u320128666
cpp
p03031
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define fi first #define se second #define pb push_back #define rep(i, s, n) for (int i = s; i < n; i++) #define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--) #define all(a) a.begin(), a.end() typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; const long long MOD = 1000000007, INF = 1e17; #define endl '\n' #define IOS() \ ios_base::sync_with_stdio(0); \ cin.tie(0) 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 <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } int A, B, C, D, E, F, G, H, I, J, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, K; string s, t; signed main() { IOS(); cin >> N >> M; int ans = 0; int k[M][N] = {}; rep(i, 0, M) { int t; cin >> t; rep(j, 0, t) { int tt; cin >> tt; k[j][tt - 1] = true; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } rep(i, 0, 1ll << N) { int flg = 1; rep(l, 0, M) { int cnt = 0; rep(j, 0, N) { if ((i & (1ll << j)) && k[l][j]) cnt++; } if (cnt % 2 != p[l]) { flg = 0; break; } } if (flg) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define fi first #define se second #define pb push_back #define rep(i, s, n) for (int i = s; i < n; i++) #define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--) #define all(a) a.begin(), a.end() typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; const long long MOD = 1000000007, INF = 1e17; #define endl '\n' #define IOS() \ ios_base::sync_with_stdio(0); \ cin.tie(0) 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 <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } int A, B, C, D, E, F, G, H, I, J, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, K; string s, t; signed main() { IOS(); cin >> N >> M; int ans = 0; int k[M][N] = {}; rep(i, 0, M) { int t; cin >> t; rep(j, 0, t) { int tt; cin >> tt; k[i][tt - 1] = true; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } rep(i, 0, 1ll << N) { int flg = 1; rep(l, 0, M) { int cnt = 0; rep(j, 0, N) { if ((i & (1ll << j)) && k[l][j]) cnt++; } if (cnt % 2 != p[l]) { flg = 0; break; } } if (flg) ans++; } cout << ans << endl; }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
842,096
842,097
u693027786
cpp
p03031
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define fi first #define se second #define pb push_back #define rep(i, s, n) for (int i = s; i < n; i++) #define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--) #define all(a) a.begin(), a.end() typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; const long long MOD = 1000000007, INF = 1e17; #define endl '\n' #define IOS() \ ios_base::sync_with_stdio(0); \ cin.tie(0) 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 <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } int A, B, C, D, E, F, G, H, I, J, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, K; string s, t; signed main() { IOS(); cin >> N >> M; int ans = 0; int k[M][N]; rep(i, 0, M) { int t; cin >> t; rep(i, 0, t) { int tt; cin >> tt; k[i][tt - 1] = true; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } rep(i, 0, 1ll << N) { int flg = 1; rep(l, 0, M) { int cnt = 0; rep(j, 0, N) { if ((i & (1ll << j)) && k[l][j]) cnt++; } if (cnt % 2 != p[l]) { flg = 0; break; } } if (flg) ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define fi first #define se second #define pb push_back #define rep(i, s, n) for (int i = s; i < n; i++) #define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--) #define all(a) a.begin(), a.end() typedef pair<int, int> pint; typedef vector<int> vint; typedef vector<pint> vpint; const long long MOD = 1000000007, INF = 1e17; #define endl '\n' #define IOS() \ ios_base::sync_with_stdio(0); \ cin.tie(0) 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 <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; } template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); } int A, B, C, D, E, F, G, H, I, J, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, K; string s, t; signed main() { IOS(); cin >> N >> M; int ans = 0; int k[M][N] = {}; rep(i, 0, M) { int t; cin >> t; rep(j, 0, t) { int tt; cin >> tt; k[i][tt - 1] = true; } } vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } rep(i, 0, 1ll << N) { int flg = 1; rep(l, 0, M) { int cnt = 0; rep(j, 0, N) { if ((i & (1ll << j)) && k[l][j]) cnt++; } if (cnt % 2 != p[l]) { flg = 0; break; } } if (flg) ans++; } cout << ans << endl; }
[ "variable_declaration.value.change", "identifier.change", "call.arguments.change" ]
842,098
842,097
u693027786
cpp
p03031
#include <algorithm> #include <iostream> #include <tuple> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> s(M); for (int i = 0; i < N; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int a; cin >> a; s[i] |= (1 << --a); } } vector<int> P(M); for (auto &p : P) cin >> p; int ans = 0; for (int b = 0; b < (1 << N); b++) { int ok = 1; for (int i = 0; i < M; i++) { int bb = b & s[i]; int cnt = 0; while (bb) { cnt += (1 & bb); bb >>= 1; } cnt = (cnt & 1); if (cnt != P[i]) ok = 0; } ans += ok; } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <tuple> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; 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] |= (1 << --a); } } vector<int> P(M); for (auto &p : P) cin >> p; int ans = 0; for (int b = 0; b < (1 << N); b++) { int ok = 1; for (int i = 0; i < M; i++) { int bb = b & s[i]; int cnt = 0; while (bb) { cnt += (1 & bb); bb >>= 1; } cnt = (cnt & 1); if (cnt != P[i]) ok = 0; } ans += ok; } cout << ans << endl; return 0; }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
842,101
842,102
u587172770
cpp
p03031
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #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; s[i].resize(k); for (int j = 0; j < k; j++) { cin >> s[i][j]; 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++) { bool ok = true; for (int j = 0; j < M; j++) { int sz = s[j].size(); int cnt = 0; for (int k = 0; k < sz; k++) { int l = s[j][k]; cnt += (i >> k) & 1; } if (cnt % 2 == p[j]) { ok = false; break; } } if (ok) ans++; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #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; s[i].resize(k); for (int j = 0; j < k; j++) { cin >> s[i][j]; 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++) { bool ok = true; for (int j = 0; j < M; j++) { int sz = s[j].size(); int cnt = 0; for (int k = 0; k < sz; k++) { int l = s[j][k]; cnt += (i >> l) & 1; } if (cnt % 2 != p[j]) { ok = false; break; } } if (ok) ans++; } cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
842,113
842,112
u261886891
cpp
p03031
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define rep(i, a, b) for (int i = a; i < (b); ++i) 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 ll INF = 1LL << 60; const ll MOD = 1e9 + 7; int N, M, k; int main() { cin >> N >> M; vector<vector<int>> v(M); REP(i, M) { cin >> k; REP(j, k) { int t; cin >> t; v[i].push_back(--t); } } vector<int> p(M); REP(i, M) cin >> p[i]; int ans = 0; for (int bit = 1; bit < (1 << N); ++bit) { vector<int> on; REP(i, N) { if (bit & (1 << i)) { on.push_back(i); } } bool isok = true; REP(i, M) { int cnt = 0; REP(j, v[i].size()) { REP(k, on.size()) { if (on[k] == v[i][j]) ++cnt; } } if (cnt % 2 != p[i]) { isok = false; break; } } if (isok) ++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 rep(i, a, b) for (int i = a; i < (b); ++i) 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 ll INF = 1LL << 60; const ll MOD = 1e9 + 7; int N, M, k; int main() { cin >> N >> M; vector<vector<int>> v(M); REP(i, M) { cin >> k; REP(j, k) { int t; cin >> t; v[i].push_back(--t); } } vector<int> p(M); REP(i, M) cin >> p[i]; ll ans = 0; for (int bit = 0; bit < (1 << N); ++bit) { vector<int> on; REP(i, N) { if (bit & (1 << i)) { on.push_back(i); } } bool isok = true; REP(i, M) { int cnt = 0; REP(j, v[i].size()) { REP(k, on.size()) { if (on[k] == v[i][j]) ++cnt; } } if (cnt % 2 != p[i]) { isok = false; break; } } if (isok) ++ans; } cout << ans << endl; return 0; }
[ "variable_declaration.type.change", "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
842,116
842,117
u843175622
cpp
p03031
#include <cstdio> #include <iostream> #include <vector> #define N 15 using namespace std; int n, m, k, c, ans, p[N]; vector<int> s[N]; int main() { int i, j, x, t; cin >> n >> m; for (i = 0; i < m; i++) { scanf("%d", &k); for (j = 0; j < k; j++) { scanf("%d", &t); s[j].push_back(t - 1); } } for (i = 0; i < m; i++) scanf("%d", &p[i]); for (x = 0; x < 1 << n; x++) { for (i = 0; i < m; i++) { c = 0; for (j = 0; j < s[i].size(); j++) { if (x & (1 << s[i][j])) c++; } if (c % 2 != p[i]) break; } if (i == m) ans++; } cout << ans << endl; return 0; }
#include <cstdio> #include <iostream> #include <vector> #define N 15 using namespace std; int n, m, k, c, ans, p[N]; vector<int> s[N]; int main() { int i, j, x, t; cin >> n >> m; for (i = 0; i < m; i++) { scanf("%d", &k); for (j = 0; j < k; j++) { scanf("%d", &t); s[i].push_back(t - 1); } } for (i = 0; i < m; i++) scanf("%d", &p[i]); for (x = 0; x < 1 << n; x++) { for (i = 0; i < m; i++) { c = 0; for (j = 0; j < s[i].size(); j++) { if (x & (1 << s[i][j])) c++; } if (c % 2 != p[i]) break; } if (i == m) ans++; } cout << ans << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change" ]
842,122
842,123
u230265105
cpp
p03031
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> sw[N]; for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; sw[s - 1].push_back(i); } } int p[M]; for (int i = 0; i < M; i++) { cin >> p[M]; } int cnt[M]; int ans = 0; for (int i = 0; i < (1 << N); i++) { memset(cnt, 0, sizeof(cnt)); for (int j = 0; j < N; j++) { if (((1 << j) & i) != 0) { for (int k = 0; k < (int)sw[j].size(); k++) { cnt[sw[j][k]]++; } } } bool ok = true; for (int i = 0; i < M; i++) { if (cnt[i] % 2 != p[M]) { ok = false; break; } } if (ok) ans++; } cout << ans << endl; return 0; }
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> sw[N]; for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; sw[s - 1].push_back(i); } } int p[M]; for (int i = 0; i < M; i++) { cin >> p[i]; } int cnt[M]; int ans = 0; for (int i = 0; i < (1 << N); i++) { memset(cnt, 0, sizeof(cnt)); for (int j = 0; j < N; j++) { if (((1 << j) & i) != 0) { for (int k = 0; k < (int)sw[j].size(); k++) { cnt[sw[j][k]]++; } } } bool ok = true; for (int i = 0; i < M; i++) { if (cnt[i] % 2 != p[i]) { ok = false; break; } } if (ok) ans++; } cout << ans << endl; return 0; }
[ "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
842,124
842,125
u783676040
cpp
p03031
#include <algorithm> #include <cmath> #include <iostream> #include <stdio.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef unsigned long long ull; typedef unsigned int uint; typedef unsigned char uchar; #define umap unordered_map const static ull INVALID_DIGIT = ~(ull)0; int main() { ull N, M; cin >> N >> M; struct Light { std::vector<int> switches; int p; }; std::vector<Light> lights(M); for (size_t i = 0; i < M; i++) { // get light info int k; cin >> k; lights[i].switches.resize(k); for (int switchI = 0; switchI < k; switchI++) { cin >> lights[i].switches[switchI]; lights[i].switches[switchI]--; } } // get each light switch should be even or odd for (size_t i = 0; i < M; i++) { int p; cin >> p; lights[i].p = p; } int successCount = 0; int lightOnOffBits = 0; int maxValue = 1 << N; while (lightOnOffBits <= maxValue) { bool success = true; for (const auto &light : lights) { int onCount = 0; for (auto switchIdx : light.switches) { onCount += ((lightOnOffBits >> switchIdx) & 0x01) == 1; } if (onCount % 2 != light.p) { success = false; break; } } if (success) { successCount++; } lightOnOffBits++; } cout << successCount << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <stdio.h> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; typedef unsigned long long ull; typedef unsigned int uint; typedef unsigned char uchar; #define umap unordered_map const static ull INVALID_DIGIT = ~(ull)0; int main() { ull N, M; cin >> N >> M; struct Light { std::vector<int> switches; int p; }; std::vector<Light> lights(M); for (size_t i = 0; i < M; i++) { // get light info int k; cin >> k; lights[i].switches.resize(k); for (int switchI = 0; switchI < k; switchI++) { cin >> lights[i].switches[switchI]; lights[i].switches[switchI]--; } } // get each light switch should be even or odd for (size_t i = 0; i < M; i++) { int p; cin >> p; lights[i].p = p; } int successCount = 0; int lightOnOffBits = 0; int maxValue = 1 << N; while (lightOnOffBits < maxValue) { bool success = true; for (const auto &light : lights) { int onCount = 0; for (auto switchIdx : light.switches) { onCount += ((lightOnOffBits >> switchIdx) & 0x01) == 1; } if (onCount % 2 != light.p) { success = false; break; } } if (success) { successCount++; } lightOnOffBits++; } cout << successCount << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
842,126
842,127
u097665156
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> S[N], T(M); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; S[i].push_back(s - 1); } } for (int i = 0; i < M; i++) { cin >> T[i]; } int sum = 0; for (int bit = 0; bit < (1 << N); bit++) { int ans = 0; for (int j = 0; j < M; j++) { int cnt = 0; for (int i = 0; i < S[j].size(); i++) { if (bit & (1 << S[j][i])) cnt++; } if (cnt % 2 == T[j]) ans++; } if (ans == M) sum++; } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> S[M], T(M); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; S[i].push_back(s - 1); } } for (int i = 0; i < M; i++) { cin >> T[i]; } int sum = 0; for (int bit = 0; bit < (1 << N); bit++) { int ans = 0; for (int j = 0; j < M; j++) { int cnt = 0; for (int i = 0; i < S[j].size(); i++) { if (bit & (1 << S[j][i])) cnt++; } if (cnt % 2 == T[j]) ans++; } if (ans == M) sum++; } cout << sum << endl; }
[ "identifier.change", "variable_declaration.array_dimensions.change" ]
842,134
842,135
u133391510
cpp
p03031
#include <bits/stdc++.h> #define int long long #define rep(i, n) REP(i, 0, n) #define REP(i, l, r) for (long long i = l; i < r; i++) using namespace std; typedef pair<int, int> P; struct edge { int to, cost; }; class dijkstra { int V; int d[100002]; priority_queue<P, vector<P>, greater<P>> que; void update(int s, vector<edge> G[]) { fill(d, d + V + 1, 100000000000ll); d[s] = 0; que.push(make_pair(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; rep(i, G[v].size()) { edge e = G[v][i]; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(make_pair(d[e.to], e.to)); } } } } public: dijkstra(int v, int s, vector<edge> G[]) { V = v; update(s, G); } int find(int e) { return d[e]; } }; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } bool prime(int a) { if (a == 1) return false; for (int i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } class Union_Find { private: vector<int> t, s; public: Union_Find(int max_length) { rep(i, max_length + 1) { t.push_back(i); s.push_back(1); } } void Union(int x, int y) { if (same(x, y)) return; int tx = Find(x), ty = Find(y); if (s[tx] < s[ty]) { s[ty] += s[tx]; t[tx] = ty; } else if (s[tx] > s[ty]) { s[tx] += s[ty]; t[ty] = tx; } else if (tx > ty) { t[tx] = ty; s[ty] += s[tx]; } else { t[ty] = tx; s[tx] += s[ty]; } } int Find(int n) { if (t[n] == n) return n; else return t[n] = Find(t[n]); } bool same(int x, int y) { return Find(x) == Find(y); } int get_Size(int a) { return s[a]; } }; signed main() { int n, m, k[10], s[10][10], p[10], ans = 0; cin >> n >> m; rep(i, m) { cin >> k[i]; rep(j, k[i]) cin >> s[i][j]; } rep(i, m) cin >> p[i]; rep(i, ((1 << n) + 1)) { int memo = i, cnt = 1, memo2[10]; fill(memo2, memo2 + m, 0); while (memo) { if (memo % 2 == 1) { rep(j, m) { rep(ck, k[j]) { if (s[j][ck] == cnt) { memo2[j]++; } } } } memo /= 2; cnt++; } rep(j, m) { if (memo2[j] % 2 != p[j]) goto ioi; } ans++; ioi:; } cout << ans << endl; }
#include <bits/stdc++.h> #define int long long #define rep(i, n) REP(i, 0, n) #define REP(i, l, r) for (long long i = l; i < r; i++) using namespace std; typedef pair<int, int> P; struct edge { int to, cost; }; class dijkstra { int V; int d[100002]; priority_queue<P, vector<P>, greater<P>> que; void update(int s, vector<edge> G[]) { fill(d, d + V + 1, 100000000000ll); d[s] = 0; que.push(make_pair(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; rep(i, G[v].size()) { edge e = G[v][i]; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(make_pair(d[e.to], e.to)); } } } } public: dijkstra(int v, int s, vector<edge> G[]) { V = v; update(s, G); } int find(int e) { return d[e]; } }; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } bool prime(int a) { if (a == 1) return false; for (int i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } class Union_Find { private: vector<int> t, s; public: Union_Find(int max_length) { rep(i, max_length + 1) { t.push_back(i); s.push_back(1); } } void Union(int x, int y) { if (same(x, y)) return; int tx = Find(x), ty = Find(y); if (s[tx] < s[ty]) { s[ty] += s[tx]; t[tx] = ty; } else if (s[tx] > s[ty]) { s[tx] += s[ty]; t[ty] = tx; } else if (tx > ty) { t[tx] = ty; s[ty] += s[tx]; } else { t[ty] = tx; s[tx] += s[ty]; } } int Find(int n) { if (t[n] == n) return n; else return t[n] = Find(t[n]); } bool same(int x, int y) { return Find(x) == Find(y); } int get_Size(int a) { return s[a]; } }; signed main() { int n, m, k[10], s[10][10], p[10], ans = 0; cin >> n >> m; rep(i, m) { cin >> k[i]; rep(j, k[i]) cin >> s[i][j]; } rep(i, m) cin >> p[i]; rep(i, ((1 << n))) { int memo = i, cnt = 1, memo2[10]; fill(memo2, memo2 + m, 0); while (memo) { if (memo % 2 == 1) { rep(j, m) { rep(ck, k[j]) { if (s[j][ck] == cnt) { memo2[j]++; } } } } memo /= 2; cnt++; } rep(j, m) { if (memo2[j] % 2 != p[j]) goto ioi; } ans++; ioi:; } cout << ans << endl; }
[ "expression.operation.binary.remove" ]
842,141
842,142
u073057072
cpp
p03031
#include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 500500; int n, m; int a[100][100], p[110]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d", &a[i][0]); for (int j = 1; j <= a[i][0]; j++) scanf("%d", &a[i][j]); } for (int i = 1; i <= m; i++) scanf("%d", &p[i]); int cnt = 0; for (int i = 0; i <= (1 << n) - 1; i++) { int flag = 1; for (int j = 1; j <= m; j++) { int sum = 0; for (int k = 1; k <= a[j][0]; k++) { if ((i & (1 << (a[j][k] - 1))) != 0) sum++; } if (sum % 2 != p[i]) flag = 0; } cnt += flag; } cout << cnt << endl; }
#include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 500500; int n, m; int a[100][100], p[110]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d", &a[i][0]); for (int j = 1; j <= a[i][0]; j++) scanf("%d", &a[i][j]); } for (int i = 1; i <= m; i++) scanf("%d", &p[i]); int cnt = 0; for (int i = 0; i <= (1 << n) - 1; i++) { int flag = 1; for (int j = 1; j <= m; j++) { int sum = 0; for (int k = 1; k <= a[j][0]; k++) { if ((i & (1 << (a[j][k] - 1))) != 0) sum++; } if (sum % 2 != p[j]) flag = 0; } // if(flag)cout<<i<<endl; cnt += flag; } cout << cnt << endl; }
[ "identifier.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
842,152
842,153
u308881771
cpp
p03031
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int n, m; cin >> n >> m; vector<int> k(m), p(m); int s[10][10]; 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 count = 0; for (int sw = 0; sw < 1 << n; sw++) { int cc = 0; for (int i = 0; i < m; i++) { int c = 0; for (int j = 0; j < k[i]; j++) { if (sw >> s[i][j] & 1) c++; } if (c % 2 == p[i]) cc++; } if (cc == m) count++; } cout << count << endl; }
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int n, m; cin >> n >> m; vector<int> k(m), p(m); int s[10][10]; 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 count = 0; for (int sw = 0; sw < 1 << n; sw++) { int cc = 0; for (int i = 0; i < m; i++) { int c = 0; for (int j = 0; j < k[i]; j++) { if ((sw >> (s[i][j] - 1)) & 1) c++; } if (c % 2 == p[i]) cc++; } if (cc == m) count++; } cout << count << endl; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
842,172
842,173
u949692208
cpp
p03031
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int s[N] = {0}; int d[M][N] = {0}; int p[M]; int k; int ins; int count = 0; int sum; int tmp; int flug; int max; for (int i = 0; i < M; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> ins; d[i][ins] = 1; } } for (int i = 0; i < M; i++) { cin >> p[i]; } max = pow(2, N); for (int i = 0; i < max; i++) { tmp = i; flug = 1; for (int j = 0; j < N; j++) { s[j] = tmp % 2; tmp /= 2; } for (int j = 0; j < M; j++) { sum = 0; for (int k = 0; k < N; k++) { if (d[j][k] == 1) { sum += s[k]; } } if (sum % 2 != p[j]) { flug = 0; break; } } if (flug == 1) count++; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int s[N] = {0}; int d[M][N] = {0}; int p[M]; int k; int ins; int count = 0; int sum; int tmp; int flug; int max; for (int i = 0; i < M; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> ins; d[i][ins - 1] = 1; } } for (int i = 0; i < M; i++) { cin >> p[i]; } max = pow(2, N); for (int i = 0; i < max; i++) { tmp = i; flug = 1; for (int j = 0; j < N; j++) { s[j] = tmp % 2; tmp /= 2; } for (int j = 0; j < M; j++) { sum = 0; for (int k = 0; k < N; k++) { if (d[j][k] == 1) { sum += s[k]; } } if (sum % 2 != p[j]) { flug = 0; break; } } if (flug == 1) count++; } cout << count << endl; } /* 2 2 2 1 2 2 1 2 0 0 */
[ "assignment.change" ]
842,182
842,183
u279066739
cpp
p03031
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb pushback #define fr(i, n) for (int i = 0; i < n; i++) #define ifr(i, n) for (int i = n - 1; i >= 0; i--) int main() { int n, m; int x; int k; cin >> n >> m; int sw[m][n]; int jou[m]; int ans = 0; bool flag; int nishin[n]; fr(i, m) { fr(j, n) { sw[m][n] = 0; } } fr(i, m) { cin >> k; fr(j, k) { cin >> x; sw[i][x] = 1; } } int p[m]; fr(i, m) { cin >> p[i]; } fr(i, int(pow(2, n))) { int z = i; flag = true; fr(j, m) { jou[j] = 0; } fr(j, n) { nishin[j] = z % 2; z = z / 2; } fr(j, n) { fr(k, m) { jou[k] += nishin[j] * sw[k][j]; } } fr(j, m) { if (jou[j] % 2 != p[j]) flag = false; } if (flag == true) ans += 1; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb pushback #define fr(i, n) for (int i = 0; i < n; i++) #define ifr(i, n) for (int i = n - 1; i >= 0; i--) int main() { int n, m; int x; int k; cin >> n >> m; int sw[m][n]; int jou[m]; int ans = 0; bool flag; int nishin[n]; fr(i, m) { fr(j, n) { sw[i][j] = 0; } } fr(i, m) { cin >> k; fr(j, k) { cin >> x; sw[i][x - 1] = 1; } } int p[m]; fr(i, m) { cin >> p[i]; } fr(i, int(pow(2, n))) { int z = i; flag = true; fr(j, m) { jou[j] = 0; } fr(j, n) { nishin[j] = z % 2; z = z / 2; } fr(j, n) { fr(k, m) { jou[k] += nishin[j] * sw[k][j]; } } fr(j, m) { if (jou[j] % 2 != p[j]) flag = false; } if (flag == true) ans += 1; } cout << ans << endl; }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change", "assignment.change" ]
842,184
842,185
u806159048
cpp
p03031
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; int main() { int N, M; cin >> N >> M; vector<int> k(M), p(M); vector<vector<int>> s(M); for (int i = 0; i < M; i++) { cin >> k[i]; s[i] = vector<int>(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 cnt = 0; for (int i = 0; i < pow(2, N); i++) { vector<int> on(N); int flag = 1; for (int j = 0; j < N; j++) { on[j] = (i >> j) & 1; } for (int j = 0; j < M; j++) { int onn = 0; for (int l = 0; l < k[j]; l++) { onn += on[s[j][l]]; } if (onn % 2 != p[j]) flag = 0; } if (flag == 1) cnt++; } cout << cnt; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; int main() { int N, M; cin >> N >> M; vector<int> k(M), p(M); vector<vector<int>> s(M); for (int i = 0; i < M; i++) { cin >> k[i]; s[i] = vector<int>(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 cnt = 0; for (int i = 0; i < pow(2, N); i++) { vector<int> on(N); int flag = 1; for (int j = 0; j < N; j++) { on[j] = (i >> j) & 1; } for (int j = 0; j < M; j++) { int onn = 0; for (int l = 0; l < k[j]; l++) { onn += on[s[j][l] - 1]; } if (onn % 2 != p[j]) flag = 0; } if (flag == 1) cnt++; } cout << cnt; return 0; }
[ "assignment.change" ]
842,188
842,189
u129667379
cpp
p03031
#include <iostream> #include <vector> int main() { int N, M; std::cin >> N >> M; int k[M]; std::vector<int> s[M]; int n = 1; for (int i = 0; i < N; ++i) n *= 2; for (int i = 0; i < M; ++i) { std::cin >> k[i]; for (int j = 0; j < k[i]; ++j) { int tmp = 0; std::cin >> tmp; s[i].push_back(tmp - 1); } } int p[M]; for (int i = 0; i < M; ++i) std::cin >> p[i]; int ans = 0; for (int i = 1; i < n; ++i) { bool flag = true; for (int j = 0; j < M; ++j) { int count = 0; for (int l = 0; l < k[j]; ++l) { if (i & (1 << s[j][l])) { count++; } } if (count % 2 != p[j]) { flag = false; break; } } if (flag) ++ans; } std::cout << ans << std::endl; return 0; }
#include <iostream> #include <vector> int main() { int N, M; std::cin >> N >> M; int k[M]; std::vector<int> s[M]; int n = 1; for (int i = 0; i < N; ++i) n *= 2; for (int i = 0; i < M; ++i) { std::cin >> k[i]; for (int j = 0; j < k[i]; ++j) { int tmp = 0; std::cin >> tmp; s[i].push_back(tmp - 1); } } int p[M]; for (int i = 0; i < M; ++i) std::cin >> p[i]; int ans = 0; for (int i = 0; i < n; ++i) { bool flag = true; for (int j = 0; j < M; ++j) { int count = 0; for (int l = 0; l < k[j]; ++l) { if (i & (1 << s[j][l])) { count++; } } if (count % 2 != p[j]) { flag = false; break; } } if (flag) ++ans; } std::cout << ans << std::endl; return 0; }
[ "literal.number.change", "variable_declaration.value.change", "control_flow.loop.for.initializer.change", "expression.off_by_one" ]
842,190
842,191
u047150897
cpp
p03031
#include <bits/stdc++.h> using namespace std; #define LLINF (1LL << 60) typedef long long ll; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) // C++14 (GCC 5.4.1) int main() { int N, M; cin >> N >> M; int k, l; vector<int> S(M, 0), P(M); rep(i, M) { cin >> k; rep(j, k) { cin >> l; S[j] |= 1 << (l - 1); } } rep(i, M) cin >> P[i]; //----------------------------------- int ans = 0; bool isok; rep(bit, 1 << N) { isok = true; rep(i, M) { isok = __builtin_popcount(bit & S[i]) % 2 == P[i]; if (!isok) break; } if (isok) ans++; } cout << ans << endl; return (0); }
#include <bits/stdc++.h> using namespace std; #define LLINF (1LL << 60) typedef long long ll; #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) // C++14 (GCC 5.4.1) int main() { int N, M; cin >> N >> M; int k, l; vector<int> S(M, 0), P(M); rep(i, M) { cin >> k; rep(j, k) { cin >> l; S[i] |= 1 << (l - 1); } } rep(i, M) cin >> P[i]; //----------------------------------- int ans = 0; bool isok; rep(bit, 1 << N) { isok = true; rep(i, M) { isok = (__builtin_popcount(bit & S[i]) % 2 == P[i]); if (!isok) break; } if (isok) ans++; } cout << ans << endl; return (0); }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
842,192
842,193
u216459554
cpp
p03031
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define ld long double #define ll long long int #define ull unsigned long long int #define rep(i, n) for (i = 0; i < n; i++) #define fin(ans) cout << (ans) << endl #define INF INT_MAX #define vi vector<int> #define vc vector<char> #define vs vector<string> #define vpii vector<pair<int, int>> #define vvi vector<vector<int>> #define vvc vector<vector<char>> #define vvs vector<vector<string>> #define P 1000000007 using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long LLINF = 1LL << 60; // set<int>::iterator it; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ////////////////////////////////////////////////////// int sw = 0; int i, j; int n, m, k, t; cin >> n >> m; vector<vector<int>> v(m, vector<int>()); for (i = 0; i < m; i++) { cin >> k; for (j = 0; j < k; j++) { cin >> t; v[i].push_back(t); } } int p[m]; rep(i, m) cin >> p[i]; int ans = 0; vector<int> st(n * n, 0); vector<int> swn(m, 0); int onsw; for (sw = 0; sw <= pow(2, n); sw++) { //すべてのスイッチ onsw = 0; rep(i, n * n) st[i] = 0; rep(i, m) swn[i] = 0; t = sw; i = 0; while (t > 0) { st[i] = t % 2; t /= 2; i++; } rep(i, m) { //各電球 rep(j, v[i].size()) { //スイッチがオンか if (st[v[i][j] - 1] == 1) swn[i]++; } if (swn[i] % 2 == p[i]) onsw++; } if (onsw == m) ans++; } fin(ans); ////////////////////////////////////////////////////// return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define ld long double #define ll long long int #define ull unsigned long long int #define rep(i, n) for (i = 0; i < n; i++) #define fin(ans) cout << (ans) << endl #define INF INT_MAX #define vi vector<int> #define vc vector<char> #define vs vector<string> #define vpii vector<pair<int, int>> #define vvi vector<vector<int>> #define vvc vector<vector<char>> #define vvs vector<vector<string>> #define P 1000000007 using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long LLINF = 1LL << 60; // set<int>::iterator it; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ////////////////////////////////////////////////////// int sw = 0; int i, j; int n, m, k, t; cin >> n >> m; vector<vector<int>> v(m, vector<int>()); for (i = 0; i < m; i++) { cin >> k; for (j = 0; j < k; j++) { cin >> t; v[i].push_back(t); } } int p[m]; rep(i, m) cin >> p[i]; int ans = 0; vector<int> st(n * n, 0); vector<int> swn(m, 0); int onsw; for (sw = 0; sw < pow(2, n); sw++) { //すべてのスイッチ onsw = 0; rep(i, n * n) st[i] = 0; rep(i, m) swn[i] = 0; t = sw; i = 0; while (t > 0) { st[i] = t % 2; t /= 2; i++; } // for(i=0;i<n;i++)cout<<st[i]; // cout<<endl; rep(i, m) { //各電球 rep(j, v[i].size()) { //スイッチがオンか if (st[v[i][j] - 1] == 1) swn[i]++; } if (swn[i] % 2 == p[i]) onsw++; } if (onsw == m) ans++; } fin(ans); ////////////////////////////////////////////////////// return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,202
842,203
u903311413
cpp
p03031
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define ld long double #define ll long long int #define ull unsigned long long int #define rep(i, n) for (i = 0; i < n; i++) #define fin(ans) cout << (ans) << endl #define INF INT_MAX #define vi vector<int> #define vc vector<char> #define vs vector<string> #define vpii vector<pair<int, int>> #define vvi vector<vector<int>> #define vvc vector<vector<char>> #define vvs vector<vector<string>> #define P 1000000007 using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long LLINF = 1LL << 60; // set<int>::iterator it; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ////////////////////////////////////////////////////// int sw = 0; int i, j; int n, m, k, t; cin >> n >> m; vector<vector<int>> v(m, vector<int>()); for (i = 0; i < m; i++) { cin >> k; for (j = 0; j < k; j++) { cin >> t; v[i].push_back(t); } } int p[m]; rep(i, m) cin >> p[i]; int ans = 0; vector<int> st(n, 0); vector<int> swn(m, 0); int onsw; for (sw = 0; sw <= pow(2, n); sw++) { //すべてのスイッチ onsw = 0; rep(i, n) st[i] = 0; rep(i, m) swn[i] = 0; t = sw; i = 0; while (t > 0) { st[i] = t % 2; t /= 2; i++; } rep(i, m) { //各電球 rep(j, v[i].size()) { //スイッチがオンか if (st[v[i][j] - 1] == 1) swn[i]++; } if (swn[i] % 2 == p[i]) onsw++; } if (onsw == m) ans++; } fin(ans); ////////////////////////////////////////////////////// return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define ld long double #define ll long long int #define ull unsigned long long int #define rep(i, n) for (i = 0; i < n; i++) #define fin(ans) cout << (ans) << endl #define INF INT_MAX #define vi vector<int> #define vc vector<char> #define vs vector<string> #define vpii vector<pair<int, int>> #define vvi vector<vector<int>> #define vvc vector<vector<char>> #define vvs vector<vector<string>> #define P 1000000007 using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long LLINF = 1LL << 60; // set<int>::iterator it; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ////////////////////////////////////////////////////// int sw = 0; int i, j; int n, m, k, t; cin >> n >> m; vector<vector<int>> v(m, vector<int>()); for (i = 0; i < m; i++) { cin >> k; for (j = 0; j < k; j++) { cin >> t; v[i].push_back(t); } } int p[m]; rep(i, m) cin >> p[i]; int ans = 0; vector<int> st(n * n, 0); vector<int> swn(m, 0); int onsw; for (sw = 0; sw < pow(2, n); sw++) { //すべてのスイッチ onsw = 0; rep(i, n * n) st[i] = 0; rep(i, m) swn[i] = 0; t = sw; i = 0; while (t > 0) { st[i] = t % 2; t /= 2; i++; } // for(i=0;i<n;i++)cout<<st[i]; // cout<<endl; rep(i, m) { //各電球 rep(j, v[i].size()) { //スイッチがオンか if (st[v[i][j] - 1] == 1) swn[i]++; } if (swn[i] % 2 == p[i]) onsw++; } if (onsw == m) ans++; } fin(ans); ////////////////////////////////////////////////////// return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,204
842,203
u903311413
cpp
p03031
#include <bits/stdc++.h> using namespace std; #define FOR(i, nn) for (int i = 0; i < nn; i++) #define MOD 1000000007 typedef long long ll; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } else { return 0; } } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } else { return 0; } } template <class T> inline T GCD(T a, T b) { T c; while (b != 0) { c = a % b; a = b; b = c; } return a; } template <class T> inline T LCM(T a, T b) { return a * b / GCD(a, b); } int main() { ll n, m; cin >> n >> m; ll k[100], s[100][100]; FOR(i, m) { cin >> k[i]; FOR(j, k[i]) { cin >> s[i][j]; } } int p[100]; FOR(i, m) { cin >> p[i]; } bool swi[100], c, d; int cnt = 0, ans = 0; FOR(i, pow(2, n) + 1) { FOR(j, 12) { swi[j] = 0; } FOR(j, n) { if (i & (1 << j)) { swi[j] = 1; } } d = 0; FOR(j, m) { cnt = 0; FOR(u, k[j]) { if (swi[s[j][u] - 1]) { cnt++; } } if (cnt % 2 != p[j]) { d = 1; break; } } if (d) continue; ans++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define FOR(i, nn) for (int i = 0; i < nn; i++) #define MOD 1000000007 typedef long long ll; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } else { return 0; } } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } else { return 0; } } template <class T> inline T GCD(T a, T b) { T c; while (b != 0) { c = a % b; a = b; b = c; } return a; } template <class T> inline T LCM(T a, T b) { return a * b / GCD(a, b); } int main() { ll n, m; cin >> n >> m; ll k[100], s[100][100]; FOR(i, m) { cin >> k[i]; FOR(j, k[i]) { cin >> s[i][j]; } } int p[100]; FOR(i, m) { cin >> p[i]; } bool swi[100], c, d; int cnt = 0, ans = 0; FOR(i, pow(2, n)) { FOR(j, 12) { swi[j] = 0; } FOR(j, n) { if (i & (1 << j)) { swi[j] = 1; } } d = 0; FOR(j, m) { cnt = 0; FOR(u, k[j]) { if (swi[s[j][u] - 1]) { cnt++; } } if (cnt % 2 != p[j]) { d = 1; break; } } if (d) continue; ans++; } cout << ans << endl; }
[ "expression.operation.binary.remove" ]
842,211
842,212
u962104148
cpp
p03031
#include <bits/stdc++.h> #define ll long long #define ii pair<int, int> #define vi vector<int> #define vl vector<ll> #define pb push_back #define mp make_pair #define ff first #define ss second #define pi 3.14159265 #define oo 1000000000 using namespace std; #define prime 1000000007 const ll N = 300005; #define W(x) \ cerr << "\033[31m" << #x << " = " << x << "\033[0m" \ << "\n"; int ce(int a, int b) { return (a + b - 1) / b; } int n, m, k, x; int p[11], t[11]; vi gr[11]; int main() { scanf("%d %d", &n, &m); for (int i = 0; i < m; ++i) { scanf("%d", &k); for (int j = 0; j < k; ++j) { scanf("%d", &x); gr[j].pb(x); } } for (int i = 0; i < m; ++i) { scanf("%d", &p[i]); } int mask = 0, ans = 0; int yo = pow(2, n); while (mask < yo) { int aux = mask; for (int i = 1; i <= n; ++i) { t[i] = aux % 2; aux /= 2; } int r = 0; for (int i = 0; i < m; ++i) { int s = 0; for (int l : gr[i]) { if (t[l]) s++; } if (s % 2 == p[i]) r++; } if (r == m) { ans++; } memset(t, 0, sizeof t); mask++; } printf("%d\n", ans); return 0; }
#include <bits/stdc++.h> #define ll long long #define ii pair<int, int> #define vi vector<int> #define vl vector<ll> #define pb push_back #define mp make_pair #define ff first #define ss second #define pi 3.14159265 #define oo 1000000000 using namespace std; #define prime 1000000007 const ll N = 300005; #define W(x) \ cerr << "\033[31m" << #x << " = " << x << "\033[0m" \ << "\n"; int ce(int a, int b) { return (a + b - 1) / b; } int n, m, k, x; int p[11], t[11]; vi gr[11]; int main() { scanf("%d %d", &n, &m); for (int i = 0; i < m; ++i) { scanf("%d", &k); for (int j = 0; j < k; ++j) { scanf("%d", &x); gr[i].pb(x); } } for (int i = 0; i < m; ++i) { scanf("%d", &p[i]); } int mask = 0, ans = 0; int yo = pow(2, n); while (mask < yo) { int aux = mask; for (int i = 1; i <= n; ++i) { t[i] = aux % 2; aux /= 2; } int r = 0; for (int i = 0; i < m; ++i) { int s = 0; for (int l : gr[i]) { if (t[l]) s++; } if (s % 2 == p[i]) r++; } if (r == m) { ans++; } memset(t, 0, sizeof t); mask++; } printf("%d\n", ans); return 0; }
[ "identifier.change", "variable_access.subscript.index.change" ]
842,213
842,214
u680926371
cpp
p03031
#include <bits/stdc++.h> #include <bitset> using namespace std; int main() { int N, M; cin >> N >> M; vector<long long> Bit(M, 0); vector<long long> mod(M, 0); for (int i = 0; i < N; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; Bit[i] ^= 1 << (s - 1); } } for (int i = 0; i < M; i++) cin >> mod[i]; long long ans = 0; for (long long i = 0; i < (1 << N); i++) { bool flg = false; // cout << bitset<3>(i) << "\n"; for (int j = 0; j < M; j++) { // cout << j << ' ' << __builtin_popcount(Bit[j]&i)%2 << ' ' << // mod[j] << "\n"; if (__builtin_popcountll(Bit[j] & i) % 2 != mod[j]) { flg = true; break; } } if (!flg) ans++; } cout << ans << "\n"; // for (int i=0; i<M; i++) { // cout << bitset<3>(Bit[i]) << "\n"; // } }
#include <bits/stdc++.h> #include <bitset> using namespace std; int main() { int N, M; cin >> N >> M; vector<long long> Bit(M, 0); vector<long long> mod(M, 0); for (int i = 0; i < M; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int s; cin >> s; Bit[i] ^= 1 << (s - 1); } } for (int i = 0; i < M; i++) cin >> mod[i]; long long ans = 0; for (long long i = 0; i < (1 << N); i++) { bool flg = false; // cout << bitset<3>(i) << "\n"; for (int j = 0; j < M; j++) { // cout << j << ' ' << __builtin_popcount(Bit[j]&i)%2 << ' ' << // mod[j] << "\n"; if (__builtin_popcountll(Bit[j] & i) % 2 != mod[j]) { flg = true; break; } } if (!flg) ans++; } cout << ans << "\n"; // for (int i=0; i<M; i++) { // cout << bitset<3>(Bit[i]) << "\n"; // } }
[ "identifier.change", "control_flow.loop.for.condition.change", "expression.operation.binary.change" ]
842,215
842,216
u501643136
cpp
p03030
#include <bits/stdc++.h> using namespace std; char in[120]; pair<pair<string, int>, int> p[110]; int main() { int a; cin >> a; for (int i = 0; i < a; i++) { int t; cin >> t; string tmp = in; p[i] = make_pair(make_pair(in, -t), i); } sort(p, p + a); for (int i = 0; i < a; i++) { cout << p[i].second + 1 << endl; } }
#include <bits/stdc++.h> using namespace std; char in[120]; pair<pair<string, int>, int> p[110]; int main() { int a; cin >> a; for (int i = 0; i < a; i++) { int t; cin >> in >> t; string tmp = in; p[i] = make_pair(make_pair(in, -t), i); } sort(p, p + a); for (int i = 0; i < a; i++) { cout << p[i].second + 1 << endl; } }
[ "expression.operation.binary.add" ]
842,229
842,230
u962609087
cpp
p03030
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " int main() { int n; cin >> n; pair<pair<string, int>, int> p[n]; rep(i, n) { string name; int score; cin >> name >> score; p[i] = make_pair(make_pair(name, score), i + 1); } sort(p, p + n); rep(i, n) { co(p[i].second); } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #define co(x) cout << (x) << "\n" #define cosp(x) cout << (x) << " " int main() { int n; cin >> n; pair<pair<string, int>, int> p[n]; rep(i, n) { string name; int score; cin >> name >> score; p[i] = make_pair(make_pair(name, -1 * score), i + 1); } sort(p, p + n); rep(i, n) { co(p[i].second); } }
[ "assignment.change" ]
842,235
842,236
u789075914
cpp
p03030
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<tuple<string, int, int>> t(N); for (int i = 0; i < N; ++i) { string s; int p; cin >> s >> p; t.emplace_back(make_tuple(s, p, i + 1)); } sort(t.begin(), t.end(), [&](auto &a, auto &b) { return get<0>(a) < get<0>(b) || (get<0>(a) == get<0>(b) && get<1>(a) > get<1>(b)); }); for (auto &tt : t) { cout << get<2>(tt) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<tuple<string, int, int>> t(N); for (int i = 0; i < N; ++i) { string s; int p; cin >> s >> p; t[i] = make_tuple(s, p, i + 1); } sort(t.begin(), t.end(), [&](auto &a, auto &b) { return get<0>(a) < get<0>(b) || (get<0>(a) == get<0>(b) && get<1>(a) > get<1>(b)); }); for (auto &tt : t) { cout << get<2>(tt) << endl; } return 0; }
[ "call.arguments.change" ]
842,252
842,253
u335241815
cpp
p03030
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<tuple<string, int, int>> arr; tuple<string, int, int> p; string x; int y, z; for (int i = 0; i < N; i++) { cin >> x; cin >> y; arr.push_back(make_tuple(x, y, i + 1)); } sort(arr.rbegin(), arr.rend()); int num; for (tuple<string, int, int> t : arr) { tie(ignore, ignore, num) = t; cout << num << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<tuple<string, int, int>> arr; tuple<string, int, int> p; string x; int y, z; for (int i = 0; i < N; i++) { cin >> x; cin >> y; arr.push_back(make_tuple(x, -y, i + 1)); } sort(arr.begin(), arr.end()); int num; for (tuple<string, int, int> t : arr) { tie(ignore, ignore, num) = t; cout << num << endl; } }
[ "expression.operation.unary.add", "call.arguments.change", "call.function.change" ]
842,258
842,259
u950567701
cpp
p03030
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<tuple<string, int, int>> tpl(n); for (int i = 0; i < n; i++) { string a; int b; cin >> a >> b; tpl[i] = make_tuple(a, b, i + 1); } sort(tpl.begin(), tpl.end()); for (int i = 0; i < n; i++) { int num; tie(ignore, ignore, num) = tpl[i]; cout << num << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<tuple<string, int, int>> tpl(n); for (int i = 0; i < n; i++) { string a; int b; cin >> a >> b; tpl[i] = make_tuple(a, 100 - b, i + 1); } sort(tpl.begin(), tpl.end()); for (int i = 0; i < n; i++) { int num; tie(ignore, ignore, num) = tpl[i]; cout << num << endl; } }
[ "assignment.change" ]
842,260
842,261
u820057330
cpp
p03030
#include <bits/stdc++.h> using namespace std; int main() { map<pair<string, int>, int> R; int N; cin >> N; for (int i = 0; i < N; i++) { string t; int s; cin >> t >> s; pair<string, int> p(t, s); R[p] = i + 1; } for (auto p : R) { auto k = p.first; auto v = p.second; cout << v << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { map<pair<string, int>, int> R; int N; cin >> N; for (int i = 0; i < N; i++) { string t; int s; cin >> t >> s; pair<string, int> p(t, -s); R[p] = i + 1; } for (auto p : R) { auto k = p.first; auto v = p.second; cout << v << endl; } return 0; }
[ "expression.operation.unary.add", "call.arguments.change" ]
842,278
842,279
u101018317
cpp
p03030
#include <algorithm> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; string s1[N]; string s2[N]; int p1[N]; int p2[N]; for (int i = 0; i < N; i++) { cin >> s1[i] >> p1[i]; } for (int i = 0; i < N; i++) { s2[i] = s1[i]; } for (int i = 0; i < N; i++) { p2[i] = p1[i]; } for (int i = 0; i < N; i++) { for (int k = i + 1; k < N; k++) { if (s1[i].compare(s1[k]) > 0) { string l; l = s1[i]; s1[i] = s1[k]; s1[k] = l; int v; v = p1[i]; p1[i] = p1[k]; p1[k] = v; } } } for (int i = 0; i < N; i++) { for (int k = i + 1; k < N; k++) { if (p1[i] < p1[k] && s1[i] == s2[k]) { string l; l = s1[i]; s1[i] = s1[k]; s1[k] = l; int v; v = p1[i]; p1[i] = p1[k]; p1[k] = v; } } } //あとは、もとの数列、配列と当てはめて、該当する番号を出力するのみ。 for (int i = 0; i < N; i++) { for (int k = 0; k < N; k++) { if (p1[i] == p2[k] && s1[i] == s2[k]) { cout << k + 1 << endl; } } } }
#include <algorithm> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N; cin >> N; string s1[N]; string s2[N]; int p1[N]; int p2[N]; for (int i = 0; i < N; i++) { cin >> s1[i] >> p1[i]; } for (int i = 0; i < N; i++) { s2[i] = s1[i]; } for (int i = 0; i < N; i++) { p2[i] = p1[i]; } for (int i = 0; i < N; i++) { for (int k = i + 1; k < N; k++) { if (s1[i].compare(s1[k]) > 0) { string l; l = s1[i]; s1[i] = s1[k]; s1[k] = l; int v; v = p1[i]; p1[i] = p1[k]; p1[k] = v; } } } for (int i = 0; i < N; i++) { for (int k = i + 1; k < N; k++) { if (p1[i] < p1[k] && s1[i] == s1[k]) { string l; l = s1[i]; s1[i] = s1[k]; s1[k] = l; int v; v = p1[i]; p1[i] = p1[k]; p1[k] = v; } } } //あとは、もとの数列、配列と当てはめて、該当する番号を出力するのみ。 for (int i = 0; i < N; i++) { for (int k = 0; k < N; k++) { if (p1[i] == p2[k] && s1[i] == s2[k]) { cout << k + 1 << endl; } } } }
[ "identifier.change", "control_flow.branch.if.condition.change" ]
842,280
842,281
u878454346
cpp
p03030
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<tuple<string, int, int>> p; for (int i = 0; i < n; i++) { string name; int sco; cin >> name >> sco; // p = make_pair(sco, name); sco *= -1; p.push_back(make_tuple(name, sco, i + 1)); } sort(p.begin(), p.end()); // reverse(p.begin(), p.end()); for (tuple<string, int, int> t : p) { int sco, i; string s; tie(s, sco, i) = t; cout << i << s << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<tuple<string, int, int>> p; for (int i = 0; i < n; i++) { string name; int sco; cin >> name >> sco; // p = make_pair(sco, name); sco *= -1; p.push_back(make_tuple(name, sco, i + 1)); } sort(p.begin(), p.end()); // reverse(p.begin(), p.end()); for (tuple<string, int, int> t : p) { int sco, i; string s; tie(s, sco, i) = t; cout << i << endl; } }
[ "expression.operation.binary.remove" ]
842,284
842,285
u729695898
cpp
p03030
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string S[N]; int P[N]; int num[N]; for (int i = 0; i < N; ++i) { cin >> S[i] >> P[i]; num[N] = i + 1; } int i = 0; int flag = 0; int swap_P; int swap_num; string swap_S; // 点数大きい順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 1) { // 1巡したらreset i = 0; } else if (P[i] >= P[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } i = 0; flag = 0; // 辞書順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 1) { // 1巡したらreset i = 0; } else if (S[i] <= S[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } for (int i = 0; i < N; ++i) { cout << num[i] << endl; } }
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string S[N]; int P[N]; int num[N]; for (int i = 0; i < N; ++i) { cin >> S[i] >> P[i]; num[i] = i + 1; } int i = 0; int flag = 0; int swap_P; int swap_num; string swap_S; // 点数大きい順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 1) { // 1巡したらreset i = 0; } else if (P[i] >= P[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } i = 0; flag = 0; // 辞書順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 1) { // 1巡したらreset i = 0; } else if (S[i] <= S[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } for (int i = 0; i < N; ++i) { cout << num[i] << endl; } }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
842,286
842,287
u894788154
cpp
p03030
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string S[N]; int P[N]; int num[N]; for (int i = 0; i < N; ++i) { cin >> S[i] >> P[i]; num[N] = i + 1; } int i = 0; int flag = 0; int swap_P; int swap_num; string swap_S; // 点数大きい順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 2) { // 1巡したらreset i = 0; } else if (P[i] >= P[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } i = 0; flag = 0; // 辞書順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 2) { // 1巡したらreset i = 0; } else if (S[i] <= S[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } for (int i = 0; i < N; ++i) { cout << num[i] << endl; } }
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; string S[N]; int P[N]; int num[N]; for (int i = 0; i < N; ++i) { cin >> S[i] >> P[i]; num[i] = i + 1; } int i = 0; int flag = 0; int swap_P; int swap_num; string swap_S; // 点数大きい順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 1) { // 1巡したらreset i = 0; } else if (P[i] >= P[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } i = 0; flag = 0; // 辞書順に並べる while (1) { if (flag == N - 1) { // すべて無操作ならbreak break; } else if (i == N - 1) { // 1巡したらreset i = 0; } else if (S[i] <= S[i + 1]) { // 1つ無操作ならflag ++i; ++flag; } else { // swapしてflagをreset swap_P = P[i]; P[i] = P[i + 1]; P[i + 1] = swap_P; swap_S = S[i]; S[i] = S[i + 1]; S[i + 1] = swap_S; swap_num = num[i]; num[i] = num[i + 1]; num[i + 1] = swap_num; ++i; flag = 0; } } for (int i = 0; i < N; ++i) { cout << num[i] << endl; } }
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change", "literal.number.change", "control_flow.branch.if.condition.change" ]
842,288
842,287
u894788154
cpp
p03032
//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define pb push_back #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define ll long long using namespace std; void file() { #ifndef ONLINE_JUDGE freopen("tst.txt", "r", stdin); #endif } int tc; const int N = 3e5 + 5, M = 3e5 + 5, MOD = 1e9 + 7, OO = 1e9; ll memo[55][55][105]; int n, k, a[55], b[55]; bool vis[55][65][105]; ll solve(int l, int r, int rem) { if (rem == 0) return 0; std::vector<int> mn; ll &ret = memo[l][r][rem]; if (vis[l][r][rem]) return ret; vis[l][r][rem] = 1; if (l > r) { ret = 0; for (int i = 0; i < min(rem, n); i++) { if (b[i] > 0) break; ret -= b[i]; } return ret; } for (int i = 0; i < l; i++) mn.pb(a[i]); for (int i = r + 1; i < n; i++) mn.pb(a[i]); sort(all(mn)); ret = solve(l, r, rem - 1); ll curr = 0; for (int i = 0; i < min(rem, sz(mn)); i++) { if (mn[i] >= 0) break; curr -= mn[i]; ret = max(ret, curr); } if (l <= r) { if (l <= n - 1) ret = max(ret, solve(l + 1, r, rem - 1) + a[l]); if (r >= 0) ret = max(ret, solve(l, r - 1, rem - 1) + a[r]); } return ret; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // file(); scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); b[i] = a[i]; } sort(b, b + n); printf("%lld\n", solve(0, n - 1, k)); }
//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define pb push_back #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define ll long long using namespace std; void file() { #ifndef ONLINE_JUDGE freopen("tst.txt", "r", stdin); #endif } int tc; const int N = 3e5 + 5, M = 3e5 + 5, MOD = 1e9 + 7, OO = 1e9; ll memo[55][55][105]; int n, k, a[55], b[55]; bool vis[55][65][105]; ll solve(int l, int r, int rem) { if (rem == 0) return 0; std::vector<int> mn; ll &ret = memo[l][r][rem]; if (vis[l][r][rem]) return ret; vis[l][r][rem] = 1; if (l > r) { ret = 0; for (int i = 0; i < min(rem, n); i++) { if (b[i] > 0) break; ret -= b[i]; } return ret; } for (int i = 0; i < l; i++) mn.pb(a[i]); for (int i = r + 1; i < n; i++) mn.pb(a[i]); sort(all(mn)); ret = solve(l, r, rem - 1); ll curr = 0; for (int i = 0; i < min(rem, sz(mn)); i++) { if (mn[i] >= 0) break; curr -= mn[i]; ret = max(ret, curr); } if (l <= r) { if (l <= n - 1) ret = max(ret, solve(l + 1, r, rem - 1) + a[l]); if (r > 0) ret = max(ret, solve(l, r - 1, rem - 1) + a[r]); } return ret; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // file(); scanf("%d %d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); b[i] = a[i]; } sort(b, b + n); printf("%lld\n", solve(0, n - 1, k)); }
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
842,291
842,292
u353919145
cpp
p03032
#include <algorithm> #include <cstdio> #include <iostream> #define maxn 100 using namespace std; int n, l, r, a[maxn], p, b[maxn], cnt, sum, ans = 0; int main() { scanf("%d%d", &n, &p); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 0; i <= p; i++) { //Ò»¹²½øÐÐÁ˼¸´ÎÈ¡µÄ²Ù×÷ for (int j = 0; j <= i; j++) { int lnum = j, rnum = i - j; cnt = 0; sum = 0; for (int k = 1; k <= lnum; k++) { b[++cnt] = a[k]; sum += a[k]; } for (int k = n; k >= n - rnum + 1; k--) { b[++cnt] = a[k]; sum += a[k]; } sort(b + 1, b + cnt + 1); for (int k = 1; k <= min(p - i, cnt); k++) { if (b[k] >= 0) break; sum -= b[k]; } ans = max(ans, sum); } } printf("%d\n", ans); return 0; }
#include <algorithm> #include <cstdio> #include <iostream> #define maxn 100 using namespace std; int n, l, r, a[maxn], p, b[maxn], cnt, sum, ans = 0; int main() { scanf("%d%d", &n, &p); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 0; i <= min(n, p); i++) { //Ò»¹²½øÐÐÁ˼¸´ÎÈ¡µÄ²Ù×÷ for (int j = 0; j <= i; j++) { int lnum = j, rnum = i - j; cnt = 0; sum = 0; for (int k = 1; k <= lnum; k++) { b[++cnt] = a[k]; sum += a[k]; } for (int k = n; k >= n - rnum + 1; k--) { b[++cnt] = a[k]; sum += a[k]; } sort(b + 1, b + cnt + 1); for (int k = 1; k <= min(p - i, cnt); k++) { if (b[k] >= 0) break; sum -= b[k]; } ans = max(ans, sum); } } printf("%d\n", ans); return 0; }
[ "control_flow.loop.for.condition.change", "call.add", "call.arguments.change" ]
842,293
842,294
u089230684
cpp
p03032
#include <bits/stdc++.h> typedef long long ll; #define dbg cout << "Freak" << endl; #define dbgg(i) cout << i << endl; #define N 1e9 + 7; using namespace std; ll t; ll arr[200005]; int main() { ll a, b, c, d, e, f, g, i, j, k, sum; vector<ll> v; cin >> a >> b; for (i = 1; i <= a; i++) cin >> arr[i]; f = 0; for (i = 0; i <= a; i++) { for (j = 0; j <= a; j++) { d = b - i - j; sum = 0; v.clear(); if (d < 0 || i + j > b) continue; for (k = 1; k <= i; k++) { v.push_back(arr[k]); sum += arr[k]; } for (k = a; k > a - j; k--) { v.push_back(arr[k]); sum += arr[k]; } sort(v.begin(), v.end()); for (k = 0; k < i + j && d != 0; k++) { if (v[k] >= 0) break; sum = sum - v[k]; --d; } f = max(sum, f); } } cout << f << endl; return 0; }
#include <bits/stdc++.h> typedef long long ll; #define dbg cout << "Freak" << endl; #define dbgg(i) cout << i << endl; #define N 1e9 + 7; using namespace std; ll t; ll arr[200005]; int main() { ll a, b, c, d, e, f, g, i, j, k, sum; vector<ll> v; cin >> a >> b; for (i = 1; i <= a; i++) cin >> arr[i]; f = 0; for (i = 0; i <= a; i++) { for (j = 0; j <= a; j++) { d = b - i - j; sum = 0; v.clear(); if (d < 0 || i + j > b || i + j > a) continue; for (k = 1; k <= i; k++) { v.push_back(arr[k]); sum += arr[k]; } for (k = a; k > a - j; k--) { v.push_back(arr[k]); sum += arr[k]; } sort(v.begin(), v.end()); for (k = 0; k < i + j && d != 0; k++) { if (v[k] >= 0) break; sum = sum - v[k]; --d; } f = max(sum, f); } } cout << f << endl; return 0; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
842,295
842,296
u089230684
cpp
p03032
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*----------------------------------ここからマクロ----------------------------------*/ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define vecin(a) rep(i, a.size()) cin >> a[i] #define overload4(_1, _2, _3, _4, name, ...) name /*#define rep1(n) for(int i=0;i<(int)n;++i) #define rep2(i,n) for(int i=0;i<(int)n;++i) #define rep3(i,a,b) for(int i=(int)a;i<(int)b;++i) #define rep4(i,a,b,c) for(int i=(int)a;i<(int)b;i+=(int)c)*/ #define rep1(n) for (ll i = 0; i < (ll)n; ++i) #define rep2(i, n) for (ll i = 0; i < (ll)n; ++i) #define rep3(i, a, b) for (ll i = (ll)a; i < (ll)b; ++i) #define rep4(i, a, b, c) for (int i = (ll)a; i < (ll)b; i += (ll)c) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #ifdef _DEBUG #define debug1(a) cerr << #a << ": " << a << "\n" #define debug2(a, b) cerr << #a << ": " << a << ", " << #b << ": " << b << "\n" #define debug3(a, b, c) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << "\n" #define debug4(a, b, c, d) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << ", " << #d << ": " << d << "\n" #define debug(...) \ overload4(__VA_ARGS__, debug4, debug3, debug2, debug1)(__VA_ARGS__) #define vecout(a) \ cerr << #a << ": ["; \ rep(i, a.size()) { \ cerr << a[i]; \ cerr << (i == a.size() - 1 ? "" : ","); \ } \ cerr << "]\n" #else #define debug(...) #define vecout(a) #endif #define mp make_pair // struct doset{doset(int n){cout << fixed << setprecision(n);cerr << fixed << // setprecision(n);}}; struct // myset{myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}; void myset() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void doset(int n) { cout << fixed << setprecision(n); } using ll = long long; using ld = long double; using dou = double; const int inf = 1 << 30; const ll INF = 1LL << 60; const ld pi = 3.14159265358; const ll mod1 = 1000000007LL; const ll mod2 = 998244353LL; typedef pair<ll, ll> P; template <class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template <class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class U> inline bool change(T &a, U &b) { if (a > b) { swap(a, b); return 1; } return 0; } // nのm乗をMODで割ったあまりO(logm) ll modpow(ll n, ll m, ll MOD) { if (m == 0) return 1; if (m < 0) return 0; ll res = 1; n %= MOD; while (m) { if (m & 1) res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n, ll m) { if (m == 0) return 1; if (m < 0) return -1; ll res = 1; while (m) { if (m & 1) res = (res * n); m >>= 1; n *= n; } return res; } //素数判定O(sqrt(N)) template <class T> inline bool isp(T n) { bool res = true; if (n == 1 || n == 0) return false; else { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res = false; break; } } return res; } } template <class T = int> T in() { T x; cin >> x; return x; } inline bool Yes(bool b) { cout << (b ? "Yes\n" : "No\n"); return b; } inline bool YES(bool b) { cout << (b ? "YES\n" : "NO\n"); return b; } /*----------------------------------マクロここまで----------------------------------*/ ll __lcm(ll a, ll b) { return a / __gcd(a, b) * b; } int main() { myset(); ll N, K; cin >> N >> K; vector<ll> vec(N); rep(i, N) cin >> vec[i]; ll ans = 0; ll M = min(2 * N, K); rep(i, M) { //取る個数 ll push = K - i; //戻せる個数 rep(j, i + 1) { //左から取る個数 vector<ll> cho; ll R = i - j; rep(k, j) cho.emplace_back(vec[k]); for (int k = N - 1; k >= N - R; k--) { cho.emplace_back(vec[k]); } sort(all(cho)); ll cnt = 0; ll neg = 0; for (ll x : cho) { if (x < 0) { if (neg < push) { neg++; } else { cnt += x; } } else { cnt += x; } } chmax(ans, cnt); } } cout << ans << "\n"; }
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*----------------------------------ここからマクロ----------------------------------*/ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define vecin(a) rep(i, a.size()) cin >> a[i] #define overload4(_1, _2, _3, _4, name, ...) name /*#define rep1(n) for(int i=0;i<(int)n;++i) #define rep2(i,n) for(int i=0;i<(int)n;++i) #define rep3(i,a,b) for(int i=(int)a;i<(int)b;++i) #define rep4(i,a,b,c) for(int i=(int)a;i<(int)b;i+=(int)c)*/ #define rep1(n) for (ll i = 0; i < (ll)n; ++i) #define rep2(i, n) for (ll i = 0; i < (ll)n; ++i) #define rep3(i, a, b) for (ll i = (ll)a; i < (ll)b; ++i) #define rep4(i, a, b, c) for (int i = (ll)a; i < (ll)b; i += (ll)c) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #ifdef _DEBUG #define debug1(a) cerr << #a << ": " << a << "\n" #define debug2(a, b) cerr << #a << ": " << a << ", " << #b << ": " << b << "\n" #define debug3(a, b, c) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << "\n" #define debug4(a, b, c, d) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << ", " << #d << ": " << d << "\n" #define debug(...) \ overload4(__VA_ARGS__, debug4, debug3, debug2, debug1)(__VA_ARGS__) #define vecout(a) \ cerr << #a << ": ["; \ rep(i, a.size()) { \ cerr << a[i]; \ cerr << (i == a.size() - 1 ? "" : ","); \ } \ cerr << "]\n" #else #define debug(...) #define vecout(a) #endif #define mp make_pair // struct doset{doset(int n){cout << fixed << setprecision(n);cerr << fixed << // setprecision(n);}}; struct // myset{myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}; void myset() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void doset(int n) { cout << fixed << setprecision(n); } using ll = long long; using ld = long double; using dou = double; const int inf = 1 << 30; const ll INF = 1LL << 60; const ld pi = 3.14159265358; const ll mod1 = 1000000007LL; const ll mod2 = 998244353LL; typedef pair<ll, ll> P; template <class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template <class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class U> inline bool change(T &a, U &b) { if (a > b) { swap(a, b); return 1; } return 0; } // nのm乗をMODで割ったあまりO(logm) ll modpow(ll n, ll m, ll MOD) { if (m == 0) return 1; if (m < 0) return 0; ll res = 1; n %= MOD; while (m) { if (m & 1) res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n, ll m) { if (m == 0) return 1; if (m < 0) return -1; ll res = 1; while (m) { if (m & 1) res = (res * n); m >>= 1; n *= n; } return res; } //素数判定O(sqrt(N)) template <class T> inline bool isp(T n) { bool res = true; if (n == 1 || n == 0) return false; else { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res = false; break; } } return res; } } template <class T = int> T in() { T x; cin >> x; return x; } inline bool Yes(bool b) { cout << (b ? "Yes\n" : "No\n"); return b; } inline bool YES(bool b) { cout << (b ? "YES\n" : "NO\n"); return b; } /*----------------------------------マクロここまで----------------------------------*/ ll __lcm(ll a, ll b) { return a / __gcd(a, b) * b; } int main() { myset(); ll N, K; cin >> N >> K; vector<ll> vec(N); rep(i, N) cin >> vec[i]; ll ans = 0; ll M = min(N, K); rep(i, M + 1) { //取る個数 ll push = K - i; //戻せる個数 rep(j, i + 1) { //左から取る個数 vector<ll> cho; ll R = i - j; rep(k, j) cho.emplace_back(vec[k]); for (int k = N - 1; k >= N - R; k--) { cho.emplace_back(vec[k]); } sort(all(cho)); ll cnt = 0; ll neg = 0; for (ll x : cho) { if (x < 0) { if (neg < push) { neg++; } else { cnt += x; } } else { cnt += x; } } chmax(ans, cnt); } } cout << ans << "\n"; }
[ "expression.operation.binary.remove" ]
842,299
842,300
u527652459
cpp
p03032
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*----------------------------------ここからマクロ----------------------------------*/ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define vecin(a) rep(i, a.size()) cin >> a[i] #define overload4(_1, _2, _3, _4, name, ...) name /*#define rep1(n) for(int i=0;i<(int)n;++i) #define rep2(i,n) for(int i=0;i<(int)n;++i) #define rep3(i,a,b) for(int i=(int)a;i<(int)b;++i) #define rep4(i,a,b,c) for(int i=(int)a;i<(int)b;i+=(int)c)*/ #define rep1(n) for (ll i = 0; i < (ll)n; ++i) #define rep2(i, n) for (ll i = 0; i < (ll)n; ++i) #define rep3(i, a, b) for (ll i = (ll)a; i < (ll)b; ++i) #define rep4(i, a, b, c) for (int i = (ll)a; i < (ll)b; i += (ll)c) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #ifdef _DEBUG #define debug1(a) cerr << #a << ": " << a << "\n" #define debug2(a, b) cerr << #a << ": " << a << ", " << #b << ": " << b << "\n" #define debug3(a, b, c) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << "\n" #define debug4(a, b, c, d) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << ", " << #d << ": " << d << "\n" #define debug(...) \ overload4(__VA_ARGS__, debug4, debug3, debug2, debug1)(__VA_ARGS__) #define vecout(a) \ cerr << #a << ": ["; \ rep(i, a.size()) { \ cerr << a[i]; \ cerr << (i == a.size() - 1 ? "" : ","); \ } \ cerr << "]\n" #else #define debug(...) #define vecout(a) #endif #define mp make_pair // struct doset{doset(int n){cout << fixed << setprecision(n);cerr << fixed << // setprecision(n);}}; struct // myset{myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}; void myset() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void doset(int n) { cout << fixed << setprecision(n); } using ll = long long; using ld = long double; using dou = double; const int inf = 1 << 30; const ll INF = 1LL << 60; const ld pi = 3.14159265358; const ll mod1 = 1000000007LL; const ll mod2 = 998244353LL; typedef pair<ll, ll> P; template <class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template <class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class U> inline bool change(T &a, U &b) { if (a > b) { swap(a, b); return 1; } return 0; } // nのm乗をMODで割ったあまりO(logm) ll modpow(ll n, ll m, ll MOD) { if (m == 0) return 1; if (m < 0) return 0; ll res = 1; n %= MOD; while (m) { if (m & 1) res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n, ll m) { if (m == 0) return 1; if (m < 0) return -1; ll res = 1; while (m) { if (m & 1) res = (res * n); m >>= 1; n *= n; } return res; } //素数判定O(sqrt(N)) template <class T> inline bool isp(T n) { bool res = true; if (n == 1 || n == 0) return false; else { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res = false; break; } } return res; } } template <class T = int> T in() { T x; cin >> x; return x; } inline bool Yes(bool b) { cout << (b ? "Yes\n" : "No\n"); return b; } inline bool YES(bool b) { cout << (b ? "YES\n" : "NO\n"); return b; } /*----------------------------------マクロここまで----------------------------------*/ ll __lcm(ll a, ll b) { return a / __gcd(a, b) * b; } int main() { myset(); ll N, K; cin >> N >> K; vector<ll> vec(N); rep(i, N) cin >> vec[i]; ll ans = 0; ll M = min(N, K); rep(i, M) { //取る個数 ll push = K - i; //戻せる個数 rep(j, i + 1) { //左から取る個数 vector<ll> cho; ll R = i - j; rep(k, j) cho.emplace_back(vec[k]); for (int k = N - 1; k >= N - R; k--) { cho.emplace_back(vec[k]); } sort(all(cho)); ll cnt = 0; ll neg = 0; for (ll x : cho) { if (x < 0) { if (neg < push) { neg++; } else { cnt += x; } } else { cnt += x; } } chmax(ans, cnt); } } cout << ans << "\n"; }
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*----------------------------------ここからマクロ----------------------------------*/ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define vecin(a) rep(i, a.size()) cin >> a[i] #define overload4(_1, _2, _3, _4, name, ...) name /*#define rep1(n) for(int i=0;i<(int)n;++i) #define rep2(i,n) for(int i=0;i<(int)n;++i) #define rep3(i,a,b) for(int i=(int)a;i<(int)b;++i) #define rep4(i,a,b,c) for(int i=(int)a;i<(int)b;i+=(int)c)*/ #define rep1(n) for (ll i = 0; i < (ll)n; ++i) #define rep2(i, n) for (ll i = 0; i < (ll)n; ++i) #define rep3(i, a, b) for (ll i = (ll)a; i < (ll)b; ++i) #define rep4(i, a, b, c) for (int i = (ll)a; i < (ll)b; i += (ll)c) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #ifdef _DEBUG #define debug1(a) cerr << #a << ": " << a << "\n" #define debug2(a, b) cerr << #a << ": " << a << ", " << #b << ": " << b << "\n" #define debug3(a, b, c) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << "\n" #define debug4(a, b, c, d) \ cerr << #a << ": " << a << ", " << #b << ": " << b << ", " << #c << ": " \ << c << ", " << #d << ": " << d << "\n" #define debug(...) \ overload4(__VA_ARGS__, debug4, debug3, debug2, debug1)(__VA_ARGS__) #define vecout(a) \ cerr << #a << ": ["; \ rep(i, a.size()) { \ cerr << a[i]; \ cerr << (i == a.size() - 1 ? "" : ","); \ } \ cerr << "]\n" #else #define debug(...) #define vecout(a) #endif #define mp make_pair // struct doset{doset(int n){cout << fixed << setprecision(n);cerr << fixed << // setprecision(n);}}; struct // myset{myset(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}; void myset() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void doset(int n) { cout << fixed << setprecision(n); } using ll = long long; using ld = long double; using dou = double; const int inf = 1 << 30; const ll INF = 1LL << 60; const ld pi = 3.14159265358; const ll mod1 = 1000000007LL; const ll mod2 = 998244353LL; typedef pair<ll, ll> P; template <class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; } template <class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; } template <class T, class U> inline bool change(T &a, U &b) { if (a > b) { swap(a, b); return 1; } return 0; } // nのm乗をMODで割ったあまりO(logm) ll modpow(ll n, ll m, ll MOD) { if (m == 0) return 1; if (m < 0) return 0; ll res = 1; n %= MOD; while (m) { if (m & 1) res = (res * n) % MOD; m >>= 1; n *= n; n %= MOD; } return res; } ll mypow(ll n, ll m) { if (m == 0) return 1; if (m < 0) return -1; ll res = 1; while (m) { if (m & 1) res = (res * n); m >>= 1; n *= n; } return res; } //素数判定O(sqrt(N)) template <class T> inline bool isp(T n) { bool res = true; if (n == 1 || n == 0) return false; else { for (ll i = 2; i * i <= n; i++) { if (n % i == 0) { res = false; break; } } return res; } } template <class T = int> T in() { T x; cin >> x; return x; } inline bool Yes(bool b) { cout << (b ? "Yes\n" : "No\n"); return b; } inline bool YES(bool b) { cout << (b ? "YES\n" : "NO\n"); return b; } /*----------------------------------マクロここまで----------------------------------*/ ll __lcm(ll a, ll b) { return a / __gcd(a, b) * b; } int main() { myset(); ll N, K; cin >> N >> K; vector<ll> vec(N); rep(i, N) cin >> vec[i]; ll ans = 0; ll M = min(N, K); rep(i, M + 1) { //取る個数 ll push = K - i; //戻せる個数 rep(j, i + 1) { //左から取る個数 vector<ll> cho; ll R = i - j; rep(k, j) cho.emplace_back(vec[k]); for (int k = N - 1; k >= N - R; k--) { cho.emplace_back(vec[k]); } sort(all(cho)); ll cnt = 0; ll neg = 0; for (ll x : cho) { if (x < 0) { if (neg < push) { neg++; } else { cnt += x; } } else { cnt += x; } } chmax(ans, cnt); } } cout << ans << "\n"; }
[ "expression.operation.binary.add" ]
842,301
842,300
u527652459
cpp
p03032
#include "bits/stdc++.h" // region Template #include "ext/pb_ds/assoc_container.hpp" using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int MOD = 1000000007; using namespace std; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset; #define finish(x) \ cout << x; \ exit(0); #define fastIO \ cin.tie(0); \ cin.sync_with_stdio(false); void setIn(string s) { freopen(s.c_str(), "r", stdin); } void setOut(string s) { freopen(s.c_str(), "w", stdout); } // const string USCAO_TAG = "mountains"; void usaco(const string &USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); } void print() {} template <typename T, typename... Args> void print(T firstArg, Args... args) { #ifdef LOCAL cout << firstArg << "\t"; print(args...); #endif } // endregion /* Notes: * Farah </3 */ const int MAXN = 55; const ll INF = 2e18; ll a[MAXN]; int main() { #ifdef LOCAL setIn("in.txt"); setOut("out.txt"); #endif int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } ll ans = 0; for (int i = 1; i <= k; i++) { vector<ll> left, right; for (int j = 0; j < i; j++) { left.push_back(a[j]); } for (int j = -1; j < i; j++) { if (j > -1) { left.pop_back(); right.push_back(a[n - j - 1]); } vector<ll> v; for (auto x : left) v.push_back(x); for (auto x : right) v.push_back(x); sort(v.begin(), v.end()); int idx = 0; for (int q = 0; q < (int)v.size() && idx < k - i; q++) { if (v[idx] < 0) { v[idx] = 0; idx++; } } ll sum = 0; for (auto x : v) sum += x; ans = max(ans, sum); } } cout << ans; }
#include "bits/stdc++.h" // region Template #include "ext/pb_ds/assoc_container.hpp" using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int MOD = 1000000007; using namespace std; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset; #define finish(x) \ cout << x; \ exit(0); #define fastIO \ cin.tie(0); \ cin.sync_with_stdio(false); void setIn(string s) { freopen(s.c_str(), "r", stdin); } void setOut(string s) { freopen(s.c_str(), "w", stdout); } // const string USCAO_TAG = "mountains"; void usaco(const string &USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); } void print() {} template <typename T, typename... Args> void print(T firstArg, Args... args) { #ifdef LOCAL cout << firstArg << "\t"; print(args...); #endif } // endregion /* Notes: * Farah </3 */ const int MAXN = 55; const ll INF = 2e18; ll a[MAXN]; int main() { #ifdef LOCAL setIn("in.txt"); setOut("out.txt"); #endif int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; } ll ans = 0; for (int i = 1; i <= min(n, k); i++) { vector<ll> left, right; for (int j = 0; j < i; j++) { left.push_back(a[j]); } for (int j = -1; j < i; j++) { if (j > -1) { left.pop_back(); right.push_back(a[n - j - 1]); } vector<ll> v; for (auto x : left) v.push_back(x); for (auto x : right) v.push_back(x); sort(v.begin(), v.end()); int idx = 0; for (int q = 0; q < (int)v.size() && idx < k - i; q++) { if (v[idx] < 0) { v[idx] = 0; idx++; } } ll sum = 0; for (auto x : v) sum += x; ans = max(ans, sum); } } cout << ans; }
[ "control_flow.loop.for.condition.change", "call.add", "call.arguments.change" ]
842,314
842,315
u557558723
cpp
p03032
#include <bits/stdc++.h> // ver2.2.5 #define int long long #define endl "\n" #define ALL(v) (v).begin(), (v).end() #define COUNT(a, i) upper_bound(ALL(a), i) - lower_bound(ALL(a), i) #define Vi vector<int> #define VVi vector<Vi> #define Vs vector<string> #define Pii pair<int, int> #define VPii vector<Pii> #define Tiii tuple<int, int, int> #define PQi priority_queue<int> #define PQir priority_queue<int, vector<int>, greater<int>> #define pb push_back #define mp make_pair #define mt make_tuple #define itos to_string #define stoi stoll #define FI first #define SE second #define cYES cout << "YES" << endl #define cNO cout << "NO" << endl #define cYes cout << "Yes" << endl #define cNo cout << "No" << endl #define _ << ' ' << #define sortr(v) sort(v, greater<>()) #define rep(i, a, b) for (int i = a; i < b; i++) #define repeq(i, a, b) for (int i = a; i <= b; i++) #define repreq(i, a, b) for (int i = a; i >= b; i--) #define leng(n) (int)(log10(n) + 1) #define dem(a, b) ((a + b - 1) / (b)) #define Vin(a) rep(iI, 0, a.size()) cin >> a[iI] #define Vout(a) \ rep(lZ, 0, a.size() - 1) cout << a[lZ] << ' '; \ cout << a.back() << endl #define VVout(a) \ rep(lY, 0, a.size()) { Vout(a[lY]); } #define VPout(a) \ rep(lX, 0, a.size()) cout << a[lX].FI << ' ' << a[lX].SE << endl #define Verr(a) \ rep(iZ, 0, a.size() - 1) cerr << a[iZ] << ' '; \ cerr << a.back() << endl #define VVerr(a) \ rep(iY, 0, a.size()) { Verr(a[iY]); } #define VPerr(a) \ rep(iX, 0, a.size()) cerr << a[iX].FI << ' ' << a[iX].SE << endl #define INF 3000000000000000000 // 3.0*10^18(MAXの1/3くらい) #define MAX LLONG_MAX #define MOD 1000000007 // 10^9 + 7 using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } // 最大公約数gcd int lcm(int a, int b) { return a / gcd(a, b) * b; } // 最小公倍数lcm void press(auto &v) { v.erase(unique(ALL(v)), v.end()); } // 圧縮 int mypow(int x, int n, int m) { // 累乗x^n(mod m) O(log(n)) if (n == 0) return 1; if (n % 2 == 0) return mypow(x * x % m, n / 2, m); else return x * mypow(x, n - 1, m) % m; } signed main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); int n, k; cin >> n >> k; Vi a(n); Vin(a); int sum = 0, ct; int ans = 0; PQir my; repreq(i, k, 1) { PQir my; sum = 0; ct = k - i; if (i >= n) { rep(j, 0, n) { sum += a[i]; my.push(a[j]); } rep(j, 0, ct) { if (my.size() == 0) break; if (my.top() >= 0) break; sum += abs(my.top()); my.pop(); } cerr << sum << endl; ans = max(ans, sum); } else { rep(j, 0, i + 1) { PQir my; sum = 0; ct = k - i; rep(K, 0, j) { my.push(a[K]); sum += a[K]; } rep(K, 0, i - j) { my.push(a[n - 1 - K]); sum += a[n - 1 - K]; } rep(K, 0, ct) { if (my.size() == 0) break; if (my.top() >= 0) break; else { sum += abs(my.top()); my.pop(); } } cerr << sum _ k - i _ j _ i - j << endl; ans = max(ans, sum); } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> // ver2.2.5 #define int long long #define endl "\n" #define ALL(v) (v).begin(), (v).end() #define COUNT(a, i) upper_bound(ALL(a), i) - lower_bound(ALL(a), i) #define Vi vector<int> #define VVi vector<Vi> #define Vs vector<string> #define Pii pair<int, int> #define VPii vector<Pii> #define Tiii tuple<int, int, int> #define PQi priority_queue<int> #define PQir priority_queue<int, vector<int>, greater<int>> #define pb push_back #define mp make_pair #define mt make_tuple #define itos to_string #define stoi stoll #define FI first #define SE second #define cYES cout << "YES" << endl #define cNO cout << "NO" << endl #define cYes cout << "Yes" << endl #define cNo cout << "No" << endl #define _ << ' ' << #define sortr(v) sort(v, greater<>()) #define rep(i, a, b) for (int i = a; i < b; i++) #define repeq(i, a, b) for (int i = a; i <= b; i++) #define repreq(i, a, b) for (int i = a; i >= b; i--) #define leng(n) (int)(log10(n) + 1) #define dem(a, b) ((a + b - 1) / (b)) #define Vin(a) rep(iI, 0, a.size()) cin >> a[iI] #define Vout(a) \ rep(lZ, 0, a.size() - 1) cout << a[lZ] << ' '; \ cout << a.back() << endl #define VVout(a) \ rep(lY, 0, a.size()) { Vout(a[lY]); } #define VPout(a) \ rep(lX, 0, a.size()) cout << a[lX].FI << ' ' << a[lX].SE << endl #define Verr(a) \ rep(iZ, 0, a.size() - 1) cerr << a[iZ] << ' '; \ cerr << a.back() << endl #define VVerr(a) \ rep(iY, 0, a.size()) { Verr(a[iY]); } #define VPerr(a) \ rep(iX, 0, a.size()) cerr << a[iX].FI << ' ' << a[iX].SE << endl #define INF 3000000000000000000 // 3.0*10^18(MAXの1/3くらい) #define MAX LLONG_MAX #define MOD 1000000007 // 10^9 + 7 using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } // 最大公約数gcd int lcm(int a, int b) { return a / gcd(a, b) * b; } // 最小公倍数lcm void press(auto &v) { v.erase(unique(ALL(v)), v.end()); } // 圧縮 int mypow(int x, int n, int m) { // 累乗x^n(mod m) O(log(n)) if (n == 0) return 1; if (n % 2 == 0) return mypow(x * x % m, n / 2, m); else return x * mypow(x, n - 1, m) % m; } signed main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); int n, k; cin >> n >> k; Vi a(n); Vin(a); int sum = 0, ct; int ans = 0; PQir my; repreq(i, k, 1) { PQir my; sum = 0; ct = k - i; if (i >= n) { rep(j, 0, n) { sum += a[j]; my.push(a[j]); } rep(j, 0, ct) { if (my.size() == 0) break; if (my.top() >= 0) break; sum += abs(my.top()); my.pop(); } cerr << sum << endl; ans = max(ans, sum); } else { rep(j, 0, i + 1) { PQir my; sum = 0; ct = k - i; rep(K, 0, j) { my.push(a[K]); sum += a[K]; } rep(K, 0, i - j) { my.push(a[n - 1 - K]); sum += a[n - 1 - K]; } rep(K, 0, ct) { if (my.size() == 0) break; if (my.top() >= 0) break; else { sum += abs(my.top()); my.pop(); } } cerr << sum _ k - i _ j _ i - j << endl; ans = max(ans, sum); } } } cout << ans << endl; return 0; }
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change" ]
842,322
842,323
u095453583
cpp
p03032
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) #endif #define lsc(x) scanf("%lld", &x) #define sc(x) scanf("%d", &x) #define lpr(x) printf("%lld ", (long long)x) #define pr(x) printf("%d ", x) #define n_l printf("\n") #define VI vector<int> #define VII vector<long long int> #define m_p make_pair #define pb push_back #define fi first #define se second #define mset(x, y) memset(x, y, sizeof(x)) #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() #define fr(i, a, n) for (int i = a; i <= n; i++) #define FIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()); const int N = (int)1e6 + 5; const int mod = 1000000007; typedef long long ll; // order_of_key (val): returns the no. of values strictly less than val // find_by_order (k): returns the kth largest element iterator.(0-based) // vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x); // s.substr(pos[0-indexed], len(default=till end)) typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ll fmod(ll x) { if (x < mod) return x; return x % mod; } ll mul(ll a, ll b, ll c) { ll ret = 0; while (b) { if (b % 2) ret = (ret + a) % c; a = (a * 2) % c; b >>= 1; } return ret; } int modpow(ll a, ll b) { ll ret = 1; while (b) { if (b % 2) ret = (ret * a) % mod; a = (a * a) % mod; b >>= 1; } return (int)ret; } inline int inv(int x) { return modpow(x, mod - 2); } int isprime[N]; void calc_prime() { isprime[1] = 1; for (ll i = 2; i < N; i++) if (!isprime[i]) for (ll j = i * i; j < N; j += i) isprime[j] = 1; } int n; int a[N]; int solve(int i, int j, int k) { int ptrl = 1; int ptrr = n; int sz = i + j - k; set<int, greater<int>> s; while (i--) { s.insert(a[ptrl]); ptrl++; } while (j--) { s.insert(a[ptrr]); ptrr--; } // trace(i, j, k, ptrl, ptrr); // assert(ptrr - ptrl >= -1); int ret = 0; for (auto it : s) { if (sz) ret += it; else break; sz--; } return ret; } int main() { sc(n); int k; sc(k); fr(i, 1, n) sc(a[i]); int ans = 0; fr(i, 0, min(n, k)) { fr(j, 0, min(k - i, n - i)) { fr(z, 0, min(i + j, k - i - j)) { ans = max(ans, solve(i, j, z)); } } } pr(ans); return 0; }
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace std; using namespace __gnu_pbds; #define TRACE #ifdef TRACE #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char *name, Arg1 &&arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char *names, Arg1 &&arg1, Args &&...args) { const char *comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #else #define trace(...) #endif #define lsc(x) scanf("%lld", &x) #define sc(x) scanf("%d", &x) #define lpr(x) printf("%lld ", (long long)x) #define pr(x) printf("%d ", x) #define n_l printf("\n") #define VI vector<int> #define VII vector<long long int> #define m_p make_pair #define pb push_back #define fi first #define se second #define mset(x, y) memset(x, y, sizeof(x)) #define sz(v) (int)v.size() #define all(v) v.begin(), v.end() #define fr(i, a, n) for (int i = a; i <= n; i++) #define FIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()); const int N = (int)1e6 + 5; const int mod = 1000000007; typedef long long ll; // order_of_key (val): returns the no. of values strictly less than val // find_by_order (k): returns the kth largest element iterator.(0-based) // vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x); // s.substr(pos[0-indexed], len(default=till end)) typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ll fmod(ll x) { if (x < mod) return x; return x % mod; } ll mul(ll a, ll b, ll c) { ll ret = 0; while (b) { if (b % 2) ret = (ret + a) % c; a = (a * 2) % c; b >>= 1; } return ret; } int modpow(ll a, ll b) { ll ret = 1; while (b) { if (b % 2) ret = (ret * a) % mod; a = (a * a) % mod; b >>= 1; } return (int)ret; } inline int inv(int x) { return modpow(x, mod - 2); } int isprime[N]; void calc_prime() { isprime[1] = 1; for (ll i = 2; i < N; i++) if (!isprime[i]) for (ll j = i * i; j < N; j += i) isprime[j] = 1; } int n; int a[N]; int solve(int i, int j, int k) { int ptrl = 1; int ptrr = n; int sz = i + j - k; multiset<int, greater<int>> s; while (i--) { s.insert(a[ptrl]); ptrl++; } while (j--) { s.insert(a[ptrr]); ptrr--; } // trace(i, j, k, ptrl, ptrr); // assert(ptrr - ptrl >= -1); int ret = 0; for (auto it : s) { if (sz) ret += it; else break; sz--; } return ret; } int main() { sc(n); int k; sc(k); fr(i, 1, n) sc(a[i]); int ans = 0; fr(i, 0, min(n, k)) { fr(j, 0, min(k - i, n - i)) { fr(z, 0, min(i + j, k - i - j)) { ans = max(ans, solve(i, j, z)); } } } pr(ans); return 0; }
[ "variable_declaration.type.change" ]
842,348
842,349
u562608561
cpp
p03032
#include <bits/stdc++.h> using namespace ::std; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef array<int, 3> tri; typedef long double ld; template <class T> istream &operator>>(istream &I, vector<T> &v) { for (T &e : v) I >> e; return I; } template <class T> ostream &operator<<(ostream &O, const vector<T> &v) { for (const T &e : v) O << e << ' '; return O; } void _main() { int n, k; cin >> n >> k; vector<int> a(n); cin >> a; int ans = 0; for (int left = 0; left < k; left++) { for (int right = 0; right + left < min(n, k); right++) { vector<int> hand; for (int i = 0; i < left; i++) { hand.emplace_back(a[i]); } for (int i = n - 1; i >= n - right; i--) { hand.emplace_back(a[i]); } sort(all(hand), greater<>()); for (int i = 0; i < k - left - right; i++) { if (hand.size() && hand.back() < 0) hand.pop_back(); else break; } ans = max(ans, accumulate(all(hand), 0)); } } cout << ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); int _t = 1; // cin >> _t; while (_t--) _main(); return 0; }
#include <bits/stdc++.h> using namespace ::std; #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef array<int, 3> tri; typedef long double ld; template <class T> istream &operator>>(istream &I, vector<T> &v) { for (T &e : v) I >> e; return I; } template <class T> ostream &operator<<(ostream &O, const vector<T> &v) { for (const T &e : v) O << e << ' '; return O; } void _main() { int n, k; cin >> n >> k; vector<int> a(n); cin >> a; int ans = 0; for (int left = 0; left <= k; left++) { for (int right = 0; right + left <= min(n, k); right++) { vector<int> hand; for (int i = 0; i < left; i++) { hand.emplace_back(a[i]); } for (int i = n - 1; i >= n - right; i--) { hand.emplace_back(a[i]); } sort(all(hand), greater<>()); for (int i = 0; i < k - left - right; i++) { if (hand.size() && hand.back() < 0) hand.pop_back(); else break; } ans = max(ans, accumulate(all(hand), 0)); } } cout << ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("input.txt", "r", stdin); int _t = 1; // cin >> _t; while (_t--) _main(); return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,355
842,356
u093681822
cpp
p03032
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> typedef char SINT8; typedef short SINT16; typedef int SINT32; typedef long long SINT64; typedef double DOUBLE; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) #define rep(i, a, b) for (SINT64(i) = SINT64(a); (i) < SINT64(b); (i)++) #define rrep(i, a, b) for (SINT64(i) = SINT64(a); (i) >= SINT64(b); (i)--) #define put(a) cout << (a) << endl #define puts(a) cout << (a) << " " #define INF 1000000001 #define MOD 1000000007 #define INF64 1000000000000000001 #define F first #define S second #define Pii pair<SINT32, SINT32> #define Pll pair<SINT64, SINT64> #define Piii pair<SINT32, pair<SINT32, SINT32>> #define Plll pair<SINT64, pair<SINT64, SINT64>> #define Vll(a, b, c) vector<vector<SINT64>> (a)((b),vector<SINT64>((c)) #define Vlll(a, b, c, d) vector<vector<vector<SINT64>>> (a)((b),vector<vector<SINT64>>((c),vector<SINT64>((d))) using namespace std; int main() { SINT64 N; cin >> N; SINT64 K; cin >> K; SINT64 ans = 0; vector<SINT64> data(N); rep(i, 0, N) { cin >> data[i]; } rep(i, 0, MIN(N + 1, K + 1)) { rep(j, 0, MIN(N + 1, K + 1)) { if ((i + j) > MIN(N + 1, K + 1)) { break; } vector<SINT64> buf; SINT64 bans = 0; rep(k, 0, i) { buf.emplace_back(data[k]); } rep(k, 0, j) { buf.emplace_back(data[N - k - 1]); } sort(buf.begin(), buf.end()); /* rep(k,0,buf.size()) { puts(buf[k]); } cout << endl; */ rep(k, 0, buf.size()) { if ((buf[k] < 0) && (k < K - i - j)) { continue; } bans += buf[k]; } ans = MAX(ans, bans); } } put(ans); return 0; } // vector<vector<SINT64>> data(N,vector<SINT32>(3)); ////2次元配列 vector<vector<vector<SINT64>>> //data(N,vector<vector<SINT64>>(3,vector<SINT64>(3))); //3次元配列 // Vll(data,N,N); //2次元配列 // Vlll(data,N,N,N); //3次元配列 // sort(data.begin(),data.end()); // sort(data.begin(),data.end(),std::greater<SINT64>()); // __gcd(A,B); //関数へのvectorポインタ渡し // void dfs(SINT64 poi, SINT64 d, vector<vector<Pll>>& data) { //} /* 複数条件ソート bool sortcompare(Pll A, Pll B) { if(A.F == B.F){ return A.S > B.S; } else { return A.F < B.F; } } sort(data.begin(),data.end(),sortcompare); */ // タプル // vector<tuple<SINT64,SINT64,SINT64>> edges; // edges.emplace_back(a,b,c); // cout << get<0>(edges[i]); // cout << get<1>(edges[i]); // cout << get<2>(edges[i]); // sort(begin(edges), end(edges)); //ソート // data.emplace_back(BUF); //後ろに追加 // data.erase(std::unique(data.begin(), data.end()), data.end()); // //ソート後に使用 同じ値を消す // data.insert(data.begin() + X, 0); //X番目の要素に0を挿入 // 隣接リスト // vector<vector<SINT64>> data(N); // data[ A ].emplace_back( B ); /* vector<Pll> data(N); rep(i,0,N) { cin >> data[i].F; cin >> data[i].S; } sort(data.begin(),data.end()); */ /* vector<Plll> data(N); rep(i,0,N) { cin >> data[i].F; cin >> data[i].S.F; cin >> data[i].S.S; } sort(data.begin(),data.end()); */ // lower_boundは値がなければ最大値(.size())を返す // posi = lower_bound(data.begin(),data.end(), X) - data.begin(); // // X以上を探す posi = lower_bound(data.begin(),data.end(),make_pair(X,0)) - // data.begin(); //pair /* 文字列回転 string N; cin >> N; N = N[N.length()-1] + N.substr(0,N.length()-1); s = to_string(i); //ストリング変換 */ /* 文字列合成 string N,M; cin >> N >> M; SINT64 ans = 0; ans = stoi(N+M); */ /* //ワーシャルフロイド vector<vector<SINT32>> dist(N,vector<SINT32>(N)); rep(i,0,N) { rep(j,0,N) { if (i != j) { dist[i][j] = INF; } } } rep(k,0,N) { rep(i,0,N) { rep(j,0,N) { dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]); } } } */ /* 優先度付きキュー priority_queue<SINT64, vector<SINT64>, greater<SINT64>> bufq; //小さいほうから取り出せる priority_queue<SINT64, vector<SINT64>> bufq; //大きいほうから取り出せる bufq.push(X); //X を挿入 bufq.top(); //先頭データ読み bufq.pop(); //先頭データ削除 */ /* キュー queue<SINT64> bufq; //宣言 bufq.push(0); //挿入 bufq.front(); //先頭データ読み bufq.pop(); //先頭データ削除 */ /* SET コンテナ set<SINT64> data; data.insert(X); //X を挿入 data.erase(data.begin()); //先頭を削除 data.erase(--data.end()); //末尾を削除 *data.begin(); //先頭要素にアクセス *data.rbegin(); //末尾要素にアクセス //全表示 set<SINT64>::iterator it; //イテレータを用意 for(it = data.begin(); it != data.end(); it++) { cout << *it << " "; } cout << endl; //N番目を一部表示 set<SINT64>::iterator it; // イテレータを用意 it = data.begin(); rep (i,0,N) { it++; } cout << *it << endl; */ /* map map<string,SINT32> mp; SINT32 N = 0; SINT32 mx = 0; cin >> N; for (SINT32 i = 0; i < N; i++) { string s; cin >> s; mp[s]++; } for(auto it=mp.begin();it!=mp.end();it++) { mx=max(mx,it->second); } */ /* //順列全表示 //sortしてからでないと全列挙にならない sort(data.begin(),data.end()); do { cout << buf << endl; rep(i,0,R) { cout << data[i] << " "; } cout << endl; } while (next_permutation(data.begin(),data.end())); */ /* bit数数え上げ SINT64 bits64(SINT64 bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } */ // 桁指定表示 // ans = ans * M_PI; // cout << setprecision(15) << ans << endl; // 逆元 コンビネーション /* SINT64 modpow(SINT64 a, SINT64 p) { if (p == 0) return 1; if (p % 2 == 0) { //pが偶数の時 SINT64 halfP = p / 2; SINT64 half = modpow(a, halfP); //a^(p/2) をhalfとして、half*halfを計算 return half * half % MOD; } else { //pが奇数の時は、偶数にするために1減らす return a * modpow(a, p - 1) % MOD; } } SINT64 calcComb(SINT64 a, SINT64 b) { SINT64 Mul = 1; SINT64 Div = 1; SINT64 ans = 0; if (b > a - b) { return calcComb(a, a - b); } rep(i,0,b) { Mul *= (a - i); Div *= (i + 1); Mul %= MOD; Div %= MOD; } ans = Mul * modpow(Div, MOD - 2) % MOD; return ans; } */ /* UNION FIND class UnionFind { public: vector<SINT64> parent; UnionFind(SINT64 N) { parent = vector<SINT64>(N+10, -1); //少し多めに } SINT64 root(SINT64 A) { if (parent[A] < 0) { return A; } else { parent[A] = root(parent[A]); return parent[A]; } } SINT64 size(SINT64 A) { return parent[root(A)] * (-1); } bool judge(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A == B) { return true; //同じグループ } else { return false; //違うグループ } } void connect(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A != B) { if (size(A) < size(B)) { swap(A, B); } parent[A] += parent[B]; parent[B] = A; } } }; UnionFind uni(N); */ /* class SegTree { private: SINT64 size; vector<SINT64> node; SINT64 jugdement(SINT64 a, SINT64 b) { SINT64 ans = 0; ans = a+b; return ans; } public: //コンストラクタ SegTree(vector<SINT64> data) { SINT64 ori_size; ori_size = data.size(); size = 1; while (size < ori_size) { size *= 2; } node.resize(2*size-1, 0); rep(i,0,ori_size) { node[size-1+i] = data[i]; } rrep(i,size-2,0) { node[i] = jugdement(node[2*i+1], node[2*i+2]); } } //データ更新 void update(SINT64 x, SINT64 val) { x += (size - 1); node[x] = val+node[x]; while(x > 0) { x = (x - 1) / 2; node[x] = jugdement(node[2*x+1], node[2*x+2]); } } //データ取得 [a,b) SINT64 getdata(SINT64 a, SINT64 b, SINT64 k = 0, SINT64 l = 0, SINT64 r = -1) { if (r < 0) { r = size; } //要求範囲外 if ((r <= a) || (b <= l)) { return 0; } //完全要求区間内 if ((a <= l) && (r <= b)) { return node[k]; } SINT64 vl = getdata(a, b, 2*k+1, l, (l+r)/2); SINT64 vr = getdata(a, b, 2*k+2, (l+r)/2, r); return jugdement(vl, vr); } //表示 void disp() { rep(i,0,size) { puts(node[size-1+i]); } cout << endl; } void alldisp() { SINT64 cnt = 0; SINT64 end = 2; while (1) { puts(node[cnt]); if (cnt == end-2) { end *= 2; cout << endl; } cnt++; if (cnt == size*2-1) { break; } } } }; SegTree seg(N); */
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <vector> typedef char SINT8; typedef short SINT16; typedef int SINT32; typedef long long SINT64; typedef double DOUBLE; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) #define rep(i, a, b) for (SINT64(i) = SINT64(a); (i) < SINT64(b); (i)++) #define rrep(i, a, b) for (SINT64(i) = SINT64(a); (i) >= SINT64(b); (i)--) #define put(a) cout << (a) << endl #define puts(a) cout << (a) << " " #define INF 1000000001 #define MOD 1000000007 #define INF64 1000000000000000001 #define F first #define S second #define Pii pair<SINT32, SINT32> #define Pll pair<SINT64, SINT64> #define Piii pair<SINT32, pair<SINT32, SINT32>> #define Plll pair<SINT64, pair<SINT64, SINT64>> #define Vll(a, b, c) vector<vector<SINT64>> (a)((b),vector<SINT64>((c)) #define Vlll(a, b, c, d) vector<vector<vector<SINT64>>> (a)((b),vector<vector<SINT64>>((c),vector<SINT64>((d))) using namespace std; int main() { SINT64 N; cin >> N; SINT64 K; cin >> K; SINT64 ans = 0; vector<SINT64> data(N); rep(i, 0, N) { cin >> data[i]; } rep(i, 0, MIN(N + 1, K + 1)) { rep(j, 0, MIN(N + 1, K + 1)) { if ((i + j) > MIN(N, K)) { break; } vector<SINT64> buf; SINT64 bans = 0; rep(k, 0, i) { buf.emplace_back(data[k]); } rep(k, 0, j) { buf.emplace_back(data[N - k - 1]); } sort(buf.begin(), buf.end()); // rep(k,0,buf.size()) { // puts(buf[k]); // } cout << endl; rep(k, 0, buf.size()) { if ((buf[k] < 0) && (k < K - i - j)) { continue; } bans += buf[k]; } ans = MAX(ans, bans); } } put(ans); return 0; } // vector<vector<SINT64>> data(N,vector<SINT32>(3)); ////2次元配列 vector<vector<vector<SINT64>>> //data(N,vector<vector<SINT64>>(3,vector<SINT64>(3))); //3次元配列 // Vll(data,N,N); //2次元配列 // Vlll(data,N,N,N); //3次元配列 // sort(data.begin(),data.end()); // sort(data.begin(),data.end(),std::greater<SINT64>()); // __gcd(A,B); //関数へのvectorポインタ渡し // void dfs(SINT64 poi, SINT64 d, vector<vector<Pll>>& data) { //} /* 複数条件ソート bool sortcompare(Pll A, Pll B) { if(A.F == B.F){ return A.S > B.S; } else { return A.F < B.F; } } sort(data.begin(),data.end(),sortcompare); */ // タプル // vector<tuple<SINT64,SINT64,SINT64>> edges; // edges.emplace_back(a,b,c); // cout << get<0>(edges[i]); // cout << get<1>(edges[i]); // cout << get<2>(edges[i]); // sort(begin(edges), end(edges)); //ソート // data.emplace_back(BUF); //後ろに追加 // data.erase(std::unique(data.begin(), data.end()), data.end()); // //ソート後に使用 同じ値を消す // data.insert(data.begin() + X, 0); //X番目の要素に0を挿入 // 隣接リスト // vector<vector<SINT64>> data(N); // data[ A ].emplace_back( B ); /* vector<Pll> data(N); rep(i,0,N) { cin >> data[i].F; cin >> data[i].S; } sort(data.begin(),data.end()); */ /* vector<Plll> data(N); rep(i,0,N) { cin >> data[i].F; cin >> data[i].S.F; cin >> data[i].S.S; } sort(data.begin(),data.end()); */ // lower_boundは値がなければ最大値(.size())を返す // posi = lower_bound(data.begin(),data.end(), X) - data.begin(); // // X以上を探す posi = lower_bound(data.begin(),data.end(),make_pair(X,0)) - // data.begin(); //pair /* 文字列回転 string N; cin >> N; N = N[N.length()-1] + N.substr(0,N.length()-1); s = to_string(i); //ストリング変換 */ /* 文字列合成 string N,M; cin >> N >> M; SINT64 ans = 0; ans = stoi(N+M); */ /* //ワーシャルフロイド vector<vector<SINT32>> dist(N,vector<SINT32>(N)); rep(i,0,N) { rep(j,0,N) { if (i != j) { dist[i][j] = INF; } } } rep(k,0,N) { rep(i,0,N) { rep(j,0,N) { dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]); } } } */ /* 優先度付きキュー priority_queue<SINT64, vector<SINT64>, greater<SINT64>> bufq; //小さいほうから取り出せる priority_queue<SINT64, vector<SINT64>> bufq; //大きいほうから取り出せる bufq.push(X); //X を挿入 bufq.top(); //先頭データ読み bufq.pop(); //先頭データ削除 */ /* キュー queue<SINT64> bufq; //宣言 bufq.push(0); //挿入 bufq.front(); //先頭データ読み bufq.pop(); //先頭データ削除 */ /* SET コンテナ set<SINT64> data; data.insert(X); //X を挿入 data.erase(data.begin()); //先頭を削除 data.erase(--data.end()); //末尾を削除 *data.begin(); //先頭要素にアクセス *data.rbegin(); //末尾要素にアクセス //全表示 set<SINT64>::iterator it; //イテレータを用意 for(it = data.begin(); it != data.end(); it++) { cout << *it << " "; } cout << endl; //N番目を一部表示 set<SINT64>::iterator it; // イテレータを用意 it = data.begin(); rep (i,0,N) { it++; } cout << *it << endl; */ /* map map<string,SINT32> mp; SINT32 N = 0; SINT32 mx = 0; cin >> N; for (SINT32 i = 0; i < N; i++) { string s; cin >> s; mp[s]++; } for(auto it=mp.begin();it!=mp.end();it++) { mx=max(mx,it->second); } */ /* //順列全表示 //sortしてからでないと全列挙にならない sort(data.begin(),data.end()); do { cout << buf << endl; rep(i,0,R) { cout << data[i] << " "; } cout << endl; } while (next_permutation(data.begin(),data.end())); */ /* bit数数え上げ SINT64 bits64(SINT64 bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } */ // 桁指定表示 // ans = ans * M_PI; // cout << setprecision(15) << ans << endl; // 逆元 コンビネーション /* SINT64 modpow(SINT64 a, SINT64 p) { if (p == 0) return 1; if (p % 2 == 0) { //pが偶数の時 SINT64 halfP = p / 2; SINT64 half = modpow(a, halfP); //a^(p/2) をhalfとして、half*halfを計算 return half * half % MOD; } else { //pが奇数の時は、偶数にするために1減らす return a * modpow(a, p - 1) % MOD; } } SINT64 calcComb(SINT64 a, SINT64 b) { SINT64 Mul = 1; SINT64 Div = 1; SINT64 ans = 0; if (b > a - b) { return calcComb(a, a - b); } rep(i,0,b) { Mul *= (a - i); Div *= (i + 1); Mul %= MOD; Div %= MOD; } ans = Mul * modpow(Div, MOD - 2) % MOD; return ans; } */ /* UNION FIND class UnionFind { public: vector<SINT64> parent; UnionFind(SINT64 N) { parent = vector<SINT64>(N+10, -1); //少し多めに } SINT64 root(SINT64 A) { if (parent[A] < 0) { return A; } else { parent[A] = root(parent[A]); return parent[A]; } } SINT64 size(SINT64 A) { return parent[root(A)] * (-1); } bool judge(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A == B) { return true; //同じグループ } else { return false; //違うグループ } } void connect(SINT64 A, SINT64 B) { A = root(A); B = root(B); if (A != B) { if (size(A) < size(B)) { swap(A, B); } parent[A] += parent[B]; parent[B] = A; } } }; UnionFind uni(N); */ /* class SegTree { private: SINT64 size; vector<SINT64> node; SINT64 jugdement(SINT64 a, SINT64 b) { SINT64 ans = 0; ans = a+b; return ans; } public: //コンストラクタ SegTree(vector<SINT64> data) { SINT64 ori_size; ori_size = data.size(); size = 1; while (size < ori_size) { size *= 2; } node.resize(2*size-1, 0); rep(i,0,ori_size) { node[size-1+i] = data[i]; } rrep(i,size-2,0) { node[i] = jugdement(node[2*i+1], node[2*i+2]); } } //データ更新 void update(SINT64 x, SINT64 val) { x += (size - 1); node[x] = val+node[x]; while(x > 0) { x = (x - 1) / 2; node[x] = jugdement(node[2*x+1], node[2*x+2]); } } //データ取得 [a,b) SINT64 getdata(SINT64 a, SINT64 b, SINT64 k = 0, SINT64 l = 0, SINT64 r = -1) { if (r < 0) { r = size; } //要求範囲外 if ((r <= a) || (b <= l)) { return 0; } //完全要求区間内 if ((a <= l) && (r <= b)) { return node[k]; } SINT64 vl = getdata(a, b, 2*k+1, l, (l+r)/2); SINT64 vr = getdata(a, b, 2*k+2, (l+r)/2, r); return jugdement(vl, vr); } //表示 void disp() { rep(i,0,size) { puts(node[size-1+i]); } cout << endl; } void alldisp() { SINT64 cnt = 0; SINT64 end = 2; while (1) { puts(node[cnt]); if (cnt == end-2) { end *= 2; cout << endl; } cnt++; if (cnt == size*2-1) { break; } } } }; SegTree seg(N); */
[ "expression.operation.binary.remove" ]
842,363
842,362
u824905100
cpp
p03032
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <numeric> // accumulate(v.begin(), v.end(), 0) #include <vector> using namespace std; #define ll long long int main() { int N, K; cin >> N >> K; vector<ll> V(N); for (int i = 0; i < N; i++) cin >> V[i]; ll ans = 0; for (int i = 0; i < min(N, K); i++) { for (int j = 0; j < min(N, K) - i; j++) { vector<ll> tmp(i); copy(V.begin(), V.begin() + i, tmp.begin()); vector<ll> tmp2(j); copy(V.end() - j, V.end(), tmp2.begin()); tmp.insert(tmp.end(), tmp2.begin(), tmp2.end()); // for(int k=0; k<tmp.size(); k++) // cout << tmp[k] << ' '; // cout << endl; sort(tmp.begin(), tmp.end()); int tmp3 = lower_bound(tmp.begin(), tmp.end(), 0) - tmp.begin(); ans = max(ans, accumulate(tmp.begin() + min(tmp3, K - i - j), tmp.end(), 0LL)); } } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdlib> #include <iostream> #include <numeric> // accumulate(v.begin(), v.end(), 0) #include <vector> using namespace std; #define ll long long int main() { int N, K; cin >> N >> K; vector<ll> V(N); for (int i = 0; i < N; i++) cin >> V[i]; ll ans = 0; for (int i = 0; i <= min(N, K); i++) { for (int j = 0; j <= min(N, K) - i; j++) { vector<ll> tmp(i); copy(V.begin(), V.begin() + i, tmp.begin()); vector<ll> tmp2(j); copy(V.end() - j, V.end(), tmp2.begin()); tmp.insert(tmp.end(), tmp2.begin(), tmp2.end()); // for(int k=0; k<tmp.size(); k++) // cout << tmp[k] << ' '; // cout << endl; sort(tmp.begin(), tmp.end()); int tmp3 = lower_bound(tmp.begin(), tmp.end(), 0) - tmp.begin(); ans = max(ans, accumulate(tmp.begin() + min(tmp3, K - i - j), tmp.end(), 0LL)); } } cout << ans << endl; return 0; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,364
842,365
u137747137
cpp
p03032
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i, n) for (int i = 0; i < (int)n; ++i) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << "(" << v.first << ", " << v.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << " "; } os << v[i]; } return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << endl; } os << v[i]; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, K; cin >> N >> K; vector<ll> V(N); REP(i, N) cin >> V[i]; ll ma = -1; REP(i, K) { REP(j, K) { // dump(i) // dump(j) if (i + j > K || i + j > N) continue; ll res = 0; ll nokori = K - i - j; vector<ll> deteru; REP(k, i) { deteru.push_back(V[k]); // dump(V[k]) res += V[k]; } REP(k, j) { deteru.push_back(V[N - 1 - k]); // dump(V[N-1-k]) res += V[N - 1 - k]; } sort(deteru.begin(), deteru.end()); REP(k, min(nokori, (ll)deteru.size())) { if (deteru[k] < 0) res -= deteru[k]; } // dump(res) ma = max(res, ma); } } cout << ma << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i, n) for (int i = 0; i < (int)n; ++i) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << "(" << v.first << ", " << v.second << ")"; return os; } template <class T> ostream &operator<<(ostream &os, const vector<T> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << " "; } os << v[i]; } return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> v) { for (int i = 0; i < v.size(); i++) { if (i > 0) { os << endl; } os << v[i]; } return os; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, K; cin >> N >> K; vector<ll> V(N); REP(i, N) cin >> V[i]; ll ma = -1; REP(i, K + 1) { REP(j, K + 1) { // dump(i) // dump(j) if (i + j > K || i + j > N) continue; ll res = 0; ll nokori = K - i - j; vector<ll> deteru; REP(k, i) { deteru.push_back(V[k]); // dump(V[k]) res += V[k]; } REP(k, j) { deteru.push_back(V[N - 1 - k]); // dump(V[N-1-k]) res += V[N - 1 - k]; } sort(deteru.begin(), deteru.end()); REP(k, min(nokori, (ll)deteru.size())) { if (deteru[k] < 0) res -= deteru[k]; } // dump(res) ma = max(res, ma); } } cout << ma << endl; return 0; }
[ "expression.operation.binary.add" ]
842,368
842,369
u895971408
cpp
p03032
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; const ll MOD = 1e9 + 7; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (int i = num, i##_len = (n); i < i##_len; ++i) 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; } template <class T> inline void add(T &a, T b) { a = ((a + b) % MOD + MOD) % MOD; }; #define print(x) (cout << (x) << endl) #define pb push_back #define mp make_pair #define sz(x) int(x.size()) template <class T> inline void Yes(T condition) { if (condition) cout << "Yes" << endl; else cout << "No" << endl; } template <class itr> void cins(itr first, itr last) { for (auto i = first; i != last; i++) { cin >> (*i); } } template <class itr> void array_output(itr start, itr goal) { string ans; for (auto i = start; i != goal; i++) ans += to_string(*i) + " "; if (!ans.empty()) ans.pop_back(); cout << ans << endl; } #define fs first #define sc second const int INF = 1e9; const ll LLINF = 1e16; template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value != 0>::type fill_v(U &u, const V... v) { u = U(v...); } template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value == 0>::type fill_v(U &u, const V... v) { for (auto &e : u) fill_v<T>(e, v...); } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T ngcd(vector<T> a) { T res; res = a[0]; for (int i = 1; i < a.size() && res != 1; i++) { res = gcd(a[i], res); } return res; } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> T nlcm(vector<T> numbers) { T res; res = numbers[0]; for (int i = 1; i < numbers.size(); i++) { res = lcm(res, numbers[i]); } return res; } // 素数判定 template <typename T> bool isPrime(T x) { T i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } // 桁和 template <typename T> T digsum(T n) { T res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } // 回文判定 bool kai(string s) { string t{s}; reverse(begin(t), end(t)); return s == t; }; // 指定した文字cが文字列に何文字入ってるか ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } // 割り算の切り上げ処理 template <typename T> T rp(T a, T b) { return (a + b - 1) / b; } using pint = pair<int, int>; using pll = pair<ll, ll>; int main(void) { cout.tie(0); cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); ll n, k; cin >> n >> k; vector<ll> v(n); cins(all(v)); ll ans = 0; rep(l, k) { rep(r, k - l) { if (l + r > n) continue; ll d = k - l - r; ll sum = 0; vector<ll> s; rep(i, l) { sum += v[i]; s.pb(v[i]); } REP(i, n - r, n) { sum += v[i]; s.pb(v[i]); } sort(all(s)); rep(i, d) { if (i >= s.size()) break; if (s[i] > 0) break; sum -= s[i]; } chmax(ans, sum); } } print(ans); }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; const ll MOD = 1e9 + 7; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (int i = num, i##_len = (n); i < i##_len; ++i) 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; } template <class T> inline void add(T &a, T b) { a = ((a + b) % MOD + MOD) % MOD; }; #define print(x) (cout << (x) << endl) #define pb push_back #define mp make_pair #define sz(x) int(x.size()) template <class T> inline void Yes(T condition) { if (condition) cout << "Yes" << endl; else cout << "No" << endl; } template <class itr> void cins(itr first, itr last) { for (auto i = first; i != last; i++) { cin >> (*i); } } template <class itr> void array_output(itr start, itr goal) { string ans; for (auto i = start; i != goal; i++) ans += to_string(*i) + " "; if (!ans.empty()) ans.pop_back(); cout << ans << endl; } #define fs first #define sc second const int INF = 1e9; const ll LLINF = 1e16; template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value != 0>::type fill_v(U &u, const V... v) { u = U(v...); } template <typename T, typename U, typename... V> typename enable_if<is_same<T, U>::value == 0>::type fill_v(U &u, const V... v) { for (auto &e : u) fill_v<T>(e, v...); } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T ngcd(vector<T> a) { T res; res = a[0]; for (int i = 1; i < a.size() && res != 1; i++) { res = gcd(a[i], res); } return res; } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <typename T> T nlcm(vector<T> numbers) { T res; res = numbers[0]; for (int i = 1; i < numbers.size(); i++) { res = lcm(res, numbers[i]); } return res; } // 素数判定 template <typename T> bool isPrime(T x) { T i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) if (x % i == 0) return 0; return 1; } // 桁和 template <typename T> T digsum(T n) { T res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; } // 回文判定 bool kai(string s) { string t{s}; reverse(begin(t), end(t)); return s == t; }; // 指定した文字cが文字列に何文字入ってるか ll stringcount(string s, char c) { return count(s.cbegin(), s.cend(), c); } // 割り算の切り上げ処理 template <typename T> T rp(T a, T b) { return (a + b - 1) / b; } using pint = pair<int, int>; using pll = pair<ll, ll>; int main(void) { cout.tie(0); cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); ll n, k; cin >> n >> k; vector<ll> v(n); cins(all(v)); ll ans = 0; rep(l, k + 1) { rep(r, k - l + 1) { if (l + r > n) continue; ll d = k - l - r; ll sum = 0; vector<ll> s; rep(i, l) { sum += v[i]; s.pb(v[i]); } REP(i, n - r, n) { sum += v[i]; s.pb(v[i]); } sort(all(s)); rep(i, d) { if (i >= s.size()) break; if (s[i] > 0) break; sum -= s[i]; } chmax(ans, sum); } } print(ans); }
[ "expression.operation.binary.add" ]
842,375
842,376
u135572611
cpp
p03032
#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, K; cin >> N >> K; vector<int> v(N); for (int i = 0; i < N; i++) cin >> v[i]; int maxV = 0; for (int l = 0; l <= K; l++) { for (int r = 0; r <= K; r++) { int outNum = l + r; if (outNum > N) continue; int rest = K - outNum; vector<int> hand; hand.insert(hand.end(), v.begin(), v.begin() + l); hand.insert(hand.end(), v.rbegin(), v.rbegin() + r); sort(hand.begin(), hand.end()); int tmp = 0; for (int i = 0; i < outNum; i++) { if (i < rest && hand[i] < 0) continue; tmp += hand[i]; } maxV = max(tmp, maxV); } } cout << maxV << '\n'; }
#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, K; cin >> N >> K; vector<int> v(N); for (int i = 0; i < N; i++) cin >> v[i]; int maxV = 0; for (int l = 0; l <= K; l++) { for (int r = 0; r <= K; r++) { int outNum = l + r; if (outNum > min(N, K)) continue; int rest = K - outNum; vector<int> hand; hand.insert(hand.end(), v.begin(), v.begin() + l); hand.insert(hand.end(), v.rbegin(), v.rbegin() + r); sort(hand.begin(), hand.end()); int tmp = 0; for (int i = 0; i < outNum; i++) { if (i < rest && hand[i] < 0) continue; tmp += hand[i]; } maxV = max(tmp, maxV); } } cout << maxV << '\n'; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "call.add", "call.arguments.add" ]
842,383
842,384
u603234915
cpp
p03032
#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, K; cin >> N >> K; vector<ll> v(N); for (int i = 0; i < N; i++) cin >> v[i]; ll maxV = 0; for (int l = 0; l <= K; l++) { for (int r = 0; r <= K; r++) { int outNum = l + r; if (outNum > N) continue; int rest = K - outNum; vector<int> hand; hand.insert(hand.end(), v.begin(), v.begin() + l); hand.insert(hand.end(), v.rbegin(), v.rbegin() + r); sort(hand.begin(), hand.end()); ll tmp = 0; for (int i = 0; i < outNum; i++) { if (i < rest && hand[i] < 0) continue; tmp += hand[i]; } maxV = max(tmp, maxV); } } cout << maxV << '\n'; }
#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, K; cin >> N >> K; vector<ll> v(N); for (int i = 0; i < N; i++) cin >> v[i]; ll maxV = 0; for (int l = 0; l <= K; l++) { for (int r = 0; r <= K; r++) { int outNum = l + r; if (outNum > min(N, K)) continue; int rest = K - outNum; vector<int> hand; hand.insert(hand.end(), v.begin(), v.begin() + l); hand.insert(hand.end(), v.rbegin(), v.rbegin() + r); sort(hand.begin(), hand.end()); ll tmp = 0; for (int i = 0; i < outNum; i++) { if (i < rest && hand[i] < 0) continue; tmp += hand[i]; } maxV = max(tmp, maxV); } } cout << maxV << '\n'; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "call.add", "call.arguments.add" ]
842,385
842,386
u603234915
cpp
p03032
#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, K; cin >> N >> K; vector<ll> v(N); for (int i = 0; i < N; i++) cin >> v[i]; ll maxV = 0; for (int l = 0; l <= K; l++) { for (int r = 0; r <= K; r++) { int outNum = l + r; if (outNum > N) continue; int rest = K - outNum; vector<int> hand; hand.insert(hand.end(), v.begin(), v.begin() + l); hand.insert(hand.end(), v.rbegin(), v.rbegin() + r); sort(hand.begin(), hand.end()); ll tmp = 0; for (int i = 0; i < outNum; i++) { if (i < rest && hand[i] < 0) continue; tmp += hand[i]; } maxV = max(tmp, maxV); } } cout << maxV << '\n'; }
#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, K; cin >> N >> K; vector<ll> v(N); for (int i = 0; i < N; i++) cin >> v[i]; ll maxV = 0; for (int l = 0; l <= K; l++) { for (int r = 0; r <= K; r++) { int outNum = l + r; if (outNum > N || outNum > K) continue; int rest = K - outNum; vector<int> hand; hand.insert(hand.end(), v.begin(), v.begin() + l); hand.insert(hand.end(), v.rbegin(), v.rbegin() + r); sort(hand.begin(), hand.end()); ll tmp = 0; for (int i = 0; i < outNum; i++) { if (i < rest && hand[i] < 0) continue; tmp += hand[i]; } maxV = max(tmp, maxV); } } cout << maxV << '\n'; }
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change" ]
842,385
842,387
u603234915
cpp
p03032
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++) #define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--) #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 eb emplace_back using ll = long long; using vll = vector<ll>; using vi = vector<int>; using vvi = vector<vector<int>>; using P = pair<int, int>; template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } void Main() { int n, k; cin >> n >> k; vi v(n), l(k, 0), r(k, 0); rep(i, n) { cin >> v[i]; } ll ans = 0; rep3(l, 0, min(n - 1, k)) { rep3(r, 0, min(n - 1, k - l)) { int x = k - (l + r); ll tot = 0; vi vtmp; rep(i, l) { vtmp.pb(v[i]); tot += v[i]; } rep(i, r) { vtmp.pb(v[n - i - 1]); tot += v[n - i - 1]; } sort(all(vtmp)); int sz = vtmp.size(); rep(i, min(sz, x)) { if (vtmp[i] < 0) tot -= vtmp[i]; } chmax(ans, tot); } } cout << ans << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++) #define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--) #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 eb emplace_back using ll = long long; using vll = vector<ll>; using vi = vector<int>; using vvi = vector<vector<int>>; using P = pair<int, int>; template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } void Main() { int n, k; cin >> n >> k; vll v(n), l(k, 0), r(k, 0); rep(i, n) { cin >> v[i]; } ll ans = 0; rep3(l, 0, min(n - 1, k)) { rep3(r, 0, min(n - l, k - l)) { int x = k - (l + r); ll tot = 0; vll vtmp; rep(i, l) { vtmp.pb(v[i]); tot += v[i]; } rep(i, r) { vtmp.pb(v[n - i - 1]); tot += v[n - i - 1]; } sort(all(vtmp)); int sz = vtmp.size(); rep(i, min(sz, x)) { if (vtmp[i] < 0) tot -= vtmp[i]; } chmax(ans, tot); } } cout << ans << endl; return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }
[ "variable_declaration.type.change", "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "expression.operation.binary.change" ]
842,396
842,397
u103557284
cpp
p03032
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> using pv = vector<pair<T, U>>; template <typename T> using matrix = vector<vector<T>>; template <typename T> using pque = priority_queue<T>; template <typename T> using lpque = priority_queue<T, vector<T>, greater<T>>; using ll = long long; using intpair = pair<int, int>; using llpair = pair<ll, ll>; using ilpair = pair<int, ll>; using lipair = pair<ll, int>; using intvec = vector<int>; using llvec = vector<ll>; using intq = queue<int>; using llq = queue<ll>; using intmat = vector<intvec>; using llmat = vector<llvec>; #define PI 3.141592653589793 #define INTINF ((1 << 30) - 1) #define LLINF ((1LL << 62) - 1) #define MPRIME 1000000007 #define MPRIME9 998244353 #define MMPRIME ((1ll << 61) - 1) #define len length() #define pushb push_back #define fi first #define se second #define setpr fixed << setprecision(15) #define all(name) name.begin(), name.end() #define rall(name) name.rbegin(), name.rend() #define gsort(vbeg, vend) sort(vbeg, vend, greater<>()) 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; } template <class T> inline void init(T &v) { for (auto &a : v) cin >> a; } template <class T, class U> inline void init(vector<pair<T, U>> &v) { for (auto &a : v) cin >> a.first >> a.second; } template <class T, class N> inline void init(T &v, N n) { v.resize(n); for (auto &a : v) cin >> a; } template <class T, class U, class N> inline void init(vector<pair<T, U>> &v, N n) { v.resize(n); for (auto &a : v) cin >> a.first >> a.second; } inline void out() { cout << endl; } template <class T, class... U> inline void out(T a, U... alist) { cout << a << " "; out(forward<U>(alist)...); } template <class N> void resiz(N n) { // empty } template <class N, class T, class... U> void resiz(N n, T &&hd, U &&...tl) { hd.resize(n); resiz(n, forward<U>(tl)...); } bool isout(int h, int w, int H, int W) { return (h < 0 || h >= H || w < 0 || w >= W); } ll binpow(ll a, ll ex, ll p) { ll result = 1; while (ex > 0) { if (ex & 1) result = result * a % p; ex >>= 1; a = a * a % p; } return result; } int N, K; intvec V; int ans = 0; void input() { cin >> N >> K; init(V, N); } void solve() { for (int l = 0; l < N; l++) for (int r = N; N - (r - l) <= K; r--) { intvec tmp = intvec(V.begin(), V.begin() + l); copy(V.begin() + r, V.end(), back_inserter(tmp)); sort(all(tmp)); int k = K - N + (r - l), tmpans = 0; for (int i = 0; i < tmp.size(); i++) { if (tmp[i] < 0 && k > 0) { k--; continue; } tmpans += tmp[i]; } chmax(ans, tmpans); } cout << ans << endl; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); int t = 1; while (t) { input(); solve(); t--; } }
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> using pv = vector<pair<T, U>>; template <typename T> using matrix = vector<vector<T>>; template <typename T> using pque = priority_queue<T>; template <typename T> using lpque = priority_queue<T, vector<T>, greater<T>>; using ll = long long; using intpair = pair<int, int>; using llpair = pair<ll, ll>; using ilpair = pair<int, ll>; using lipair = pair<ll, int>; using intvec = vector<int>; using llvec = vector<ll>; using intq = queue<int>; using llq = queue<ll>; using intmat = vector<intvec>; using llmat = vector<llvec>; #define PI 3.141592653589793 #define INTINF ((1 << 30) - 1) #define LLINF ((1LL << 62) - 1) #define MPRIME 1000000007 #define MPRIME9 998244353 #define MMPRIME ((1ll << 61) - 1) #define len length() #define pushb push_back #define fi first #define se second #define setpr fixed << setprecision(15) #define all(name) name.begin(), name.end() #define rall(name) name.rbegin(), name.rend() #define gsort(vbeg, vend) sort(vbeg, vend, greater<>()) 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; } template <class T> inline void init(T &v) { for (auto &a : v) cin >> a; } template <class T, class U> inline void init(vector<pair<T, U>> &v) { for (auto &a : v) cin >> a.first >> a.second; } template <class T, class N> inline void init(T &v, N n) { v.resize(n); for (auto &a : v) cin >> a; } template <class T, class U, class N> inline void init(vector<pair<T, U>> &v, N n) { v.resize(n); for (auto &a : v) cin >> a.first >> a.second; } inline void out() { cout << endl; } template <class T, class... U> inline void out(T a, U... alist) { cout << a << " "; out(forward<U>(alist)...); } template <class N> void resiz(N n) { // empty } template <class N, class T, class... U> void resiz(N n, T &&hd, U &&...tl) { hd.resize(n); resiz(n, forward<U>(tl)...); } bool isout(int h, int w, int H, int W) { return (h < 0 || h >= H || w < 0 || w >= W); } ll binpow(ll a, ll ex, ll p) { ll result = 1; while (ex > 0) { if (ex & 1) result = result * a % p; ex >>= 1; a = a * a % p; } return result; } int N, K; intvec V; int ans = 0; void input() { cin >> N >> K; init(V, N); } void solve() { for (int l = 0; l < N; l++) for (int r = N; N - (r - l) <= K && l <= r; r--) { intvec tmp = intvec(V.begin(), V.begin() + l); copy(V.begin() + r, V.end(), back_inserter(tmp)); sort(all(tmp)); int k = K - N + (r - l), tmpans = 0; for (int i = 0; i < tmp.size(); i++) { if (tmp[i] < 0 && k > 0) { k--; continue; } tmpans += tmp[i]; } chmax(ans, tmpans); } cout << ans << endl; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); int t = 1; while (t) { input(); solve(); t--; } }
[ "control_flow.loop.for.condition.change" ]
842,398
842,399
u195036695
cpp
p03032
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N, K; cin >> N >> K; deque<int> jewel; for (int i = 0; i < N; i++) { int num; cin >> num; jewel.push_back(num); } int ans = -1; for (int i = 0; i < min(N, K); i++) { for (int j = 0; j < min(N, K) - i; j++) { deque<int> jewel_copy = jewel; vector<int> tmp; for (int a = 0; a < i; a++) { tmp.push_back(jewel_copy.front()); jewel_copy.pop_front(); } for (int b = 0; b < j; b++) { tmp.push_back(jewel_copy.back()); jewel_copy.pop_back(); } sort(tmp.begin(), tmp.end()); int value = 0, trash = K - i - j; for (auto x : tmp) { if (trash > 0 && x < 0) { trash--; continue; } value += x; } if (value > ans) ans = value; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N, K; cin >> N >> K; deque<int> jewel; for (int i = 0; i < N; i++) { int num; cin >> num; jewel.push_back(num); } int ans = -1; for (int i = 0; i <= min(N, K); i++) { for (int j = 0; j <= min(N, K) - i; j++) { deque<int> jewel_copy = jewel; vector<int> tmp; for (int a = 0; a < i; a++) { tmp.push_back(jewel_copy.front()); jewel_copy.pop_front(); } for (int b = 0; b < j; b++) { tmp.push_back(jewel_copy.back()); jewel_copy.pop_back(); } sort(tmp.begin(), tmp.end()); int value = 0, trash = K - i - j; for (auto x : tmp) { if (trash > 0 && x < 0) { trash--; continue; } value += x; } if (value > ans) ans = value; } } cout << ans << endl; }
[ "expression.operator.compare.change", "control_flow.loop.for.condition.change", "expression.off_by_one", "expression.operation.binary.change" ]
842,407
842,408
u986480146
cpp
p03032
#define MOD 1000000007 #if 1 //------------------------------------------------------------ #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; template <class T> struct Entry { static void Run() { T().Run(); } }; struct MyMain; #if defined(TEST) #include "test.hpp" #else signed main() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); Entry<MyMain>::Run(); return 0; } #endif //------------------------------------------------------------ using ll = long long; #define int ll #define FOR(i, s, e) for (ll i = ll(s); i < ll(e); ++i) #define RFOR(i, s, e) for (ll i = ll(e) - 1; i >= ll(s); --i) #define REP(i, n) for (ll i = 0, i##_size = ll(n); i < i##_size; ++i) #define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define INF INT64_MAX //------------------------------------------------------------ template <class T> struct ContainerHolder { bool flag = true; T &var; ContainerHolder(T &v) : var(v) {} operator bool() const { return flag; } T *operator->() { return &var; } }; template <class T> ContainerHolder<T> ContainerHold(T &v) { return ContainerHolder<T>(v); } #define CFOR(it, container) \ for (auto holder = ContainerHold(container); holder; holder.flag = false) \ for (auto it = holder->begin(), endIt = holder->end(); it != endIt; ++it) //------------------------------------------------------------ template <class T> struct arr : public vector<T> { arr() {} arr(initializer_list<T> il) : vector<T>(il) {} explicit arr(ll n, T v = T()) : vector<T>(n, v) {} T &operator()(int i) { return (*this)[i]; } T const &operator()(int i) const { return (*this)[i]; } void init(ll n, T v = T()) { this->clear(); this->resize(n, v); } ll sz() const { return (ll)this->size(); } void pb(T v) { this->push_back(v); } void sort() { std::sort(this->begin(), this->end()); } void sort(function<bool(T, T)> p) { std::sort(this->begin(), this->end(), p); } void rsort() { std::sort(this->begin(), this->end(), greater<T>()); } void reverse() { std::reverse(this->begin(), this->end()); } void unique_erase() { this->erase(std::unique(this->begin(), this->end()), this->end()); } bool next_permutation() { return std::next_permutation(this->begin(), this->end()); } // これ以下はソート済み前提 int lower_bound(T const &v, function<bool(T, T)> p) { return std::lower_bound(this->begin(), this->end(), v, p) - this->begin(); } int lower_bound(T const &v) { return std::lower_bound(this->begin(), this->end(), v) - this->begin(); } int upper_bound(T const &v, function<bool(T, T)> p) { return std::upper_bound(this->begin(), this->end(), v, p) - this->begin(); } int upper_bound(T const &v) { return std::upper_bound(this->begin(), this->end(), v) - this->begin(); } int find_nearest(T const &v) { int i = this->lower_bound(v); if (i >= sz()) { --i; } else if ((*this)[i] != v) { int p = i - 1; if (p >= 0) { int id = abs((*this)[i] - v); int pd = abs((*this)[p] - v); if (pd < id) { i = p; } } } return i; } // 見つからなければ-1 int find(T const &v) { int i = this->lower_bound(v); if (i >= sz()) { return -1; } if ((*this)[i] != v) { return -1; } return i; } }; using ints = arr<ll>; template <class T> struct que : public queue<T> { ll sz() const { return (ll)this->size(); } T popfront() { T v = this->front(); this->pop(); return v; } }; template <class A, class B> struct pr { union { A a; A key; A first; A x; }; union { B b; B value; B second; B y; }; pr() : a(A()), b(B()){}; pr(A a_, B b_) : a(a_), b(b_) {} pr(pr const &r) : a(r.a), b(r.b){}; pr(pair<A, B> const &r) : a(r.first), b(r.second){}; bool operator==(pr const &r) const { return a == r.a && b == r.b; } bool operator!=(pr const &r) const { return !((*this) == r); } bool operator<(pr const &r) const { if (a == r.a) { return b < r.b; } return a < r.a; } pr operator+(pr v) const { return pr(x, y) += v; } pr operator-(pr v) const { return pr(x, y) -= v; } pr &operator+=(pr v) { x += v.x; y += v.y; return *this; } pr &operator-=(pr v) { x -= v.x; y -= v.y; return *this; } void flip() { swap(x, y); } friend istream &operator>>(istream &is, pr &p) { is >> p.a >> p.b; return is; } friend ostream &operator<<(ostream &os, pr const &p) { os << p.a << " " << p.b; return os; } }; using pint = pr<ll, ll>; using pints = arr<pint>; template <class K, class V> struct dic : public map<K, V> { bool get(K const &k, V *v) { auto it = this->find(k); if (it != this->end()) { *v = it->second; return true; } return false; } }; template <class T> struct arr2 { vector<T> m_vec; int m_width; int m_height; arr2() : m_width(0), m_height(0) {} arr2(int w, int h, T const &value = T()) : m_width(w), m_height(h) { m_vec.resize(w * h, value); } arr2(arr2 const &r) { m_vec = r.m_vec; m_width = r.m_width; m_height = r.m_height; } arr2(arr2 &&r) { m_vec = move(r.m_vec); m_width = r.m_width; m_height = r.m_height; } arr2 &operator=(arr2 const &r) { m_vec = r.m_vec; m_width = r.m_width; m_height = r.m_height; return *this; } arr2 &operator=(arr2 &&r) { m_vec = move(r.m_vec); m_width = r.m_width; m_height = r.m_height; return *this; } bool operator==(arr2 const &r) const { return m_vec = r.m_vec; } bool operator<(arr2 const &r) const { if (m_width != r.m_width) { return m_width < r.m_width; } if (m_height != r.m_height) { return m_height < r.m_height; } REP(i, m_vec.size()) { if (m_vec[i] != r.m_vec[i]) { return m_vec[i] < r.m_vec[i]; } } return false; } pint size() const { return pint(m_width, m_height); } int width() const { return m_width; } int height() const { return m_height; } void init(int w, int h, T const &value = T()) { m_vec.clear(); m_vec.resize(w * h, value); m_width = w; m_height = h; } void init(pint size, T const &value = T()) { init(size.x, size.y, value); } T &operator()(int x, int y) { return m_vec[y * m_width + x]; } T const &operator()(int x, int y) const { return m_vec[y * m_width + x]; } T &operator()(pint p) { return m_vec[p.y * m_width + p.x]; } T const &operator()(pint p) const { return m_vec[p.y * m_width + p.x]; } T &operator[](pint p) { return m_vec[p.y * m_width + p.x]; } T const &operator[](pint p) const { return m_vec[p.y * m_width + p.x]; } bool isIn(int x, int y) const { return x >= 0 && x < m_width && y >= 0 && y < m_height; } bool isIn(pint p) const { return isIn(p.x, p.y); } bool isOut(int x, int y) const { return x < 0 || x >= m_width || y < 0 || y >= m_height; } bool isOut(pint p) const { return isOut(p.x, p.y); } struct iterator { private: arr2<T> *owner; public: pint pt; iterator(arr2<T> *owner_, pint pt_) : owner(owner_), pt(pt_) {} bool operator==(iterator const &r) const { return pt == r.pt; } bool operator!=(iterator const &r) const { return !((*this) == r); } void operator++() { ++pt.x; if (pt.x >= owner->width()) { ++pt.y; pt.x = 0; } } T &operator*() { return (*owner)(pt); } }; iterator begin() { return iterator(this, pint(0, 0)); } iterator end() { return iterator(this, pint(0, height())); } void disp(ostream &os) { REP(y, m_height) { REP(x, m_width) { os << setw(2) << (*this)(x, y) << " "; } os << endl; } os << endl; } }; const pints around4 = {pint(-1, 0), pint(0, -1), pint(1, 0), pint(0, 1)}; //------------------------------------------------------------ template <class T> void chmin(T &a, T b) { if (b < a) { a = b; } } template <class T> void chmax(T &a, T b) { if (b > a) { a = b; } } constexpr int gcd(int a, int b) { if (a < 0) { a = -a; } if (b < 0) { b = -b; } if (a == 0) { return b; } if (b == 0) { return a; } while (int c = a % b) { a = b; b = c; } return b; } constexpr int lcm(int a, int b) { return a * b / gcd(a, b); } //------------------------------------------------------------ struct bfs { ints froms; ints steps; bfs(int N, int start, function<ints(int)> getAround) { froms.init(N, -1); steps.init(N, -1); que<ll> queue; queue.push(start); froms[start] = start; steps[start] = 0; while (queue.empty() == false) { ll p = queue.popfront(); for (ll n : getAround(p)) { if (steps[n] != -1) { continue; } froms[n] = p; steps[n] = steps[p] + 1; queue.push(n); } } } }; struct BfsResult { arr2<pint> froms; arr2<int> steps; }; template <class T> BfsResult bfs2(arr2<T> const &field, pints const &starts, function<bool(T)> canMove) { BfsResult result; result.froms.init(field.size(), pint(-1, -1)); result.steps.init(field.size(), -1); que<pint> queue; for (auto const &start : starts) { queue.push(start); result.froms(start) = start; result.steps(start) = 0; } while (queue.empty() == false) { auto p = queue.popfront(); for (auto a : around4) { pint n = p + a; if (field.isOut(n)) { continue; } if (result.steps(n) != -1) { continue; } if (!canMove(field(n))) { continue; } result.froms(n) = p; result.steps(n) = result.steps(p) + 1; queue.push(n); } } return result; } //------------------------------------------------------------ template <int M> struct modint { int raw; modint() { raw = 0; } modint(int v) { if (v < 0) { raw = (v % M) + M; } else if (v >= M) { raw = v % M; } else { raw = v; } } modint operator+(modint v) const { return modint(raw) += v; } modint operator-(modint v) const { return modint(raw) -= v; } modint operator*(modint v) const { return modint(raw) *= v; } modint &operator+=(modint v) { raw += v.raw; if (raw >= M) { raw -= M; } return *this; } modint &operator-=(modint v) { raw -= v.raw; if (raw < 0) { raw += M; } return *this; } modint &operator*=(modint v) { raw = (raw * v.raw) % M; return *this; } modint pow(int n) const { return modint::pow(raw, n); } static modint pow(int a, int n) { if (n < 0) { // not support abort(); } int r = 1; while (n) { if (n & 1) { r = (r * a) % M; } a = (a * a) % M; n >>= 1; } return modint(r); } modint inv() const { int a = raw; int b = M; int u = 1; int v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } u %= M; if (u < 0) { u += M; } return u; } friend istream &operator>>(istream &is, modint &m) { int v; is >> v; m = modint(v); return is; } friend ostream &operator<<(ostream &os, modint const &m) { return os << m.raw; } }; using mint = modint<MOD>; using mints = arr<mint>; //------------------------------------------------------------ struct UnionFind { struct Node { Node *parent = nullptr; int count = 1; Node *Root() { if (parent == nullptr) { return this; } return parent = parent->Root(); } }; vector<Node> nodes; UnionFind(int count) { nodes.resize(count); } void Join(int a, int b) { Node *rootA = nodes[a].Root(); Node *rootB = nodes[b].Root(); if (rootA == rootB) { return; } if (rootA->count > rootB->count) { swap(rootA, rootB); } rootB->count += rootA->count; rootA->parent = rootB; rootA->count = 0; } bool IsReachable(int a, int b) { Node *rootA = nodes[a].Root(); Node *rootB = nodes[b].Root(); return rootA == rootB; } int Count(int a) { return nodes[a].Root()->count; } }; //------------------------------------------------------------ template <class T> struct SumsImpl { private: int N; arr<T> S; public: SumsImpl(int N_) : N(N_), S(N + 1, 0) {} void Set(int i, T const &value) { S(i + 1) = S(i) + value; } // l <= x < r T Get(int l, int r) const { return S(r) - S(l); } }; using Sums = SumsImpl<int>; template <class T> struct ImosImpl { private: int N; arr<T> S; public: ImosImpl() {} ImosImpl(int N_) : N(N_), S(N + 1, 0) {} void init(int N_) { N = N_; S.init(N + 1, 0); } void Add(int i, T const &value) { S(i + 1) += value; } void Calc() { REP(i, N) { S(i + 1) += S(i); } } // l <= x < r T Get(int l, int r) const { return S(r) - S(l); } T Get(int i) const { return S(i); } }; using Imos = ImosImpl<int>; template <class T> struct Sums2Impl { private: arr2<T> sums; public: Sums2Impl(int W, int H) : sums(W + 1, H + 1) {} void Set(int x, int y, T const &value) { T s = value; s += sums(x + 1, y); s += sums(x, y + 1); s -= sums(x, y); sums(x + 1, y + 1) = s; } // l <= x < r // t <= y < b T Get(int l, int t, int r, int b) const { int s = sums(r, b); s -= sums(r, t); s -= sums(l, b); s += sums(l, t); return s; } }; using Sums2 = Sums2Impl<int>; template <class T> struct Imos2Impl { private: arr2<T> sums; public: Imos2Impl(int W, int H) : sums(W + 1, H + 1) {} void Add(int x, int y, T const &value) { sums(x + 1, y + 1) += value; } void Calc() { REP(y, sums.height() - 1) { REP(x, sums.width() - 1) { T s = 0; s += sums(x + 1, y); s += sums(x, y + 1); s -= sums(x, y); sums(x + 1, y + 1) += s; } } } // l <= x < r // t <= y < b T Get(int l, int t, int r, int b) const { int s = sums(r, b); s -= sums(r, t); s -= sums(l, b); s += sums(l, t); return s; } }; using Imos2 = Imos2Impl<int>; //------------------------------------------------------------ struct CombiTbl { mints fac; mints ifac; // 重複組み合わせを使う場合は N*2 を指定しないといけない CombiTbl(int N) : fac(N), ifac(N) { fac[0] = 1; ifac[0] = 1; FOR(i, 1, N) { fac[i] = fac[i - 1] * i; ifac[i] = fac[i].inv(); } } // a! mint Fac(int a) const { return fac(a); } // aPb mint Perm(int a, int b) const { return fac(a) * ifac(a - b); } // aCb mint Combi(int a, int b) const { return fac(a) * ifac(b) * ifac(a - b); } // aHb(重複組み合わせ) mint RepCombi(int a, int b) const { return Combi(a + b - 1, b); } }; //------------------------------------------------------------ #if defined(TEST) extern istream &mis; extern ostream &mos; #else istream &mis = cin; ostream &mos = cout; #endif //------------------------------------------------------------ struct OutputStream { template <class T> friend OutputStream &operator<<(OutputStream &s, T const &v) { mos << v << '\n'; return s; } } out; struct PrintStream { stringstream ss; template <class T> friend PrintStream &operator<<(PrintStream &s, T &&v) { s.ss << v << ' '; return s; } PrintStream &operator<<(PrintStream &(*manip)(PrintStream &)) { return (*manip)(*this); } } prn; PrintStream &en(PrintStream &s) { string str = s.ss.str(); s.ss = stringstream(); if (str.empty() == false) { str.pop_back(); } mos << str << '\n'; return s; } //------------------------------------------------------------ template <class T> struct in_base { T value; in_base() { mis >> value; } operator T() { return value; } }; struct in_int { int value; in_int() { mis >> value; } in_int(int add) { mis >> value; value += add; } operator int() { return value; } }; template <class A, class B> struct in_pr { pr<A, B> value; in_pr() { mis >> value.a >> value.b; } in_pr(int addA, int addB) { mis >> value.a >> value.b; value.a += addA; value.b += addB; } in_pr(bool flip) { mis >> value.b >> value.a; } in_pr(int addA, int addB, bool flip) { mis >> value.b >> value.a; value.a += addB; value.b += addA; } operator pr<A, B>() { return value; } }; template <class T> struct in_arr { arr<T> value; in_arr(int N) { value.init(N); REP(i, N) { mis >> value[i]; } } in_arr(int N, int add) { value.init(N); REP(i, N) { mis >> value[i]; value[i] += add; } } operator arr<T>() { return value; } }; template <> struct in_arr<pint> { arr<pint> value; in_arr(int N) { value.init(N); REP(i, N) { mis >> value[i]; } } in_arr(int N, int addA, int addB) { value.init(N); REP(i, N) { mis >> value[i].a >> value[i].b; value[i].a += addA; value[i].b += addB; } } in_arr(int N, bool flip) { value.init(N); REP(i, N) { mis >> value[i].b >> value[i].a; } } in_arr(int N, int addA, int addB, bool flip) { value.init(N); REP(i, N) { mis >> value[i].b >> value[i].a; value[i].a += addB; value[i].b += addA; } } operator arr<pint>() { return value; } }; template <class A, class B> struct in_dic { dic<A, B> value; in_dic(int N) { REP(i, N) { pair<A, B> pr; mis >> pr.first >> pr.second; value.insert(pr); } } in_dic(int N, int addA, int addB) { REP(i, N) { pair<A, B> pr; mis >> pr.first >> pr.second; pr.first += addA; pr.second += addB; value.insert(pr); } } in_dic(int N, bool flip) { REP(i, N) { pair<A, B> pr; mis >> pr.second >> pr.first; value.insert(pr); } } in_dic(int N, int addA, int addB, bool flip) { REP(i, N) { pair<A, B> pr; mis >> pr.second >> pr.first; pr.first += addB; pr.second += addA; value.insert(pr); } } operator dic<A, B>() { return value; } }; template <class T> struct in_arr2 { arr2<T> value; in_arr2(int H, int W) { value.init(W, H); REP(y, H) { REP(x, W) { mis >> value(x, y); } } } in_arr2(int H, int W, int add) { value.init(W, H); REP(y, H) { REP(x, W) { mis >> value(x, y); value(x, y) += add; } } } operator arr2<T>() { return value; } }; template <class T, class Tuple, size_t... Index> T MakeFromTupleImpl(Tuple &&t, index_sequence<Index...>) { return T(get<Index>(forward<Tuple>(t))...); } template <class T, class Tuple> T MakeFromTuple(Tuple &&t) { return MakeFromTupleImpl<T>( forward<Tuple>(t), make_index_sequence<tuple_size<remove_reference_t<Tuple>>::value>{}); } template <class... ARGS> struct inputWithParam { tuple<ARGS...> param; inputWithParam() {} explicit inputWithParam(tuple<ARGS...> &&param_) : param(param_) {} operator int() { return MakeFromTuple<in_int>(param); } operator double() { return MakeFromTuple<in_base<double>>(param); } operator string() { return MakeFromTuple<in_base<string>>(param); } operator char() { return MakeFromTuple<in_base<char>>(param); } template <class A, class B> operator pr<A, B>() { return MakeFromTuple<in_pr<A, B>>(param); } template <class T> operator arr<T>() { return MakeFromTuple<in_arr<T>>(param); } template <class A, class B> operator dic<A, B>() { return MakeFromTuple<in_dic<A, B>>(param); } template <class T> operator arr2<T>() { return MakeFromTuple<in_arr2<T>>(param); } }; struct input { operator int() { return inputWithParam<>(); } operator double() { return inputWithParam<>(); } operator string() { return inputWithParam<>(); } operator char() { return inputWithParam<>(); } template <class A, class B> operator pr<A, B>() { return inputWithParam<>(); } template <class... ARGS> inputWithParam<ARGS...> operator()(ARGS &&...args) { inputWithParam<ARGS...> withParam(forward_as_tuple(args...)); return withParam; } } in; //------------------------------------------------------------ #endif struct MyMain { int N = in; int K = in; void Run() { ints V = in(N); int ans = 0; REP(l, K) { REP(r, K) { int totalGet = l + r; if (totalGet > K) { break; } if (totalGet > N) { break; } int eraseCount = K - l - r; arr<int> minus; int sum = 0; REP(i, l) { sum += V[i]; if (V[i] < 0) { minus.push_back(V[i]); } } REP(i, r) { sum += V[N - 1 - i]; if (V[N - 1 - i] < 0) { minus.push_back(V[N - 1 - i]); } } minus.sort(); REP(i, eraseCount) { if (i >= minus.size()) { break; } sum -= minus[i]; } chmax(ans, sum); } } out << ans; } };
#define MOD 1000000007 #if 1 //------------------------------------------------------------ #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; template <class T> struct Entry { static void Run() { T().Run(); } }; struct MyMain; #if defined(TEST) #include "test.hpp" #else signed main() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); Entry<MyMain>::Run(); return 0; } #endif //------------------------------------------------------------ using ll = long long; #define int ll #define FOR(i, s, e) for (ll i = ll(s); i < ll(e); ++i) #define RFOR(i, s, e) for (ll i = ll(e) - 1; i >= ll(s); --i) #define REP(i, n) for (ll i = 0, i##_size = ll(n); i < i##_size; ++i) #define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i) #define INF INT64_MAX //------------------------------------------------------------ template <class T> struct ContainerHolder { bool flag = true; T &var; ContainerHolder(T &v) : var(v) {} operator bool() const { return flag; } T *operator->() { return &var; } }; template <class T> ContainerHolder<T> ContainerHold(T &v) { return ContainerHolder<T>(v); } #define CFOR(it, container) \ for (auto holder = ContainerHold(container); holder; holder.flag = false) \ for (auto it = holder->begin(), endIt = holder->end(); it != endIt; ++it) //------------------------------------------------------------ template <class T> struct arr : public vector<T> { arr() {} arr(initializer_list<T> il) : vector<T>(il) {} explicit arr(ll n, T v = T()) : vector<T>(n, v) {} T &operator()(int i) { return (*this)[i]; } T const &operator()(int i) const { return (*this)[i]; } void init(ll n, T v = T()) { this->clear(); this->resize(n, v); } ll sz() const { return (ll)this->size(); } void pb(T v) { this->push_back(v); } void sort() { std::sort(this->begin(), this->end()); } void sort(function<bool(T, T)> p) { std::sort(this->begin(), this->end(), p); } void rsort() { std::sort(this->begin(), this->end(), greater<T>()); } void reverse() { std::reverse(this->begin(), this->end()); } void unique_erase() { this->erase(std::unique(this->begin(), this->end()), this->end()); } bool next_permutation() { return std::next_permutation(this->begin(), this->end()); } // これ以下はソート済み前提 int lower_bound(T const &v, function<bool(T, T)> p) { return std::lower_bound(this->begin(), this->end(), v, p) - this->begin(); } int lower_bound(T const &v) { return std::lower_bound(this->begin(), this->end(), v) - this->begin(); } int upper_bound(T const &v, function<bool(T, T)> p) { return std::upper_bound(this->begin(), this->end(), v, p) - this->begin(); } int upper_bound(T const &v) { return std::upper_bound(this->begin(), this->end(), v) - this->begin(); } int find_nearest(T const &v) { int i = this->lower_bound(v); if (i >= sz()) { --i; } else if ((*this)[i] != v) { int p = i - 1; if (p >= 0) { int id = abs((*this)[i] - v); int pd = abs((*this)[p] - v); if (pd < id) { i = p; } } } return i; } // 見つからなければ-1 int find(T const &v) { int i = this->lower_bound(v); if (i >= sz()) { return -1; } if ((*this)[i] != v) { return -1; } return i; } }; using ints = arr<ll>; template <class T> struct que : public queue<T> { ll sz() const { return (ll)this->size(); } T popfront() { T v = this->front(); this->pop(); return v; } }; template <class A, class B> struct pr { union { A a; A key; A first; A x; }; union { B b; B value; B second; B y; }; pr() : a(A()), b(B()){}; pr(A a_, B b_) : a(a_), b(b_) {} pr(pr const &r) : a(r.a), b(r.b){}; pr(pair<A, B> const &r) : a(r.first), b(r.second){}; bool operator==(pr const &r) const { return a == r.a && b == r.b; } bool operator!=(pr const &r) const { return !((*this) == r); } bool operator<(pr const &r) const { if (a == r.a) { return b < r.b; } return a < r.a; } pr operator+(pr v) const { return pr(x, y) += v; } pr operator-(pr v) const { return pr(x, y) -= v; } pr &operator+=(pr v) { x += v.x; y += v.y; return *this; } pr &operator-=(pr v) { x -= v.x; y -= v.y; return *this; } void flip() { swap(x, y); } friend istream &operator>>(istream &is, pr &p) { is >> p.a >> p.b; return is; } friend ostream &operator<<(ostream &os, pr const &p) { os << p.a << " " << p.b; return os; } }; using pint = pr<ll, ll>; using pints = arr<pint>; template <class K, class V> struct dic : public map<K, V> { bool get(K const &k, V *v) { auto it = this->find(k); if (it != this->end()) { *v = it->second; return true; } return false; } }; template <class T> struct arr2 { vector<T> m_vec; int m_width; int m_height; arr2() : m_width(0), m_height(0) {} arr2(int w, int h, T const &value = T()) : m_width(w), m_height(h) { m_vec.resize(w * h, value); } arr2(arr2 const &r) { m_vec = r.m_vec; m_width = r.m_width; m_height = r.m_height; } arr2(arr2 &&r) { m_vec = move(r.m_vec); m_width = r.m_width; m_height = r.m_height; } arr2 &operator=(arr2 const &r) { m_vec = r.m_vec; m_width = r.m_width; m_height = r.m_height; return *this; } arr2 &operator=(arr2 &&r) { m_vec = move(r.m_vec); m_width = r.m_width; m_height = r.m_height; return *this; } bool operator==(arr2 const &r) const { return m_vec = r.m_vec; } bool operator<(arr2 const &r) const { if (m_width != r.m_width) { return m_width < r.m_width; } if (m_height != r.m_height) { return m_height < r.m_height; } REP(i, m_vec.size()) { if (m_vec[i] != r.m_vec[i]) { return m_vec[i] < r.m_vec[i]; } } return false; } pint size() const { return pint(m_width, m_height); } int width() const { return m_width; } int height() const { return m_height; } void init(int w, int h, T const &value = T()) { m_vec.clear(); m_vec.resize(w * h, value); m_width = w; m_height = h; } void init(pint size, T const &value = T()) { init(size.x, size.y, value); } T &operator()(int x, int y) { return m_vec[y * m_width + x]; } T const &operator()(int x, int y) const { return m_vec[y * m_width + x]; } T &operator()(pint p) { return m_vec[p.y * m_width + p.x]; } T const &operator()(pint p) const { return m_vec[p.y * m_width + p.x]; } T &operator[](pint p) { return m_vec[p.y * m_width + p.x]; } T const &operator[](pint p) const { return m_vec[p.y * m_width + p.x]; } bool isIn(int x, int y) const { return x >= 0 && x < m_width && y >= 0 && y < m_height; } bool isIn(pint p) const { return isIn(p.x, p.y); } bool isOut(int x, int y) const { return x < 0 || x >= m_width || y < 0 || y >= m_height; } bool isOut(pint p) const { return isOut(p.x, p.y); } struct iterator { private: arr2<T> *owner; public: pint pt; iterator(arr2<T> *owner_, pint pt_) : owner(owner_), pt(pt_) {} bool operator==(iterator const &r) const { return pt == r.pt; } bool operator!=(iterator const &r) const { return !((*this) == r); } void operator++() { ++pt.x; if (pt.x >= owner->width()) { ++pt.y; pt.x = 0; } } T &operator*() { return (*owner)(pt); } }; iterator begin() { return iterator(this, pint(0, 0)); } iterator end() { return iterator(this, pint(0, height())); } void disp(ostream &os) { REP(y, m_height) { REP(x, m_width) { os << setw(2) << (*this)(x, y) << " "; } os << endl; } os << endl; } }; const pints around4 = {pint(-1, 0), pint(0, -1), pint(1, 0), pint(0, 1)}; //------------------------------------------------------------ template <class T> void chmin(T &a, T b) { if (b < a) { a = b; } } template <class T> void chmax(T &a, T b) { if (b > a) { a = b; } } constexpr int gcd(int a, int b) { if (a < 0) { a = -a; } if (b < 0) { b = -b; } if (a == 0) { return b; } if (b == 0) { return a; } while (int c = a % b) { a = b; b = c; } return b; } constexpr int lcm(int a, int b) { return a * b / gcd(a, b); } //------------------------------------------------------------ struct bfs { ints froms; ints steps; bfs(int N, int start, function<ints(int)> getAround) { froms.init(N, -1); steps.init(N, -1); que<ll> queue; queue.push(start); froms[start] = start; steps[start] = 0; while (queue.empty() == false) { ll p = queue.popfront(); for (ll n : getAround(p)) { if (steps[n] != -1) { continue; } froms[n] = p; steps[n] = steps[p] + 1; queue.push(n); } } } }; struct BfsResult { arr2<pint> froms; arr2<int> steps; }; template <class T> BfsResult bfs2(arr2<T> const &field, pints const &starts, function<bool(T)> canMove) { BfsResult result; result.froms.init(field.size(), pint(-1, -1)); result.steps.init(field.size(), -1); que<pint> queue; for (auto const &start : starts) { queue.push(start); result.froms(start) = start; result.steps(start) = 0; } while (queue.empty() == false) { auto p = queue.popfront(); for (auto a : around4) { pint n = p + a; if (field.isOut(n)) { continue; } if (result.steps(n) != -1) { continue; } if (!canMove(field(n))) { continue; } result.froms(n) = p; result.steps(n) = result.steps(p) + 1; queue.push(n); } } return result; } //------------------------------------------------------------ template <int M> struct modint { int raw; modint() { raw = 0; } modint(int v) { if (v < 0) { raw = (v % M) + M; } else if (v >= M) { raw = v % M; } else { raw = v; } } modint operator+(modint v) const { return modint(raw) += v; } modint operator-(modint v) const { return modint(raw) -= v; } modint operator*(modint v) const { return modint(raw) *= v; } modint &operator+=(modint v) { raw += v.raw; if (raw >= M) { raw -= M; } return *this; } modint &operator-=(modint v) { raw -= v.raw; if (raw < 0) { raw += M; } return *this; } modint &operator*=(modint v) { raw = (raw * v.raw) % M; return *this; } modint pow(int n) const { return modint::pow(raw, n); } static modint pow(int a, int n) { if (n < 0) { // not support abort(); } int r = 1; while (n) { if (n & 1) { r = (r * a) % M; } a = (a * a) % M; n >>= 1; } return modint(r); } modint inv() const { int a = raw; int b = M; int u = 1; int v = 0; while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); } u %= M; if (u < 0) { u += M; } return u; } friend istream &operator>>(istream &is, modint &m) { int v; is >> v; m = modint(v); return is; } friend ostream &operator<<(ostream &os, modint const &m) { return os << m.raw; } }; using mint = modint<MOD>; using mints = arr<mint>; //------------------------------------------------------------ struct UnionFind { struct Node { Node *parent = nullptr; int count = 1; Node *Root() { if (parent == nullptr) { return this; } return parent = parent->Root(); } }; vector<Node> nodes; UnionFind(int count) { nodes.resize(count); } void Join(int a, int b) { Node *rootA = nodes[a].Root(); Node *rootB = nodes[b].Root(); if (rootA == rootB) { return; } if (rootA->count > rootB->count) { swap(rootA, rootB); } rootB->count += rootA->count; rootA->parent = rootB; rootA->count = 0; } bool IsReachable(int a, int b) { Node *rootA = nodes[a].Root(); Node *rootB = nodes[b].Root(); return rootA == rootB; } int Count(int a) { return nodes[a].Root()->count; } }; //------------------------------------------------------------ template <class T> struct SumsImpl { private: int N; arr<T> S; public: SumsImpl(int N_) : N(N_), S(N + 1, 0) {} void Set(int i, T const &value) { S(i + 1) = S(i) + value; } // l <= x < r T Get(int l, int r) const { return S(r) - S(l); } }; using Sums = SumsImpl<int>; template <class T> struct ImosImpl { private: int N; arr<T> S; public: ImosImpl() {} ImosImpl(int N_) : N(N_), S(N + 1, 0) {} void init(int N_) { N = N_; S.init(N + 1, 0); } void Add(int i, T const &value) { S(i + 1) += value; } void Calc() { REP(i, N) { S(i + 1) += S(i); } } // l <= x < r T Get(int l, int r) const { return S(r) - S(l); } T Get(int i) const { return S(i); } }; using Imos = ImosImpl<int>; template <class T> struct Sums2Impl { private: arr2<T> sums; public: Sums2Impl(int W, int H) : sums(W + 1, H + 1) {} void Set(int x, int y, T const &value) { T s = value; s += sums(x + 1, y); s += sums(x, y + 1); s -= sums(x, y); sums(x + 1, y + 1) = s; } // l <= x < r // t <= y < b T Get(int l, int t, int r, int b) const { int s = sums(r, b); s -= sums(r, t); s -= sums(l, b); s += sums(l, t); return s; } }; using Sums2 = Sums2Impl<int>; template <class T> struct Imos2Impl { private: arr2<T> sums; public: Imos2Impl(int W, int H) : sums(W + 1, H + 1) {} void Add(int x, int y, T const &value) { sums(x + 1, y + 1) += value; } void Calc() { REP(y, sums.height() - 1) { REP(x, sums.width() - 1) { T s = 0; s += sums(x + 1, y); s += sums(x, y + 1); s -= sums(x, y); sums(x + 1, y + 1) += s; } } } // l <= x < r // t <= y < b T Get(int l, int t, int r, int b) const { int s = sums(r, b); s -= sums(r, t); s -= sums(l, b); s += sums(l, t); return s; } }; using Imos2 = Imos2Impl<int>; //------------------------------------------------------------ struct CombiTbl { mints fac; mints ifac; // 重複組み合わせを使う場合は N*2 を指定しないといけない CombiTbl(int N) : fac(N), ifac(N) { fac[0] = 1; ifac[0] = 1; FOR(i, 1, N) { fac[i] = fac[i - 1] * i; ifac[i] = fac[i].inv(); } } // a! mint Fac(int a) const { return fac(a); } // aPb mint Perm(int a, int b) const { return fac(a) * ifac(a - b); } // aCb mint Combi(int a, int b) const { return fac(a) * ifac(b) * ifac(a - b); } // aHb(重複組み合わせ) mint RepCombi(int a, int b) const { return Combi(a + b - 1, b); } }; //------------------------------------------------------------ #if defined(TEST) extern istream &mis; extern ostream &mos; #else istream &mis = cin; ostream &mos = cout; #endif //------------------------------------------------------------ struct OutputStream { template <class T> friend OutputStream &operator<<(OutputStream &s, T const &v) { mos << v << '\n'; return s; } } out; struct PrintStream { stringstream ss; template <class T> friend PrintStream &operator<<(PrintStream &s, T &&v) { s.ss << v << ' '; return s; } PrintStream &operator<<(PrintStream &(*manip)(PrintStream &)) { return (*manip)(*this); } } prn; PrintStream &en(PrintStream &s) { string str = s.ss.str(); s.ss = stringstream(); if (str.empty() == false) { str.pop_back(); } mos << str << '\n'; return s; } //------------------------------------------------------------ template <class T> struct in_base { T value; in_base() { mis >> value; } operator T() { return value; } }; struct in_int { int value; in_int() { mis >> value; } in_int(int add) { mis >> value; value += add; } operator int() { return value; } }; template <class A, class B> struct in_pr { pr<A, B> value; in_pr() { mis >> value.a >> value.b; } in_pr(int addA, int addB) { mis >> value.a >> value.b; value.a += addA; value.b += addB; } in_pr(bool flip) { mis >> value.b >> value.a; } in_pr(int addA, int addB, bool flip) { mis >> value.b >> value.a; value.a += addB; value.b += addA; } operator pr<A, B>() { return value; } }; template <class T> struct in_arr { arr<T> value; in_arr(int N) { value.init(N); REP(i, N) { mis >> value[i]; } } in_arr(int N, int add) { value.init(N); REP(i, N) { mis >> value[i]; value[i] += add; } } operator arr<T>() { return value; } }; template <> struct in_arr<pint> { arr<pint> value; in_arr(int N) { value.init(N); REP(i, N) { mis >> value[i]; } } in_arr(int N, int addA, int addB) { value.init(N); REP(i, N) { mis >> value[i].a >> value[i].b; value[i].a += addA; value[i].b += addB; } } in_arr(int N, bool flip) { value.init(N); REP(i, N) { mis >> value[i].b >> value[i].a; } } in_arr(int N, int addA, int addB, bool flip) { value.init(N); REP(i, N) { mis >> value[i].b >> value[i].a; value[i].a += addB; value[i].b += addA; } } operator arr<pint>() { return value; } }; template <class A, class B> struct in_dic { dic<A, B> value; in_dic(int N) { REP(i, N) { pair<A, B> pr; mis >> pr.first >> pr.second; value.insert(pr); } } in_dic(int N, int addA, int addB) { REP(i, N) { pair<A, B> pr; mis >> pr.first >> pr.second; pr.first += addA; pr.second += addB; value.insert(pr); } } in_dic(int N, bool flip) { REP(i, N) { pair<A, B> pr; mis >> pr.second >> pr.first; value.insert(pr); } } in_dic(int N, int addA, int addB, bool flip) { REP(i, N) { pair<A, B> pr; mis >> pr.second >> pr.first; pr.first += addB; pr.second += addA; value.insert(pr); } } operator dic<A, B>() { return value; } }; template <class T> struct in_arr2 { arr2<T> value; in_arr2(int H, int W) { value.init(W, H); REP(y, H) { REP(x, W) { mis >> value(x, y); } } } in_arr2(int H, int W, int add) { value.init(W, H); REP(y, H) { REP(x, W) { mis >> value(x, y); value(x, y) += add; } } } operator arr2<T>() { return value; } }; template <class T, class Tuple, size_t... Index> T MakeFromTupleImpl(Tuple &&t, index_sequence<Index...>) { return T(get<Index>(forward<Tuple>(t))...); } template <class T, class Tuple> T MakeFromTuple(Tuple &&t) { return MakeFromTupleImpl<T>( forward<Tuple>(t), make_index_sequence<tuple_size<remove_reference_t<Tuple>>::value>{}); } template <class... ARGS> struct inputWithParam { tuple<ARGS...> param; inputWithParam() {} explicit inputWithParam(tuple<ARGS...> &&param_) : param(param_) {} operator int() { return MakeFromTuple<in_int>(param); } operator double() { return MakeFromTuple<in_base<double>>(param); } operator string() { return MakeFromTuple<in_base<string>>(param); } operator char() { return MakeFromTuple<in_base<char>>(param); } template <class A, class B> operator pr<A, B>() { return MakeFromTuple<in_pr<A, B>>(param); } template <class T> operator arr<T>() { return MakeFromTuple<in_arr<T>>(param); } template <class A, class B> operator dic<A, B>() { return MakeFromTuple<in_dic<A, B>>(param); } template <class T> operator arr2<T>() { return MakeFromTuple<in_arr2<T>>(param); } }; struct input { operator int() { return inputWithParam<>(); } operator double() { return inputWithParam<>(); } operator string() { return inputWithParam<>(); } operator char() { return inputWithParam<>(); } template <class A, class B> operator pr<A, B>() { return inputWithParam<>(); } template <class... ARGS> inputWithParam<ARGS...> operator()(ARGS &&...args) { inputWithParam<ARGS...> withParam(forward_as_tuple(args...)); return withParam; } } in; //------------------------------------------------------------ #endif struct MyMain { int N = in; int K = in; void Run() { ints V = in(N); int ans = 0; REP(l, K + 1) { REP(r, K + 1) { int totalGet = l + r; if (totalGet > K) { break; } if (totalGet > N) { break; } int eraseCount = K - l - r; arr<int> minus; int sum = 0; REP(i, l) { sum += V[i]; if (V[i] < 0) { minus.push_back(V[i]); } } REP(i, r) { sum += V[N - 1 - i]; if (V[N - 1 - i] < 0) { minus.push_back(V[N - 1 - i]); } } minus.sort(); REP(i, eraseCount) { if (i >= minus.size()) { break; } sum -= minus[i]; } chmax(ans, sum); } } out << ans; } };
[ "expression.operation.binary.add" ]
842,426
842,427
u658243311
cpp
p03032
#include <bits/stdc++.h> #include <unistd.h> #define fi first #define se second #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = (n)-1; i >= 0; --i) #define ALL(a) a.begin(), a.end() #define pb push_back #define dame \ { \ puts("-1"); \ return 0; \ } #define show(x) cerr << #x << " = " << x << endl; using namespace std; using ll = long long; using ld = long double; using pl = pair<ll, ll>; ll LINF = 1000000000000000000; typedef vector<ll> vl; typedef vector<pl> vp; 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; } struct UnionFind { vector<int> d; UnionFind(int n = 0) : d(n, -1) {} int root(int x) { if (d[x] < 0) return x; return d[x] = root(d[x]); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (d[x] > d[y]) swap(x, y); d[x] += d[y]; d[y] = x; return true; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -d[root(x)]; } int factor_size() { int ans = 0; rep(i, d.size()) { if (d[i] < 0) { ans++; } } return ans; } }; ll d[201][201]; void warshall_floyd(ll n) { rep(k, n) { rep(i, n) { rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } } struct edge { ll to, cost; }; struct dijkstra { ll V; vector<vector<edge>> G; vector<ll> d; dijkstra(ll n) { init(n); } void init(ll n) { V = n; G.resize(V); d.resize(V); rep(i, V) { d[i] = LINF; } } void add_edge(ll s, ll t, ll cost) { edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void run(ll s) { rep(i, V) { d[i] = LINF; } d[s] = 0; priority_queue<pl, vector<pl>, greater<pl>> que; que.push(pl(0, s)); while (!que.empty()) { pl p = que.top(); que.pop(); ll v = p.second; if (d[v] < p.first) continue; for (auto e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(pl(d[e.to], e.to)); } } } } }; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const ll mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } // combination mod prime // https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619 struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } } c(200005); // Sieve of Eratosthenes // https://youtu.be/UTVg7wzMWQc?t=2774 struct Sieve { int n; vector<int> f, primes; Sieve(int n = 1) : n(n), f(n + 1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i * i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x; } vector<int> factorList(int x) { vector<int> res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector<pl> factor(int x) { vector<int> fl = factorList(x); if (fl.size() == 0) return {}; vector<pl> res(1, pl(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } vector<pair<ll, int>> factor(ll x) { vector<pair<ll, int>> res; for (int p : primes) { int y = 0; while (x % p == 0) x /= p, ++y; if (y != 0) res.emplace_back(p, y); } if (x != 1) res.emplace_back(x, 1); return res; } }; using data = pair<ll, vector<ll>>; int h, w; ll xxx[1010][1010]; ll a[1010][1010]; ll dfs(int x, int y) { if (xxx[x][y] > 0) return xxx[x][y]; int tate[4] = {1, -1, 0, 0}; int yoko[4] = {0, 0, 1, -1}; ll ret = 1LL; rep(i, 4) { if (x + yoko[i] < 0 || y + tate[i] < 0 || x + yoko[i] >= w || y + tate[i] >= h) continue; if (a[x + yoko[i]][y + tate[i]] <= a[x][y]) continue; // f = true; // show(x); // show(y); // show(x+yoko[i]); // show(y+tate[i]); ret += dfs(x + yoko[i], y + tate[i]); ret %= mod; } // if(!f) return ret; // show(x); // show(y); // show(w); // show(h); // show(ret); return xxx[x][y] = ret; } int main() { ll n, k; cin >> n >> k; vector<ll> v(n); rep(i, n) cin >> v[i]; // x is gotten juery ll ans = -100000000000; rep(x, k + 1) { // if(k>2*x) continue; // z is gotten from left rep(z, x + 1) { vector<ll> tmp_v; rep(w, z) tmp_v.pb(v[w]); rep(w, x - z) tmp_v.pb(v[n - 1 - w]); rep(y, x + 1) { if (2 * x - y > k) continue; sort(ALL(tmp_v)); // show(tmp_v.size()); // show(x); ll tmp = accumulate(tmp_v.begin() + x - y, tmp_v.end(), 0LL); // // if (tmp == 50) { // show(x); // show(z); // show(y); // } chmax(ans, tmp); } } } // cout << -1 << endl; cout << ans << endl; return 0; }
#include <bits/stdc++.h> #include <unistd.h> #define fi first #define se second #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = (n)-1; i >= 0; --i) #define ALL(a) a.begin(), a.end() #define pb push_back #define dame \ { \ puts("-1"); \ return 0; \ } #define show(x) cerr << #x << " = " << x << endl; using namespace std; using ll = long long; using ld = long double; using pl = pair<ll, ll>; ll LINF = 1000000000000000000; typedef vector<ll> vl; typedef vector<pl> vp; 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; } struct UnionFind { vector<int> d; UnionFind(int n = 0) : d(n, -1) {} int root(int x) { if (d[x] < 0) return x; return d[x] = root(d[x]); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (d[x] > d[y]) swap(x, y); d[x] += d[y]; d[y] = x; return true; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -d[root(x)]; } int factor_size() { int ans = 0; rep(i, d.size()) { if (d[i] < 0) { ans++; } } return ans; } }; ll d[201][201]; void warshall_floyd(ll n) { rep(k, n) { rep(i, n) { rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } } struct edge { ll to, cost; }; struct dijkstra { ll V; vector<vector<edge>> G; vector<ll> d; dijkstra(ll n) { init(n); } void init(ll n) { V = n; G.resize(V); d.resize(V); rep(i, V) { d[i] = LINF; } } void add_edge(ll s, ll t, ll cost) { edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void run(ll s) { rep(i, V) { d[i] = LINF; } d[s] = 0; priority_queue<pl, vector<pl>, greater<pl>> que; que.push(pl(0, s)); while (!que.empty()) { pl p = que.top(); que.pop(); ll v = p.second; if (d[v] < p.first) continue; for (auto e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.push(pl(d[e.to], e.to)); } } } } }; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const ll mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { return mint(*this) += a; } mint operator-(const mint a) const { return mint(*this) -= a; } mint operator*(const mint a) const { return mint(*this) *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return *this *= a.inv(); } mint operator/(const mint a) const { return mint(*this) /= a; } }; istream &operator>>(istream &is, const mint &a) { return is >> a.x; } ostream &operator<<(ostream &os, const mint &a) { return os << a.x; } // combination mod prime // https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619 struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } } c(200005); // Sieve of Eratosthenes // https://youtu.be/UTVg7wzMWQc?t=2774 struct Sieve { int n; vector<int> f, primes; Sieve(int n = 1) : n(n), f(n + 1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i * i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x; } vector<int> factorList(int x) { vector<int> res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector<pl> factor(int x) { vector<int> fl = factorList(x); if (fl.size() == 0) return {}; vector<pl> res(1, pl(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } vector<pair<ll, int>> factor(ll x) { vector<pair<ll, int>> res; for (int p : primes) { int y = 0; while (x % p == 0) x /= p, ++y; if (y != 0) res.emplace_back(p, y); } if (x != 1) res.emplace_back(x, 1); return res; } }; using data = pair<ll, vector<ll>>; int h, w; ll xxx[1010][1010]; ll a[1010][1010]; ll dfs(int x, int y) { if (xxx[x][y] > 0) return xxx[x][y]; int tate[4] = {1, -1, 0, 0}; int yoko[4] = {0, 0, 1, -1}; ll ret = 1LL; rep(i, 4) { if (x + yoko[i] < 0 || y + tate[i] < 0 || x + yoko[i] >= w || y + tate[i] >= h) continue; if (a[x + yoko[i]][y + tate[i]] <= a[x][y]) continue; // f = true; // show(x); // show(y); // show(x+yoko[i]); // show(y+tate[i]); ret += dfs(x + yoko[i], y + tate[i]); ret %= mod; } // if(!f) return ret; // show(x); // show(y); // show(w); // show(h); // show(ret); return xxx[x][y] = ret; } int main() { ll n, k; cin >> n >> k; vector<ll> v(n); rep(i, n) cin >> v[i]; // x is gotten juery ll ans = -100000000000; rep(x, min(k, n) + 1LL) { // if(k>2*x) continue; // z is gotten from left // ll limit = min(x+1, n+1); rep(z, x + 1) { vector<ll> tmp_v; rep(w, z) tmp_v.pb(v[w]); rep(w, x - z) tmp_v.pb(v[n - 1 - w]); rep(y, x + 1) { if (2 * x - y > k) continue; sort(ALL(tmp_v)); // show(tmp_v.size()); // show(x); ll tmp = accumulate(tmp_v.begin() + x - y, tmp_v.end(), 0LL); // // if (tmp == 50) { // show(x); // show(z); // show(y); // } chmax(ans, tmp); } } } // cout << -1 << endl; cout << ans << endl; return 0; }
[ "call.add", "call.arguments.add", "literal.number.type.widen.change" ]
842,430
842,431
u442810826
cpp
p03032
#include <iostream> #include <vector> //#include <string> #include <algorithm> //#include <math.h> //#include <queue> //#include <stack> //#include <iomanip> // sometimes used #include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL; // typedef long double LD; using namespace std; //#define MOD 1000000007 //#define MAX 100100 //#define NIL -1 //#define INFTY 1000000000000000000 int main() { LL n; LL k; cin >> n >> k; vector<LL> v(n); for (LL i = 0; i < n; i++) { cin >> v[i]; } LL lim = min(n, k); LL ans = 0; LL sum; for (LL i = 0; i <= lim; i++) { for (LL j = 0; j <= i; j++) { sum = 0; multiset<LL> get_val; for (LL l = 0; l <= j; l++) { if (l == 0) { continue; } sum += v[l - 1]; get_val.insert(v[l - 1]); // cout << "left " << l-1 << " " << sum << endl; } for (LL l = 0; j + l <= i; l++) { if (l == 0) { continue; } sum += v[n - l]; get_val.insert(v[n - 1]); // cout << "right " << n-l << " " << sum << endl; } LL tmp = k - i; while (tmp > 0) { auto itr = get_val.begin(); if (*itr >= 0) { break; } sum -= *itr; get_val.erase(itr); tmp--; } // cout << sum << endl; ans = max(ans, sum); } } cout << ans << endl; return 0; }
#include <iostream> #include <vector> //#include <string> #include <algorithm> //#include <math.h> //#include <queue> //#include <stack> //#include <iomanip> // sometimes used #include <set> //#include <map> //#include <numeric> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL; // typedef long double LD; using namespace std; //#define MOD 1000000007 //#define MAX 100100 //#define NIL -1 //#define INFTY 1000000000000000000 int main() { LL n; LL k; cin >> n >> k; vector<LL> v(n); for (LL i = 0; i < n; i++) { cin >> v[i]; } LL lim = min(n, k); LL ans = 0; LL sum; for (LL i = 0; i <= lim; i++) { for (LL j = 0; j <= i; j++) { sum = 0; multiset<LL> get_val; for (LL l = 0; l <= j; l++) { if (l == 0) { continue; } sum += v[l - 1]; get_val.insert(v[l - 1]); // cout << "left " << v[l-1] << " " << sum << endl; } for (LL l = 0; j + l <= i; l++) { if (l == 0) { continue; } sum += v[n - l]; get_val.insert(v[n - l]); // cout << "right " << v[n-l] << " " << sum << endl; } LL tmp = k - i; while (tmp > 0) { auto itr = get_val.begin(); if (*itr >= 0) { break; } sum -= *itr; // cout << "erase " << *itr << " " << sum << endl; get_val.erase(itr); tmp--; } // cout << sum << endl; ans = max(ans, sum); } } cout << ans << endl; return 0; }
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
842,432
842,433
u755310927
cpp
p03032
//解説見た #include <bits/stdc++.h> typedef long long lint; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) int main() { int n, k; cin >> n >> k; int v[50]; rep(i, n) cin >> v[i]; int ans = 0; rep(a, min(n, k)) { rep(b, min(n, k) - a) { int va = 0; vector<int> stone; for (int i = 0; i < a; i++) { stone.push_back(v[i]); va += v[i]; } for (int i = n - 1; i > n - b - 1; i--) { stone.push_back(v[i]); va += v[i]; } sort(stone.begin(), stone.end()); int s = stone.size(); rep(i, min(k - (a + b), s)) { if (stone[i] >= 0) break; va -= stone[i]; } ans = max(ans, va); } } cout << ans << endl; }
//解説見た #include <bits/stdc++.h> typedef long long lint; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) int main() { int n, k; cin >> n >> k; int v[50]; rep(i, n) cin >> v[i]; int ans = 0; rep(a, min(n, k) + 1) { rep(b, min(n, k) - a + 1) { int va = 0; vector<int> stone; for (int i = 0; i < a; i++) { stone.push_back(v[i]); va += v[i]; } for (int i = n - 1; i > n - b - 1; i--) { stone.push_back(v[i]); va += v[i]; } sort(stone.begin(), stone.end()); int s = stone.size(); rep(i, min(k - (a + b), s)) { if (stone[i] >= 0) break; va -= stone[i]; } ans = max(ans, va); } } cout << ans << endl; }
[ "expression.operation.binary.add" ]
842,438
842,439
u870575557
cpp