buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
maxscore = 0 def solve(): ans = [-1]*n ans[-1] = m rek(ans, m, 1) return def rek(ans, m, rekdepth): global maxscore curr_ans = ans.copy() for i in range(m+1): curr_ans[-rekdepth-1] = i if rekdepth == n-1: score = get_score(curr_ans) maxscore = max...
maxscore = 0 def solve(): ans = [-1]*n ans[-1] = m rek(ans, m, 1) return def rek(ans, m, rekdepth): global maxscore curr_ans = ans.copy() for i in range(1, m+1): curr_ans[-rekdepth-1] = i if rekdepth == n-1: score = get_score(curr_ans) maxscore = ...
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
222
import itertools N,M,Q = map(int, input().split()) x = [list(map(int, input().split(" "))) for i in range(Q)] list = list(itertools.combinations(range(1,M+1),N)) tmp = 0 mx = 0 for k in range(len(list)): #print(list[k]) for i in range(Q): a = x[i][0] b = x[i][1] c = x[i][2] d = ...
import itertools N,M,Q = map(int, input().split()) x = [list(map(int, input().split(" "))) for i in range(Q)] list = list(itertools.combinations_with_replacement(range(1,M+1),N)) tmp = 0 mx = 0 for k in range(len(list)): for i in range(Q): a = x[i][0] b = x[i][1] c = x[i][2] d = x...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
175
#include <stdio.h> #include <string.h> int nxpt(char *s) { int i, l = strlen(s), max = 0, f[260] = {0}; for (l--; l + 1 && max <= s[l]; l--) f[max = s[l]]++; if (l < 0) return 0; f[s[l]]++; for (i = s[l] + 1; f[i] == 0; i++) ; f[s[l] = i]--; for (i = 0; s[++l]; f[s[l] = i]--) { while (f[i]...
#include <stdio.h> #include <string.h> int nxpt(char *s) { int i, l = strlen(s), max = 0, f[260] = {0}; for (l--; l + 1 && max <= s[l]; l--) f[max = s[l]]++; if (l < 0) return 0; f[s[l]]++; for (i = s[l] + 1; f[i] == 0; i++) ; f[s[l] = i]--; for (i = 0; s[++l]; f[s[l] = i]--) { while (f[i]...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46], ["+", 0, 1, 0, 11, 31, 69, 71, 16, 17, 33], ["+", 0, 1, 0, 11, 31, 69, 71, 16, 12, 13]]
0
459
def main(): n,m,q = map(int,input().split()) a = [1]*n a_list = [] while True: a_list.append([0, a[:]]) end = True for i in range(n): index = n-1-i if a[index] < m-i: a[index] = a[index] + 1 for j in range(i): a[index+1+j] = a[index] end = False ...
def main(): n,m,q = map(int,input().split()) a = [1]*n a_list = [] while True: a_list.append([0, a[:]]) end = True for i in range(n): index = n-1-i if a[index] < m: a[index] = a[index] + 1 for j in range(i): a[index+1+j] = a[index] end = False ...
[["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22]]
5
224
#include <bits/stdc++.h> using namespace std; #define SZ(a) int((a).size()) #define _REP(_1, _2, _3, _4, name, ...) name #define _REP4(i, b, e, s) \ for (decltype(e) _b = (b), _e = (e), i = _b + (0 < (s) ? 0 : (s)); \ (0 < (s) ? i < _e : _e <= i);...
#include <bits/stdc++.h> using namespace std; #define SZ(a) int((a).size()) #define _REP(_1, _2, _3, _4, name, ...) name #define _REP4(i, b, e, s) \ for (decltype(e) _b = (b), _e = (e), i = _b + (0 < (s) ? 0 : (s)); \ (0 < (s) ? i < _e : _e <= i);...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
534
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < (n); i++) #define ALL(v) v.begin(), v.end() #define FOR(i, j, k) for (ll i = j; i < k; i++) #define DUMP(i, v) \ for (ll i = 0; i < v.size(); i++) ...
#include "bits/stdc++.h" #define MOD 1000000007 #define rep(i, n) for (ll i = 0; i < (n); i++) #define ALL(v) v.begin(), v.end() #define FOR(i, j, k) for (ll i = j; i < k; i++) #define DUMP(i, v) \ for (ll i = 0; i < v.size(); i++) ...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22]]
1
604
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; using f64 = double; constexpr i64 INF = INT_FAST64_MAX / 2; constexpr f64 EPS = DBL_EPSILON; using p64 = pair<i64, i64>; using pp64 = pair<p64, p64>; vector<i64> v; i64 n, m, q; vector<pp64> abcd; i64 f(i64 depth, i64 pre) { i64 res = 0; if...
#include <bits/stdc++.h> using namespace std; using i64 = int_fast64_t; using f64 = double; constexpr i64 INF = INT_FAST64_MAX / 2; constexpr f64 EPS = DBL_EPSILON; using p64 = pair<i64, i64>; using pp64 = pair<p64, p64>; vector<i64> v; i64 n, m, q; vector<pp64> abcd; i64 f(i64 depth, i64 pre) { i64 res = 0; if...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18]]
1
322
import itertools n, m, q = list(map(int, input().split())) queries = [list(map(int, input().split())) for _ in range(q)] nums = [i for i in range(1, 10)] ans = 0 for nums in itertools.combinations_with_replacement(nums, r=n): tmp = 0 for query in queries: if nums[query[1] - 1] - nums[query[0] - 1] == query[2]: ...
import itertools n, m, q = list(map(int, input().split())) queries = [list(map(int, input().split())) for _ in range(q)] nums = [i for i in range(1, m + 1)] ans = 0 for nums in itertools.combinations_with_replacement(nums, r=n): tmp = 0 for query in queries: if nums[query[1] - 1] - nums[query[0] - 1] == query[2]: ...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
132
import itertools N, M, Q = map(int, input().split()) list_q = [] for i in range(Q): list_q.append(list(map(int, input().split()))) ans = 0 for A_ in itertools.combinations([i for i in range(1, M+1)], N): A = list(A_) tmp_ans = 0 for i in range(Q): if A[list_q[i][1]-1] - A[list_q[i][0]-1] == li...
import itertools N, M, Q = map(int, input().split()) list_q = [] for i in range(Q): list_q.append(list(map(int, input().split()))) ans = 0 for A_ in itertools.combinations_with_replacement([i for i in range(1, M+1)], N): A = list(A_) tmp_ans = 0 for i in range(Q): if A[list_q[i][1]-1] - A[list...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
153
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000007; int main() { ll n, m, q; cin >> n >> m >> q; vector<ll> a(q), b(q), c(q), d(q); for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i]; vector<ll> A(10); ll ans = 0; for (int i = 1; i <= m; i++) { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000007; int main() { ll n, m, q; cin >> n >> m >> q; vector<ll> a(q), b(q), c(q), d(q); for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i]; vector<ll> A(10); ll ans = 0; for (int i = 1; i <= m; i++) { ...
[["+", 31, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
409
#include <iostream> using namespace std; int n, m, q, sir[11]; long long sol; struct lol { int a, b, c; long long d; }; lol v[51]; void bkt(int k) { for (int i = sir[k - 1]; i <= m; i++) { sir[k] = i; if (k == n) { long long s = 0; for (int j = 1; j <= q; j++) { if (sir[v[j].b] - sir[...
#include <iostream> using namespace std; int n, m, q, sir[11]; long long sol; struct lol { int a, b, c; long long d; }; lol v[51]; void bkt(int k) { for (int i = sir[k - 1]; i <= m; i++) { sir[k] = i; if (k == n) { long long s = 0; for (int j = 1; j <= q; j++) { if (sir[v[j].b] - sir[...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
256
//{{{ #include <bits/stdc++.h> using namespace std; const string truename = "Yes"; const string falsename = "No"; struct IoSetup { IoSetup() { cin.tie(nullptr); // ios::sync_with_stdio(false); cout << fixed << setprecision(12); cerr << fixed << setprecision(12); }; } ioSetup; //{{{ rep rrep loop ...
//{{{ #include <bits/stdc++.h> using namespace std; const string truename = "Yes"; const string falsename = "No"; struct IoSetup { IoSetup() { cin.tie(nullptr); // ios::sync_with_stdio(false); cout << fixed << setprecision(12); cerr << fixed << setprecision(12); }; } ioSetup; //{{{ rep rrep loop ...
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21]]
1
2,789
#include <bits/stdc++.h> using namespace std; #define ll long long #define db double #define pii pair<int, int> #define pli pair<ll, int> #define pil pair<int, ll> #define pll pair<ll, ll> #define mat vector<vector<int>> const int inf = 1 << 30; const ll linf = 1e18; const db EPS = 1e-7; template <class T> void chmin(T...
#include <bits/stdc++.h> using namespace std; #define ll long long #define db double #define pii pair<int, int> #define pli pair<ll, int> #define pil pair<int, ll> #define pll pair<ll, ll> #define mat vector<vector<int>> const int inf = 1 << 30; const ll linf = 1e18; const db EPS = 1e-7; template <class T> void chmin(T...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 2, 3, 4, 0, 191, 51, 83, 0, 13], ["+", 0, 2, 3, 4, 0, 191, 51, 83, 0, 13]]
1
358
N,M,Q = gets.split.map(&:to_i) ABCD = [] Q.times{|i| ABCD[i] = gets.split.map(&:to_i)} def rec(n,arr) if(arr.size == N) return ABCD.inject(0){|s,(a,b,c,d)| s + (arr[b-1] - arr[a-1] == c ? d : 0)} end return (n..M).map{|i| rec(i,arr+[i]) }.max end puts rec(0,[])
N,M,Q = gets.split.map(&:to_i) ABCD = [] Q.times{|i| ABCD[i] = gets.split.map(&:to_i)} def rec(n,arr) if(arr.size == N) return ABCD.inject(0){|s,(a,b,c,d)| s + (arr[b-1] - arr[a-1] == c ? d : 0)} end return (n..M).map{|i| rec(i,arr+[i]) }.max end puts rec(1,[])
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
4
136
#include <bits/stdc++.h> using namespace std; #define ALL(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define debug(x) \ cout << #x << ":"; \ cout << x << endl; #define d...
#include <bits/stdc++.h> using namespace std; #define ALL(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define debug(x) \ cout << #x << ":"; \ cout << x << endl; #define d...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
451
// C++ includes #include <bits/stdc++.h> // 俳句 using namespace std; // alias templates template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; // alias declaration using ll = long long; using str = string; using vll = V<ll>; using vvll = V<vll>; using vs = V<str>; // loops #define FOR(i, a, b...
// C++ includes #include <bits/stdc++.h> // 俳句 using namespace std; // alias templates template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; // alias declaration using ll = long long; using str = string; using vll = V<ll>; using vvll = V<vll>; using vs = V<str>; // loops #define FOR(i, a, b...
[["+", 0, 1, 0, 2, 3, 4, 0, 23, 0, 24], ["+", 0, 2, 3, 4, 0, 23, 0, 16, 17, 33], ["+", 0, 2, 3, 4, 0, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 23, 0, 25]]
1
386
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <stdio.h> #include <vector> using ll = long long int; const int INF = (1 << 30); const ll INFLL = (1ll << 60); const ll MOD = (ll)(1e9 + 7); #define l_ength size void mul_mod(ll &a, ll b) { a *= b; a %= MOD; } void add_mod(ll &a...
#include <algorithm> #include <iostream> #include <queue> #include <stack> #include <stdio.h> #include <vector> using ll = long long int; const int INF = (1 << 30); const ll INFLL = (1ll << 60); const ll MOD = (ll)(1e9 + 7); #define l_ength size void mul_mod(ll &a, ll b) { a *= b; a %= MOD; } void add_mod(ll &a...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
387
import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n,m,q=map(int,input().split()) x=[list(map(int,input().split())) for i in range(q)] for i in range(q): for j in range(2): x[i][j]-=1 a=[] def dfs(v): if len(v)>n: return if len(v)==n: a.append(v) for i in ran...
import sys sys.setrecursionlimit(1000000000) input = sys.stdin.readline n,m,q=map(int,input().split()) x=[list(map(int,input().split())) for i in range(q)] for i in range(q): for j in range(2): x[i][j]-=1 a=[] def dfs(v): if len(v)>n: return if len(v)==n: a.append(v) for i in ran...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
229
import itertools def check(lis, a): return sum((i[3] for i in a if lis[i[1]-1]-lis[i[0]-1]==i[2])) n, m, q = map(int, input().split()) a = ((int(i) for i in input().split(" ")) for j in range(q)) ans = 0 for i in itertools.combinations_with_replacement(range(m), n): ans = max(ans, check(i, a)) print(ans)
import itertools def check(lis, a): return sum((i[3] for i in a if lis[i[1]-1]-lis[i[0]-1]==i[2])) n, m, q = map(int, input().split()) a = [[int(i) for i in input().split(" ")] for j in range(q)] ans = 0 for i in itertools.combinations_with_replacement(range(m), n): ans = max(ans, check(i, a)) print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 668, 0, 24], ["-", 0, 1, 0, 662, 12, 668, 8, 668, 0, 24], ["+", 0, 656, 0, 1, 0, 662, 12, 658, 0, 70], ["+", 0, 1, 0, 662, 12, 658, 8, 658, 0, 70], ["-", 8, 668, 0, 659, 12, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 658, 8, 658, 0, 73], ["-", 0, 656, 0, 1, 0, 662, 12, 668, 0, 25], ["+"...
5
132
import itertools def check(lis, a): return sum((i[3] for i in a if lis[i[1]-1]-lis[i[0]-1]==i[2])) n, m, q = map(int, input().split()) a = ((int(i) for i in input().split(" ")) for j in range(q)) ans = 0 for i in itertools.combinations_with_replacement(range(m), n): ans = max(ans, check(i, a)) print(ans)
import itertools def check(lis, a): return sum((i[3] for i in a if lis[i[1]-1]-lis[i[0]-1]==i[2])) n, m, q = map(int, input().split()) a = tuple(tuple(int(i) for i in input().split(" ")) for j in range(q)) ans = 0 for i in itertools.combinations_with_replacement(range(m), n): ans = max(ans, check(i, a)) pr...
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 668, 8, 652, 63, 22]]
5
132
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define F(i, a, n) for (int i = a; i < n; i++) int max = 0; int n, m, q; int *a, *b, *c, *d; void dfs(int depth, int num, int *req) { if (depth == n) { int sum = 0; F(i, 0, n) { if (req[b[i] - 1] - req[a[i] - 1] == c[i]) ...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define F(i, a, n) for (int i = a; i < n; i++) int max = 0; int n, m, q; int *a, *b, *c, *d; void dfs(int depth, int num, int *req) { if (depth == n) { int sum = 0; F(i, 0, q) { if (req[b[i] - 1] - req[a[i] - 1] == c[i]) ...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
327
import sys sys.setrecursionlimit(10**7) n, m, q = map(int, input().split()) query = [list(map(int, input().split())) for _ in range(q)] def dfs(k, x): global mx if k == n: v = 0 for line in query: a, b, c, d = line if x[b] - x[a] == c: v += d if mx < v: mx = v ...
import sys sys.setrecursionlimit(10**7) n, m, q = map(int, input().split()) query = [list(map(int, input().split())) for _ in range(q)] def dfs(k, x): global mx if k == n: v = 0 for line in query: a, b, c, d = line if x[b] - x[a] == c: v += d if mx < v: mx = v ...
[["-", 0, 1, 0, 652, 3, 4, 0, 634, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 634, 0, 612]]
5
155
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; using ll = long long; struct P { int a, b, c, d; }; int main() { int n, m, q; cin >> n >> m >> q; int A[10]; vector<P> p(q); int r = 0; for (auto &[a,...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> using namespace std; using ll = long long; struct P { int a, b, c, d; }; int main() { int n, m, q; cin >> n >> m >> q; int A[10]; vector<P> p(q); int r = 0; for (auto &[a,...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
440
# -*- coding: utf-8 -*- """ Created on Sat May 2 20:59:14 2020 """ import sys #import numpy as np import itertools sys.setrecursionlimit(10 ** 9) N, M, Q = map(int,input().split()) abcd = [list(map(int,input().split())) for _ in range(Q)] A = itertools.combinations_with_replacement([i for i in range(1,M)],N) ans =...
# -*- coding: utf-8 -*- """ Created on Sat May 2 20:59:14 2020 """ import sys #import numpy as np import itertools sys.setrecursionlimit(10 ** 9) N, M, Q = map(int,input().split()) abcd = [list(map(int,input().split())) for _ in range(Q)] A = itertools.combinations_with_replacement([i for i in range(1,M+1)],N) ans...
[["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
136
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa ...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa ...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 3, 4, 0, 652, 3, 4, 0, 634, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 634, 0, 612]]
5
341
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa ...
import sys stdin = sys.stdin inf = 1 << 60 mod = 1000000007 ni = lambda: int(ns()) nin = lambda y: [ni() for _ in range(y)] na = lambda: list(map(int, stdin.readline().split())) nan = lambda y: [na() for _ in range(y)] nf = lambda: float(ns()) nfn = lambda y: [nf() for _ in range(y)] nfa ...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
302
#include <bits/stdc++.h> #include <numeric> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> inline bool chmax(T &a, T b) { if (a < b) { ...
#include <bits/stdc++.h> #include <numeric> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <typename T> inline bool chmax(T &a, T b) { if (a < b) { ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
393
#include <bits/stdc++.h> using namespace std; vector<int> a, b, c, d; int n, m, q; int ans; void dfs(vector<int> A) { if (A.size() == n + 1) { int sum = 0; for (int i = 0; i < q; i++) { if (A[b[i]] - A[a[i]] == c[i]) { sum += d[i]; } } ans = max(ans, sum); return; } a.push...
#include <bits/stdc++.h> using namespace std; vector<int> a, b, c, d; int n, m, q; int ans; void dfs(vector<int> A) { if (A.size() == n + 1) { int sum = 0; for (int i = 0; i < q; i++) { if (A[b[i]] - A[a[i]] == c[i]) { sum += d[i]; } } ans = max(ans, sum); return; } A.push...
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22]]
1
245
import itertools N,M,Q = map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(0,Q,1): tmp = list(map(int,input().split())) a.append(tmp[0]) b.append(tmp[1]) c.append(tmp[2]) d.append(tmp[3]) max_score = -1 for i in itertools.combinations_with_replacement(range(1,M,1),N): score = 0 f...
import itertools N,M,Q = map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(0,Q,1): tmp = list(map(int,input().split())) a.append(tmp[0]) b.append(tmp[1]) c.append(tmp[2]) d.append(tmp[3]) max_score = -1 for i in itertools.combinations_with_replacement(range(1,M+1,1),N): score = 0 ...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
183
#include <bits/stdc++.h> using namespace std; int n, m, q; vector<int> a; vector<int> b; vector<int> c; vector<int> d; int ans; void dfs(vector<int> A) { int tmp = 0; if (A.size() == n + 1) { for (int i = 0; i < q; i++) { if (A[b[i] - 1] - A[a[i] - 1] == c[i]) { tmp += d[i]; } } ...
#include <bits/stdc++.h> using namespace std; int n, m, q; vector<int> a; vector<int> b; vector<int> c; vector<int> d; int ans; void dfs(vector<int> A) { int tmp = 0; if (A.size() == n + 1) { for (int i = 0; i < q; i++) { if (A[b[i] - 1] - A[a[i] - 1] == c[i]) { tmp += d[i]; } } ...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
258
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) //#define int long l...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) //#define int long l...
[["-", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22]]
1
1,182
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) //#define int long l...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vb = vector<bool>; using vs = vector<string>; typedef pair<ll, ll> P; #define bit(n) (1LL << (n)) //#define int long l...
[["-", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
450
#include <bits/stdc++.h> using namespace std; struct req { long long a, b, c; long long d; } r[1005]; int main() { long long n, m, q; cin >> n >> m >> q; for (long long i = 0; i < q; i++) { cin >> r[i].a >> r[i].b >> r[i].c >> r[i].d; } vector<long long> k; for (long long i = 0; i < m; i++) { k....
#include <bits/stdc++.h> using namespace std; struct req { long long a, b, c; long long d; } r[1005]; int main() { long long n, m, q; cin >> n >> m >> q; for (long long i = 0; i < q; i++) { cin >> r[i].a >> r[i].b >> r[i].c >> r[i].d; } vector<long long> k; for (long long i = 0; i < m; i++) { k....
[["-", 0, 82, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 82, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
329
#include "bits/stdc++.h" #pragma GCC optimize "03" using namespace std; #define int long long int #define ld long double #define pi pair<int, int> #define pb push_back #define fi first #define se second #define IOS \ ios::sync_with_stdio(false); ...
#include "bits/stdc++.h" #pragma GCC optimize "03" using namespace std; #define int long long int #define ld long double #define pi pair<int, int> #define pb push_back #define fi first #define se second #define IOS \ ios::sync_with_stdio(false); ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
290
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<int>; using mat = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; const int INF = 1 << 30; in...
#include <bits/stdc++.h> using namespace std; using lint = long long; using P = pair<int, int>; using vec = vector<int>; using mat = vector<vector<int>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define endl "\n" constexpr int MOD = 1000000007; const int INF = 1 << 30; in...
[["-", 0, 14, 49, 53, 54, 55, 0, 356, 365, 13], ["+", 0, 14, 49, 53, 54, 55, 0, 356, 365, 13]]
1
330
N, M, Q = map(int, input().split()) query = [] for i in range(Q): a, b, c, d = map(int, input().split()) query.append([a, b, c, d]) def calcPoint(num): ret = 0 for q in range(Q): if num[query[q][1] - 1] - num[query[q][0] - 1] == query[q][2]: ret += query[q][3] return ret an...
N, M, Q = map(int, input().split()) query = [] for i in range(Q): a, b, c, d = map(int, input().split()) query.append([a, b, c, d]) def calcPoint(num): ret = 0 for q in range(Q): if num[query[q][1] - 1] - num[query[q][0] - 1] == query[q][2]: ret += query[q][3] return ret an...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
212
def dfs(nums, length, min_lim): ans = 0 if length == n: score_ret = 0 for a,b,c,d in req: if nums[b] - nums[a] == c: score_ret += d return score_ret else: for nu in range(min_lim, m+1): new_nums = nums + [nu] score = df...
def dfs(nums, length, min_lim): ans = 0 if length == n: score_ret = 0 for a,b,c,d in req: if nums[b] - nums[a] == c: score_ret += d return score_ret else: for nu in range(min_lim, m+1): new_nums = nums + [nu] score = df...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
154
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for i in range(Q)] ans = 0 for x in combinations_with_replacement(range(1, 11), 10): tmp = 0 for a, b, c, d in abcd: a -= 1 b -= 1 if x[a] + c == x[b]: ...
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for i in range(Q)] ans = 0 for x in combinations_with_replacement(range(1, M+1), 10): tmp = 0 for a, b, c, d in abcd: a -= 1 b -= 1 if x[a] + c == x[b]: ...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
114
N,M,Q=map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(Q): ta,tb,tc,td=map(int,input().split()) a+=[ta] b+=[tb] c+=[tc] d+=[td] maxs=0 A=[0 for i in range(N)] for i in intertools.combination_with_replacement(A,N): s=0 for k in range(Q): if i[b[k]-1]-i[a[k]-1]==c[k]: s+=d[k] maxs=max...
import itertools N,M,Q=map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(Q): ta,tb,tc,td=map(int,input().split()) a+=[ta] b+=[tb] c+=[tc] d+=[td] maxs=0 A=[i for i in range(M)] for i in itertools.combinations_with_replacement(A,N): s=0 for k in range(Q): if i[b[k]-1]-i[a[k]-1]==c[k]: s...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 658, 8, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 658, 8, 22], ["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 7, 12, 652, 63, 319, 500...
5
164
def dfs(A): global ans if len(A)==N: now=0 for i in l: if A[i[1]-1]-A[i[0]-1]==i[2]: now+=i[3] ans=max(ans,now) return A A.append(A[-1]) while A[-1]<=M: dfs(A) A[-1]+=1 N,M,Q=[int(x) for x in input().rstrip().split()] A=[1] l=[] ans=0 for i in range(Q): ...
def dfs(A): global ans if len(A)==N: now=0 for i in l: if A[i[1]-1]-A[i[0]-1]==i[2]: now+=i[3] ans=max(ans,now) return A A.append(A[-1]) while A[-1]<=M: dfs(A[:]) A[-1]+=1 N,M,Q=[int(x) for x in input().rstrip().split()] A=[1] l=[] ans=0 for i in range(Q): abcd=...
[["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 652, 3, 4, 0, 206, 206, 663, 0, 102], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
178
#include <algorithm> #include <cstdio> #include <iostream> #define ll long long using namespace std; int N, M, Q, a[50], b[50], c[50], d[50]; int ans = 0; int A[10]; void dfs(int cnt, int v) { if (cnt == N) { int tot = 0; for (int i = 0; i < N; i++) { if (A[b[i]] - A[a[i]] == c[i]) tot += d[i];...
#include <algorithm> #include <cstdio> #include <iostream> #define ll long long using namespace std; int N, M, Q, a[50], b[50], c[50], d[50]; int ans = 0; int A[10]; void dfs(int cnt, int v) { if (cnt == N) { int tot = 0; for (int i = 0; i < Q; i++) { if (A[b[i]] - A[a[i]] == c[i]) tot += d[i];...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
243
n,m,q=map(int,input().split()) abcd=[] for _ in range(q): a,b,c,d=map(int,input().split()) abcd.append((a,b,c,d)) ans=0 p=[] sys.setrecursionlimit(10**6) def dfs(x): if len(x)==n: p.append(x) else: for i in range(m-x[-1]+1): dfs(x+[x[-1]+i]) dfs([1]) # import itertools # p=itertools.combinations_with_replace...
n,m,q=map(int,input().split()) abcd=[] for _ in range(q): a,b,c,d=map(int,input().split()) abcd.append((a,b,c,d)) ans=0 p=[] import sys sys.setrecursionlimit(10**6) def dfs(x): if len(x)==n: p.append(x) else: for i in range(m-x[-1]+1): dfs(x+[x[-1]+i]) dfs([1]) # import itertools # p=itertools.combinations_w...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
211
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; int a[50]; int b[50]; int c[50]; int d[50]; in...
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; int a[50]; int b[50]; int c[50]; int d[50]; in...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
333
#include <algorithm> #include <iostream> using namespace std; const int N = 10, Q = 50; int aa[Q], bb[Q], cc[Q], dd[Q], n, m, q; int branch(int *xx, int k) { if (k == n) { int ans = 0; for (int i = 0; i < q; i++) if (xx[bb[i]] - xx[aa[i]] == cc[i]) ans += dd[i]; return ans; } int ans...
#include <algorithm> #include <iostream> using namespace std; const int N = 10, Q = 50; int aa[Q], bb[Q], cc[Q], dd[Q], n, m, q; int branch(int *xx, int k) { if (k == n) { int ans = 0; for (int i = 0; i < q; i++) if (xx[bb[i]] - xx[aa[i]] == cc[i]) ans += dd[i]; return ans; } int ans...
[["+", 0, 7, 10, 43, 49, 50, 51, 41, 15, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 41, 0, 101], ["+", 0, 7, 10, 43, 49, 50, 51, 41, 0, 102], ["+", 0, 7, 10, 43, 49, 50, 51, 41, 75, 13]]
1
274
comb = [] def f(n,cnt,ls): if cnt == n: comb.append(ls) return for i in range(ls[cnt-1],11): tmp = ls.copy() tmp[cnt] = i f(n,cnt+1,tmp) return ma = lambda :map(int,input().split()) ni = lambda:int(input()) n,m,q = ma() abcd = [] for i in range(q): abcd.append(li...
comb = [] def f(n,cnt,ls): if cnt == n: comb.append(ls) return for i in range(ls[cnt-1],m+1): tmp = ls.copy() tmp[cnt] = i f(n,cnt+1,tmp) return ma = lambda :map(int,input().split()) ni = lambda:int(input()) n,m,q = ma() abcd = [] for i in range(q): abcd.append(l...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
196
#include <algorithm> // count_ifに必要 #include <array> // sizeはコンパイル時定数で固定 #include <iomanip> // cout << setprecision(15) << x で小数の出力精度を指定 #include <iostream> #include <map> #include <numeric> // accumulate, gcd #include <queue> // priority_queue も入ってる #include <set> // 要素数は size() で取得 multisetもある #include <sta...
#include <algorithm> // count_ifに必要 #include <array> // sizeはコンパイル時定数で固定 #include <iomanip> // cout << setprecision(15) << x で小数の出力精度を指定 #include <iostream> #include <map> #include <numeric> // accumulate, gcd #include <queue> // priority_queue も入ってる #include <set> // 要素数は size() で取得 multisetもある #include <sta...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
464
/* * Welcome to my code! *---------------------------------------------* * author : lynmisakura(twitter : @andoreiji11) */ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include ...
/* * Welcome to my code! *---------------------------------------------* * author : lynmisakura(twitter : @andoreiji11) */ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include ...
[["-", 0, 14, 49, 53, 54, 55, 0, 356, 365, 13], ["+", 0, 14, 49, 53, 54, 55, 0, 356, 365, 13]]
1
591
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define per(i, a, b) for (int i = (b)-1; i >= (a); i--) #define pb push_back #define mp make_pair #define ...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, a, b) for (int i = (a); i < (b); i++) #define per(i, a, b) for (int i = (b)-1; i >= (a); i--) #define pb push_back #define mp make_pair #define ...
[["-", 49, 50, 51, 69, 341, 342, 0, 16, 12, 22], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
316
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; int a[MAXN], b[MAXN], c[MAXN], d[MAXN]; int n, m, q; vector<int> vec; int ans = 0; void solve(int x, int y) { if (x == n + 1) { int cur = 0; for (int i = 1; i <= n; i++) { if (vec[b[i]] - vec[a[i]] == c[i]) { cur += d[i]; ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; int a[MAXN], b[MAXN], c[MAXN], d[MAXN]; int n, m, q; vector<int> vec; int ans = 0; void solve(int x, int y) { if (x == n + 1) { int cur = 0; for (int i = 1; i <= q; i++) { if (vec[b[i]] - vec[a[i]] == c[i]) { cur += d[i]; ...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
272
#include <algorithm> #include <cassert> #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7; vector<st...
#include <algorithm> #include <cassert> #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1e9 + 7; vector<st...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
445
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, a, b) for (int i = a; i < b; i++) #define all(x) (x).begin(), (x).end() // 昇順ソート #define rall(v) (v).rbegin(), (v).rend() // 降順ソート #define FastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ty...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, a, b) for (int i = a; i < b; i++) #define all(x) (x).begin(), (x).end() // 昇順ソート #define rall(v) (v).rbegin(), (v).rend() // 降順ソート #define FastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ty...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]]
1
370
import sys sys.setrecursionlimit(10 ** 9) n,m,q = map(int,input().split()) abcd = [] for i in range(q): abcd.append(tuple(map(int,input().split()))) ans = 0 def dfs(l): global ans if len(l) == n: ans = max(check(l),ans) else: if len(l) == 0: mx = 1 else: mx = l[-1] for i in range(m...
import sys sys.setrecursionlimit(10 ** 9) n,m,q = map(int,input().split()) abcd = [] for i in range(q): abcd.append(tuple(map(int,input().split()))) ans = 0 def dfs(l): global ans if len(l) == n: ans = max(check(l),ans) else: if len(l) == 0: mx = 1 else: mx = l[-1] for i in range(m...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
186
def judge(): global num, a, b, c, d, q point = 0 for i in range(q): if (num[b[i]] - num[a[i]] == c[i]): point += d[i] return point def mk_num(i): global mx_p for j in range(num[i-1], 10): num[i] = j if (i == n): tmp = judge() if (mx_p...
def judge(): global num, a, b, c, d, q point = 0 for i in range(q): if (num[b[i]] - num[a[i]] == c[i]): point += d[i] return point def mk_num(i): global mx_p global m for j in range(num[i-1], m): num[i] = j if (i == n): tmp = judge() ...
[["+", 0, 656, 0, 14, 8, 196, 0, 299, 0, 636], ["+", 0, 656, 0, 14, 8, 196, 0, 299, 0, 22], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
227
#include <bits/stdc++.h> #define rep(i, m, n) for (int i = m; i < n; i++) #define co(n) cout << n << endl #define all(n) (n).begin(), (n).end() #define pb(n, m) n.push_back(m) #define pi(n, m) n.insert(n.begin(), m); #define ee(n) n.erase(n.end() - 1) #define eb(n) n.erase(n.begin()) #define check(n) ...
#include <bits/stdc++.h> #define rep(i, m, n) for (int i = m; i < n; i++) #define co(n) cout << n << endl #define all(n) (n).begin(), (n).end() #define pb(n, m) n.push_back(m) #define pi(n, m) n.insert(n.begin(), m); #define ee(n) n.erase(n.end() - 1) #define eb(n) n.erase(n.begin()) #define check(n) ...
[["+", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
411
#include <bits/stdc++.h> #define syosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<do...
#include <bits/stdc++.h> #define syosu(x) fixed << setprecision(x) using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<do...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
428
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define double long double #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) ...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <math.h> #include <queue> #include <stdio.h> #include <vector> using namespace std; #define int long long #define double long double #define rep(s, i, n) for (int i = s; i < n; i++) #define c(n) cout << n << endl; #define ic(n) ...
[["-", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22]]
1
1,815
N, M, Q = gets.split.map(&:to_i) S = Q.times.map { gets.split.map(&:to_i) } def calc_score(nums) score = 0 S.each do |a, b, c, d| next if nums[b] - nums[a] != c score += d end score end def dfs(n, nums) score = 0 if n == N + 1 return calc_score(nums) else (nums[n - 1]..M).each do |m|...
N, M, Q = gets.split.map(&:to_i) S = Q.times.map { gets.split.map(&:to_i) } def calc_score(nums) score = 0 S.each do |a, b, c, d| next if nums[b] - nums[a] != c score += d end score end def dfs(n, nums) score = 0 if n == N + 1 return calc_score(nums) else (nums[n - 1]..M).each do |m|...
[["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 612]]
4
164
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #in...
#include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #in...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
318
#include <bits/stdc++.h> #define ll long long #define pb push_back #define ull unsigned long long using namespace std; set<vector<int>> seqs; int n, m, q; void createSeq(vector<int> seq, int pos) { if (pos >= n) { seqs.insert(seq); return; } for (int i = seq[pos]; i <= m; i++) { seq[pos + 1] = i; ...
#include <bits/stdc++.h> #define ll long long #define pb push_back #define ull unsigned long long using namespace std; set<vector<int>> seqs; int n, m, q; void createSeq(vector<int> seq, int pos) { if (pos >= n - 1) { seqs.insert(seq); return; } for (int i = seq[pos]; i <= m; i++) { seq[pos + 1] ...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
323
[n, m, q] = [int(x) for x in input().split(' ')] a = [] b = [] c = [] d = [] for _ in range(q): tmp = [int(x) for x in input().split(' ')] a.append(tmp[0]-1) b.append(tmp[1]-1) c.append(tmp[2]) d.append(tmp[3]) x = [1] * 10 def next(x): for i in range(9, -1, -1): if x[i] != 10: x[i] += 1 ...
[n, m, q] = [int(x) for x in input().split(' ')] a = [] b = [] c = [] d = [] for _ in range(q): tmp = [int(x) for x in input().split(' ')] a.append(tmp[0]-1) b.append(tmp[1]-1) c.append(tmp[2]) d.append(tmp[3]) x = [1] * n def next(x): for i in range(n-1, -1, -1): if x[i] != m: x[i] += 1 ...
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+"...
5
252
N, M, Q = (int(i) for i in input().split()) ABCD = [] ans = -1 for _ in range(Q): ABCD.append([int(i) for i in input().split()] ) comb_list = [] import sys sys.setrecursionlimit(100000000) def recur(N, lis, c): if len(lis) == N: comb_list.append(lis) return if lis == []: for i in range(1, N+1): ...
N, M, Q = (int(i) for i in input().split()) ABCD = [] ans = -1 for _ in range(Q): ABCD.append([int(i) for i in input().split()] ) comb_list = [] import sys sys.setrecursionlimit(100000000) def recur(N, lis, c): if len(lis) == N: comb_list.append(lis) return if lis == []: for i in range(1, M+1): ...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22]]
5
218
/*input 10 10 1 1 10 9 1 */ #include "bits/stdc++.h" using namespace std; #define pb push_back #define mod 998244353 #define int long long int n, m, q; struct node { int a, b, c, d; node(int a1, int b1, int c1, int d1) : a(a1), b(b1), c(c1), d(d1) {} node() {} }; vector<node> Q; int ans = 0; int cal(vector<int>...
/*input 10 10 1 1 10 9 1 */ #include "bits/stdc++.h" using namespace std; #define pb push_back #define mod 998244353 #define int long long int n, m, q; struct node { int a, b, c, d; node(int a1, int b1, int c1, int d1) : a(a1), b(b1), c(c1), d(d1) {} node() {} }; vector<node> Q; int ans = 0; int cal(vector<int>...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
322
import itertools n,m,q = map(int,input().split()) mylist = [list(map(int, input().split())) for i in range(q)] #print(mylist) kouho = [] for i in range(1, m+1): kouho.append(i) #print(kouho) A = list(itertools.combinations(kouho,n)) #print(A) point = 0 maxp = 0 for a in A: point = 0 #print(a) for my in myli...
import itertools n,m,q = map(int,input().split()) mylist = [list(map(int, input().split())) for i in range(q)] #print(mylist) kouho = [] for i in range(1, m+1): kouho.append(i) #print(kouho) A = list(itertools.combinations_with_replacement(kouho,n)) #print(A) point = 0 maxp = 0 for a in A: point = 0 #print(a)...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
153
#include <iostream> using namespace std; typedef long long ll; int N, M, Q; int a[50], b[50], c[50], d[50]; int A[11] = {1}; int check() { int sum = 0; for (int i = 0; i < Q; i++) if (A[b[i]] - A[a[i]] == c[i]) sum += d[i]; return sum; } int f(int n) { if (n > N) return 0; if (n == N) re...
#include <iostream> using namespace std; typedef long long ll; int N, M, Q; int a[50], b[50], c[50], d[50]; int A[11] = {1}; int check() { int sum = 0; for (int i = 0; i < Q; i++) if (A[b[i]] - A[a[i]] == c[i]) sum += d[i]; return sum; } int f(int n) { if (n > N) return 0; if (n == N) re...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
265
from itertools import combinations_with_replacement as c n, m, q = [int(i) for i in input().split()] abc = [[int(i) for i in input().split()] for _ in range(q)] aa = list(range(1,m+1)) ans = 0 for bb in c(aa,m): cc = 0 for a, b, c, d in abc: if bb[b-1] - bb[a-1] == c: cc += d ans = max(a...
from itertools import combinations_with_replacement as c n, m, q = [int(i) for i in input().split()] abc = [[int(i) for i in input().split()] for _ in range(q)] aa = list(range(1,m+1)) ans = 0 for bb in c(aa, n): cc = 0 for a, b, c, d in abc: if bb[b-1] - bb[a-1] == c: cc += d ans = max(...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
127
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define fastio \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout...
[["-", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
312
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using V = vector<int>; using Vll = vector<ll>; using Vld = vector<ld>; using Vbo = vector<bool>; using VV = vector<V>; using VVll = vector<Vll>; using VVld = vector<Vld>; using VVbo = vector<Vbo>; using P = pair<int, int>; using...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using V = vector<int>; using Vll = vector<ll>; using Vld = vector<ld>; using Vbo = vector<bool>; using VV = vector<V>; using VVll = vector<Vll>; using VVld = vector<Vld>; using VVbo = vector<Vbo>; using P = pair<int, int>; using...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
798
#include <cstdio> using namespace std; long long n, m, q, a[505], b[505], c[505], d[505], ans = 0, dfn[105]; inline void dfs(long long step, long long min) { if (step == n + 1) { long long cur = 0; for (long long i = 1; i <= q; ++i) if (dfn[b[i]] - dfn[a[i]] == c[i]) cur += d[i]; if (cur > a...
#include <cstdio> using namespace std; long long n, m, q, a[505], b[505], c[505], d[505], ans = 0, dfn[105]; inline void dfs(long long step, long long min) { if (step == n + 1) { long long cur = 0; for (long long i = 1; i <= q; ++i) if (dfn[b[i]] - dfn[a[i]] == c[i]) cur += d[i]; if (cur > a...
[["-", 0, 37, 0, 34, 31, 2, 3, 4, 0, 13], ["+", 0, 37, 0, 34, 31, 2, 3, 4, 0, 13]]
1
250
import itertools n,m,q = map(int,input().split()) qset = [list(map(int, input().split())) for i in range(q)] aa=list(itertools.combinations(range(1,m+1), r=n)) ans=0 for i in range(len(aa)): score = 0 for n in range(len(qset)): a=aa[i] abcd=qset[n] if a[abcd[1]-1]-a[abcd[0]-1]==abcd[2]: score=s...
import itertools n,m,q = map(int,input().split()) qset = [list(map(int, input().split())) for i in range(q)] aa=list(itertools.combinations_with_replacement(range(1,m+1), r=n)) ans=0 for i in range(len(aa)): score = 0 for n in range(len(qset)): a=aa[i] abcd=qset[n] if a[abcd[1]-1]-a[abcd[0]-1]==abcd[...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
154
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define reprr(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; ll n, m, ...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define reprr(i, m, n) for (ll i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; ll n, m, ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
302
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define RREP0(i, n) for (int i = (n)-1; i >= 0; --i) #define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define RREP1(i, n) for (int i...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define RREP0(i, n) for (int i = (n)-1; i >= 0; --i) #define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) #define RREP1(i, n) for (int i...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
439
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define all(v) v.begin(), v.end() typedef long long ll; typedef pair<ll, ll> P; typedef vector<ll> vec; typedef vector<vec> mat; ll n, m, q, a[50], b[50], c[50], d[50]; ll ans = 0; void dfs(ll x) { ll y = x, z = 0, p = x; vec...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < n; i++) #define all(v) v.begin(), v.end() typedef long long ll; typedef pair<ll, ll> P; typedef vector<ll> vec; typedef vector<vec> mat; ll n, m, q, a[50], b[50], c[50], d[50]; ll ans = 0; void dfs(ll x) { ll y = x, z = 0, p = x; vec...
[["-", 8, 9, 0, 57, 64, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 7, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 64, 7, 15, 16, 12, 16, 17, 33], ["+", 0, 57, 64, 7, 15, 16, 12, 16, 12, 13]]
1
291
import itertools n, m, q = map(int, input().split()) abcd = [] a_pre = [] for i in range(q): abcd.append(list(map(int, input().split()))) lis = [i for i in range(1,m+1)] for pair in itertools.combinations(lis, n): a_pre.append(list(pair)) sum = 0 for i in range(len(a_pre)): sum_pre = 0 for j in range(len(...
import itertools n, m, q = map(int, input().split()) abcd = [] a_pre = [] for i in range(q): abcd.append(list(map(int, input().split()))) lis = [i for i in range(1, m + 1)] for pair in itertools.combinations_with_replacement(lis, n): a_pre.append(list(pair)) sum = 0 for i in range(len(a_pre)): sum_pre = 0 ...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
185
import itertools N, M, Q = list(map(int,input().split())) numbers = [i for i in range(1, M+1)] array = itertools.combinations_wih_replacement(numbers, N) input_data = [list(map(int,input().split())) for _ in range(Q)] max_score = 0 for A in array: score = 0 for _ in range(Q): a, b, c, d = input_data[...
import itertools N, M, Q = list(map(int,input().split())) numbers = [i for i in range(1, M+1)] array = itertools.combinations_with_replacement(numbers, N) input_data = [list(map(int,input().split())) for _ in range(Q)] max_score = 0 for A in array: score = 0 for _ in range(Q): a, b, c, d = input_data...
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
144
#include <bits/stdc++.h> using namespace std; int a[51], b[51], c[51], d[51]; int now[11]; long long ans = 0; int n, m, q; void check() { long long res = 0; for (int i = 1; i <= q; i++) { if (now[b[i]] - now[a[i]] == c[i]) res += d[i]; } ans = max(ans, res); } void dfs(int pos, int last) { if (pos =...
#include <bits/stdc++.h> using namespace std; int a[51], b[51], c[51], d[51]; int now[11]; long long ans = 0; int n, m, q; void check() { long long res = 0; for (int i = 1; i <= q; i++) { if (now[b[i]] - now[a[i]] == c[i]) res += d[i]; } ans = max(ans, res); } void dfs(int pos, int last) { if (pos =...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
250
import sys N, M, Q = map(int, sys.stdin.readline().strip().split()) con = [] # condition for i in range(Q): con.append(list(map(int, sys.stdin.readline().strip().split()))) dig = N + 1 # dig -1 桁の数字を作る A = [1] * dig point = 0 def make(min=1, digit=1): global point for i in range(min, 11): A[di...
import sys N, M, Q = map(int, sys.stdin.readline().strip().split()) con = [] # condition for i in range(Q): con.append(list(map(int, sys.stdin.readline().strip().split()))) dig = N + 1 # dig -1 桁の数字を作る A = [1] * dig point = 0 def make(min=1, digit=1): global point for i in range(min, M + 1): A...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
204
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define drep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < b; i++) #define drep(i, a, b) for (int i = a; i >= b; i--) #define fore(i, a) for (auto &i : a) #define all(x) (x).begin(), (x).end() using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long ...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
474
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define FORR(i, a, b) for (int i = b - 1; i >= a; --i) #define SORT(v) sort(v.begin(), v.end()) #define SORTR(v) sort(v.rbegin(), v.rend()) #define ...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, a, b) for (int i = a; i < b; ++i) #define FORR(i, a, b) for (int i = b - 1; i >= a; --i) #define SORT(v) sort(v.begin(), v.end()) #define SORTR(v) sort(v.rbegin(), v.rend()) #define ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
369
#include <bits/stdc++.h> using namespace std; int n, m, q, x[55], y[55], z[55], w[55]; int a[55], ans; void dfs(int dep, int lst) { if (dep == n + 1) { int res = 0; for (int i = 1; i <= q; i++) { if (a[y[i]] - a[x[i]] == z[i]) res += w[i]; } ans = max(ans, res); return; } for (...
#include <bits/stdc++.h> using namespace std; int n, m, q, x[55], y[55], z[55], w[55]; int a[55], ans; void dfs(int dep, int lst) { if (dep == n + 1) { int res = 0; for (int i = 1; i <= q; i++) { if (a[y[i]] - a[x[i]] == z[i]) res += w[i]; } ans = max(ans, res); return; } for (...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
249
import itertools n, m, q = map(int, input().split()) queries = [] for i in range(q): a, b, c, d = map(int, input().split()) queries.append((a, b, c, d)) max_score = 0 p = [1] * n cur = n-1 while cur >= 0: score = 0 for a, b, c, d in queries: if p[b - 1] - p[a - 1] == c: score += d ...
import itertools n, m, q = map(int, input().split()) queries = [] for i in range(q): a, b, c, d = map(int, input().split()) queries.append((a, b, c, d)) max_score = 0 p = [1] * n cur = n-1 while cur >= 0: score = 0 for a, b, c, d in queries: if p[b - 1] - p[a - 1] == c: score += d ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
5
195
#include <bits/stdc++.h> #define repl(i, l, r) for (long long i = (l); i < (r); i++) #define rep(i, n) for (long long i = 0; i < (n); ++i) #define per(i, n) for (long long i = (n); i >= 0; --i) const int INF = 2147483647; // int max const long long int MOD = 1000000007; using namespace std; using ll = long long; using ...
#include <bits/stdc++.h> #define repl(i, l, r) for (long long i = (l); i < (r); i++) #define rep(i, n) for (long long i = 0; i < (n); ++i) #define per(i, n) for (long long i = (n); i >= 0; --i) const int INF = 2147483647; // int max const long long int MOD = 1000000007; using namespace std; using ll = long long; using ...
[["-", 15, 339, 10, 381, 0, 43, 0, 42, 0, 22], ["+", 15, 339, 10, 381, 0, 43, 0, 42, 0, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 42, 0, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 42, 0, 22], ["-", 0, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 83, 0, 22]]
1
458
import itertools N,M,Q = map(int, input().split()) series = list() for i in range(Q): series.append(list(map(int,input().split()))) A = [x for x in range(1,M+1)] max_score = 0 for a in itertools.combinations(A,N): score = 0 for s in series: if (a[s[1]-1] - a[s[0]-1]) == s[2]: score += s[3] if score > m...
import itertools N,M,Q = map(int, input().split()) series = list() for i in range(Q): series.append(list(map(int,input().split()))) A = [x for x in range(1,M+1)] max_score = 0 for a in itertools.combinations_with_replacement(A,N): score = 0 for s in series: if (a[s[1]-1] - a[s[0]-1]) == s[2]: score += s[3] ...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
138
import itertools N, M, Q = list(map(int, input().split())) a = [] b = [] c = [] d = [] for i in range(Q): aa, bb, cc, dd = list(map(int, input().split())) a.append(aa) b.append(bb) c.append(cc) d.append(dd) Ms = [i for i in range(1, M+1)] res = 0 for s in itertools.combinations(Ms, N): sum_ = 0 for j i...
import itertools N, M, Q = list(map(int, input().split())) a = [] b = [] c = [] d = [] for i in range(Q): aa, bb, cc, dd = list(map(int, input().split())) a.append(aa) b.append(bb) c.append(cc) d.append(dd) Ms = [i for i in range(1, M+1)] res = 0 for s in itertools.combinations_with_replacement(Ms, N): ...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
180
import itertools n,m,q = map(int,input().split()) m_li = [] for i in range(1,m+1): m_li.append(i) li = [] mx = 0 for i in range(q): a,b,c,d = map(int,input().split()) li.append((a,b,c,d)) for v in itertools.combinations(m_li,n): buf = 0 for i in range(q): a = li[i][0] b = li[i][...
import itertools n,m,q = map(int,input().split()) m_li = [] for i in range(1,m+1): m_li.append(i) li = [] mx = 0 for i in range(q): a,b,c,d = map(int,input().split()) li.append((a,b,c,d)) for v in itertools.combinations_with_replacement(m_li,n): buf = 0 for i in range(q): a = li[i][0] ...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
182
#include "bits/stdc++.h" #define REP(i, num) for (int i = 0; i < (num); ++i) #define LOOP(i) while (i--) #define ALL(c) c.begin(), c.end() #define PRINTALL(c) \ for (auto pitr = c.begin(); pitr != c.end(); ++pitr) { \ cout << *pitr;...
#include "bits/stdc++.h" #define REP(i, num) for (int i = 0; i < (num); ++i) #define LOOP(i) while (i--) #define ALL(c) c.begin(), c.end() #define PRINTALL(c) \ for (auto pitr = c.begin(); pitr != c.end(); ++pitr) { \ cout << *pitr;...
[["+", 3, 4, 0, 74, 51, 23, 0, 16, 17, 33], ["+", 3, 4, 0, 74, 51, 23, 0, 16, 12, 13]]
1
569
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, co...
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, co...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
339
#include <algorithm> #include <bitset> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string> #include <utility> #include <vector> using namespace std; typedef long long int ll; typedef long double ld; template ...
#include <algorithm> #include <bitset> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string> #include <utility> #include <vector> using namespace std; typedef long long int ll; typedef long double ld; template ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
814
#include <bits/stdc++.h> #ifdef _PRINTDEBUG #include "lib/printdebug.hpp" #else #define printdebug(...) 1 #endif #define MOD_1_000_000_007 (1000000007LL) #define LINF (1LL << 60) #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep1(i, n) for (long long i = 1; i < (long long)(n); i++) #define r...
#include <bits/stdc++.h> #ifdef _PRINTDEBUG #include "lib/printdebug.hpp" #else #define printdebug(...) 1 #endif #define MOD_1_000_000_007 (1000000007LL) #define LINF (1LL << 60) #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define rep1(i, n) for (long long i = 1; i < (long long)(n); i++) #define r...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 0, 57, 75, 76, 0, 9, 0, 9, 0, 46]]
1
401
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; int n, m, q; int *a, *b, *c, *d; int x[10]; ll dfs(int i, ...
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; int n, m, q; int *a, *b, *c, *d; int x[15]; ll dfs(int i, ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
294
#include <bits/stdc++.h> #if ONLINE_JUDGE #define DEBUG false #else #define DEBUG true #endif #define fastcin() \ cin.tie(0); \ ios::sync_with_stdio(false) #define REP(i, k, n) for (int i = ...
#include <bits/stdc++.h> #if ONLINE_JUDGE #define DEBUG false #else #define DEBUG true #endif #define fastcin() \ cin.tie(0); \ ios::sync_with_stdio(false) #define REP(i, k, n) for (int i = ...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 33], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
690
# -*- coding: utf-8 -*- import itertools def main(): # 整数の入力 # スペース区切りの整数の入力 s = [int(x) for x in input().split(' ')] n = s[0] m = s[1] q = s[2] t_list = [] for i in range(q): s = [int(x) for x in input().split(' ')] t_list.append(s) seq = [x for x in range(1, m+1)]...
# -*- coding: utf-8 -*- import itertools def main(): # 整数の入力 # スペース区切りの整数の入力 s = [int(x) for x in input().split(' ')] n = s[0] m = s[1] q = s[2] t_list = [] for i in range(q): s = [int(x) for x in input().split(' ')] t_list.append(s) seq = [x for x in range(1, m+1)]...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
220
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #incl...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <ctime> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #incl...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
436
#include <bits/stdc++.h> #define FOR(i, x, y) for (i = x; i < y; i++) typedef long long ll; using namespace std; int a[11]; pair<pair<int, int>, pair<int, int>> s[50]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, q, ans = 0; cin >> n >> m >> q; for (int i = 0; i < q; i++) cin >> s[i]...
#include <bits/stdc++.h> #define FOR(i, x, y) for (i = x; i < y; i++) typedef long long ll; using namespace std; int a[11]; pair<pair<int, int>, pair<int, int>> s[50]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, q, ans = 0; cin >> n >> m >> q; for (int i = 0; i < q; i++) cin >> s[i]...
[["+", 31, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
393
def make_arr(x, arr): if len(arr) == n: pattern.append(arr) else: for i in range(x, 11): make_arr(i, arr + [i]) n, m, q = map(int, input().split()) query = [list(map(int, input().split())) for _ in range(q)] pattern = [] for i in range(1, m + 1): make_arr(i, [i]) ans = 0 for p...
def make_arr(x, arr): if len(arr) == n: pattern.append(arr) else: for i in range(x, m + 1): make_arr(i, arr + [i]) n, m, q = map(int, input().split()) query = [list(map(int, input().split())) for _ in range(q)] pattern = [] for i in range(1, m + 1): make_arr(i, [i]) ans = 0 fo...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
170
import itertools n, m, q = map(int, input().split()) l = [] for i in range(q): a, b, c, d = map(int, input().split()) l.append([a-1, b-1, c, d]) ll = [i for i in range(1, 11)] h = itertools.combinations_with_replacement(ll, n) ans = 0 for v in h: vl = list(v) cnt = 0 for i in range(q): ai, b...
import itertools n, m, q = map(int, input().split()) l = [] for i in range(q): a, b, c, d = map(int, input().split()) l.append([a-1, b-1, c, d]) ll = [i for i in range(1, m+1)] h = itertools.combinations_with_replacement(ll, n) ans = 0 for v in h: vl = list(v) cnt = 0 for i in range(q): ai, ...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
159
import itertools N, M, Q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(Q)] M_chr = [] for i in range(1,M+1): M_chr.append(str(i)) As = list(itertools.combinations(M_chr, N)) pointA_max = 0 for i, A in enumerate(As): pointA = 0 for i in range(Q): a = abcd[i][0] ...
import itertools N, M, Q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(Q)] M_chr = [] for i in range(1,M+1): M_chr.append(str(i)) As = list(itertools.combinations_with_replacement(M_chr, N)) pointA_max = 0 for i, A in enumerate(As): pointA = 0 for i in range(Q): ...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
184
import itertools N, M, Q = map(int, input().split()) a = [list(map(int, input().split())) for l in range(Q)] b = [1]*N c = 0 for i in range(Q): if b[a[i][2]-1]-b[a[i][1]-1] == a[i][3]: c += a[i][4] C = c for k in range(1,M): nums = [i for i in range(N-1)] for balls in itertools.combinations_with_replacement(n...
import itertools N, M, Q = map(int, input().split()) a = [list(map(int, input().split())) for l in range(Q)] b = [1]*N c = 0 for i in range(Q): if b[a[i][1]-1]-b[a[i][0]-1] == a[i][2]: c += a[i][3] C = c for k in range(1,M): nums = [i for i in range(N-1)] for balls in itertools.combinations_with_replacement(n...
[["-", 0, 657, 31, 206, 206, 657, 31, 206, 206, 612], ["+", 0, 657, 31, 206, 206, 657, 31, 206, 206, 612], ["-", 0, 657, 12, 206, 206, 657, 31, 206, 206, 612], ["+", 0, 657, 12, 206, 206, 657, 31, 206, 206, 612], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 206, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 206, 612], ["-", 64,...
5
251
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); 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; } #define all(x) (x).begin(), ...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (ll)(n); 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; } #define all(x) (x).begin(), ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
750
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> ...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
648
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <str...
#include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <deque> #include <functional> #include <iostream> #include <list> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include <str...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
483