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
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #includ...
#include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #includ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
322
from collections import Counter import sys sys.setrecursionlimit(200000) def read(): N, M, Q = map(int, input().split()) ABCD = [] for i in range(Q): a, b, c, d = map(int, input().split()) ABCD.append((a, b, c, d)) return N, M, Q, ABCD def check(N, M, Q, ABCD, x): score = 0 f...
from collections import Counter import sys sys.setrecursionlimit(200000) def read(): N, M, Q = map(int, input().split()) ABCD = [] for i in range(Q): a, b, c, d = map(int, input().split()) ABCD.append((a, b, c, d)) return N, M, Q, ABCD def check(N, M, Q, ABCD, x): score = 0 f...
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
356
import sys,bisect,string,math,time,functools,random from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter from itertools import permutations,combinations,groupby def Golf():*a,=map(int,open(0)) def I():return int(input()) def S_():return input() def IS():return input().split() def...
import sys,bisect,string,math,time,functools,random from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter from itertools import permutations,combinations,groupby def Golf():*a,=map(int,open(0)) def I():return int(input()) def S_():return input() def IS():return input().split() def...
[["-", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 12, 612]]
5
1,718
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; #define REP(i, p, n) for (ll i = p; i < ll(n...
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; #define REP(i, p, n) for (ll i = p; i < ll(n...
[["+", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 83, 0, 46]]
1
291
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; #define REP(i, p, n) for (ll i = p; i < ll(n...
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <vector> using namespace std; #define REP(i, p, n) for (ll i = p; i < ll(n...
[["-", 10, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 10, 43, 49, 50, 51, 23, 0, 41, 64, 13]]
1
309
#include <bits/stdc++.h> using namespace std; int N, M, Q; vector<vector<int>> vec(51, vector<int>(4)); vector<int> tmp; long long Max = 0; void calc(int a) { if (a == N) { long long sum = 0; for (int i = 0; i < Q; i++) { if (tmp[vec[i][1]] - tmp[vec[i][0]] != vec[i][2]) { continue; } ...
#include <bits/stdc++.h> using namespace std; int N, M, Q; vector<vector<int>> vec(51, vector<int>(4)); vector<int> tmp; long long Max = 0; void calc(int a) { if (a == N) { long long sum = 0; for (int i = 0; i < Q; i++) { if (tmp[vec[i][1]] - tmp[vec[i][0]] != vec[i][2]) { continue; } ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
289
import itertools import numpy as np N, M, Q = map(int, input().split()) A = np.array(list(itertools.combinations_with_replacemeent(range(1, M+1), N))) s = np.zeros(len(A), np.int32) for i in range(Q): a, b, c, d = map(int, input().split()) s += d * (A[:, b-1] - A[:, a-1] == c) print(s.max())
import itertools import numpy as np N, M, Q = map(int, input().split()) A = np.array(list(itertools.combinations_with_replacement(range(1, M+1), N))) s = np.zeros(len(A), np.int32) for i in range(Q): a, b, c, d = map(int, input().split()) s += d * (A[:, b-1] - A[:, a-1] == c) print(s.max())
[["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
125
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; #define rep(i, m, n) for (int(i) = (int)(m); (i) < (int)(n); ++(i)) #define rREP(i, m, n) for (int(i) = (n)-1; (i) >= (m); --(i)) #define all(x) (x).begin(), (x).end() #define out(y, x, h, w) (y) < 0 || (x) < 0 || (y)...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; #define rep(i, m, n) for (int(i) = (int)(m); (i) < (int)(n); ++(i)) #define rREP(i, m, n) for (int(i) = (n)-1; (i) >= (m); --(i)) #define all(x) (x).begin(), (x).end() #define out(y, x, h, w) (y) < 0 || (x) < 0 || (y)...
[["-", 0, 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
449
import itertools def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) N,M,Q = map(int, input().split()) L = [] for i in range(1,M+1,1): L.append(i) A = [] B = [] C = [] D = [] for _ in range(Q): a,b,c,d = map(int, input().split()) A.append(a) B.ap...
import itertools def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) N,M,Q = map(int, input().split()) L = [] for i in range(1,M+1,1): L.append(i) A = [] B = [] C = [] D = [] for _ in range(Q): a,b,c,d = map(int, input().split()) A.append(a) B.ap...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
225
#include <bits/stdc++.h> using namespace std; int main() { int n, m, q; cin >> n >> m >> q; int A[10]; int atai[q][4]; long long ans = 0; long long max = 0; for (int i = 0; i < q; i++) { for (int j = 0; j < 4; j++) { cin >> atai[i][j]; } } for (A[0] = 0; A[0] <= m; A[0]++) { for (A...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, q; cin >> n >> m >> q; int A[10]; int atai[q][4]; long long ans = 0; long long max = 0; for (int i = 0; i < q; i++) { for (int j = 0; j < 4; j++) { cin >> atai[i][j]; } } for (A[0] = 1; A[0] <= m; A[0]++) { for (A...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 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], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]...
1
446
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; const ll INF = 1e9; const ll MOD = 1e9 + 7; #define all(v) v.begin(), v.end() #define repi(i, n, init) for (ll i = init; i < (n); i++) #define repd(i, n, init) for (ll i = (n); i >= init; i--) #define repm(i, m) for (a...
#include <algorithm> #include <iostream> #include <vector> using namespace std; typedef long long ll; const ll INF = 1e9; const ll MOD = 1e9 + 7; #define all(v) v.begin(), v.end() #define repi(i, n, init) for (ll i = init; i < (n); i++) #define repd(i, n, init) for (ll i = (n); i >= init; i--) #define repm(i, m) for (a...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
401
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <numeric> #include <vector> constexpr int SINT_MAX = std::numeric_limits<int>::max(); constexpr int SINT_MIN = std::numeric_limits<int>::min(); #define YesNo(b) ((b) ? "Yes" : "No") #define YESNO(b) ((b) ? "YES" : "NO") using names...
#include <algorithm> #include <climits> #include <cmath> #include <iostream> #include <numeric> #include <vector> constexpr int SINT_MAX = std::numeric_limits<int>::max(); constexpr int SINT_MIN = std::numeric_limits<int>::min(); #define YesNo(b) ((b) ? "Yes" : "No") #define YESNO(b) ((b) ? "YES" : "NO") using names...
[["-", 8, 9, 0, 43, 49, 50, 51, 41, 64, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 41, 64, 13]]
1
389
N, M, Q = map(int, input().split()) s = list(list(map(int, input().split())) for _ in range(Q)) mx = 0 a = [1]*10 for s1 in range(1, M+1): a[0] = s1 for s2 in range(s1, M+1): a[1] = s2 for s3 in range(s2, M+1): a[2] = s3 for s4 in range(s3, M+1): a[3] = ...
N, M, Q = map(int, input().split()) s = list(list(map(int, input().split())) for _ in range(Q)) mx = 0 a = [1]*10 for s1 in range(1, M+1): a[0] = s1 for s2 in range(s1, M+1): a[1] = s2 for s3 in range(s2, M+1): a[2] = s3 for s4 in range(s3, M+1): a[3] = ...
[["+", 15, 666, 0, 657, 31, 206, 206, 657, 17, 33], ["+", 15, 666, 0, 657, 31, 206, 206, 657, 12, 612], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 17, 33], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 12, 612]]
5
292
def main(): n, m, q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in [0]*q] que = [[0]] for _ in range(n): que2 = [] for qq in que: i = qq[-1] for j in range(i, m+1): que2.append(qq+[j]) que = que2 ans = 0 ...
def main(): n, m, q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in [0]*q] que = [[1]] for _ in range(n): que2 = [] for qq in que: i = qq[-1] for j in range(i, m+1): que2.append(qq+[j]) que = que2 ans = 0 ...
[["-", 0, 1, 0, 662, 12, 634, 0, 634, 0, 612], ["+", 0, 1, 0, 662, 12, 634, 0, 634, 0, 612]]
5
159
from itertools import combinations n,m,q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(q)] ans = 0 for case in combinations([i for i in range(1,n+m+1)],n): now = 0 A = [x-i for i,x in enumerate(case)] for i in range(q): a,b,c,d = abcd[i] if A[b-1]-A[a-1]...
from itertools import combinations n,m,q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(q)] ans = 0 for case in combinations([i for i in range(1,n+m)],n): now = 0 A = [x-i for i,x in enumerate(case)] for i in range(q): a,b,c,d = abcd[i] if A[b-1]-A[a-1] =...
[["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
147
package main import ( "bufio" "fmt" "os" "strconv" ) type TupleInt struct { a int b int c int d int } func main() { sc := NewScanner() N, M, Q := sc.NextInt(), sc.NextInt(), sc.NextInt() T := make([]TupleInt, Q) for i := 0; i < Q; i++ { T[i] = TupleInt{sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextI...
package main import ( "bufio" "fmt" "os" "strconv" ) type TupleInt struct { a int b int c int d int } func main() { sc := NewScanner() N, M, Q := sc.NextInt(), sc.NextInt(), sc.NextInt() T := make([]TupleInt, Q) for i := 0; i < Q; i++ { T[i] = TupleInt{sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextI...
[["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 433], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 433]]
7
1,133
n,m,q=map(int,input().split()) arr=[list(map(int,input().split())) for _ in range(q)] ans=0 for i1 in range(1,m+1): for i2 in range(i1,m+1): for i3 in range(i2,m+1): for i4 in range(i3,m+1): for i5 in range(i4,m+1): for i6 in range(i5,m+1): for i7 in range(i6,m+1): ...
n,m,q=map(int,input().split()) arr=[list(map(int,input().split())) for _ in range(q)] ans=0 for i1 in range(1,m+1): for i2 in range(i1,m+1): for i3 in range(i2,m+1): for i4 in range(i3,m+1): for i5 in range(i4,m+1): for i6 in range(i5,m+1): for i7 in range(i6,m+1): ...
[["-", 0, 57, 15, 666, 0, 657, 12, 206, 206, 612], ["+", 0, 57, 15, 666, 0, 657, 12, 206, 206, 22]]
5
234
import itertools def c165(n, m, q, adli): ans = 0 li = list(itertools.combinations_with_replacement((1, m+1), n)) for i in li: count = 0 for a, b, c, d in adli: if i[b-1] - i[a-1] == c: count += d ans = max(ans, count) return ans def main(): n,...
import itertools def c165(n, m, q, adli): ans = 0 li = list(itertools.combinations_with_replacement(range(1,m+1), n)) for i in li: count = 0 for a, b, c, d in adli: if i[b-1] - i[a-1] == c: count += d ans = max(ans, count) return ans def main(): ...
[["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22]]
5
157
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; int n, m, q; vector<int> a, b, c, d; ll ans = 0; void dfs(string s) { if ((int)s.size() == n) { ll sum = 0; for (int i = 0; i < q; i++) { if (s[b[i]] - s[a[i]] == c[i]) sum += d[i]; } ans = ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; int n, m, q; vector<int> a, b, c, d; ll ans = 0; void dfs(string s) { if ((int)s.size() == n) { ll sum = 0; for (int i = 0; i < q; i++) { if (s[b[i]] - s[a[i]] == c[i]) sum += d[i]; } ans = ...
[["-", 10, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 10, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 5, 0, 62], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35]]
1
282
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return map(int, sys.stdin.readline().split()) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return map(int, sys.stdin.readline().split()) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i...
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73]]
5
341
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return map(int, sys.stdin.readline().split()) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return map(int, sys.stdin.readline().split()) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i...
[["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612]]
5
393
/* author : seryu title : ABC165C_"Many Requirements" */ #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define reps(i, n) for (int i = 1; i <= n; i++) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ERASE(x, val) x.erase(remove(all(x), val), x....
/* author : seryu title : ABC165C_"Many Requirements" */ #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define reps(i, n) for (int i = 1; i <= n; i++) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ERASE(x, val) x.erase(remove(all(x), val), x....
[["-", 75, 76, 0, 9, 0, 43, 49, 50, 51, 13], ["+", 75, 76, 0, 9, 0, 43, 49, 50, 51, 13]]
1
428
#include <bits/stdc++.h> #define ll long long #define ALL(v) (v).begin(), (v).end() #define REP(i, p, n) for (int i = p; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define dump(a) (cerr << #a << "=" << (a) << endl) #define DUMP(list) \ cout << "{ "; ...
#include <bits/stdc++.h> #define ll long long #define ALL(v) (v).begin(), (v).end() #define REP(i, p, n) for (int i = p; i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) #define dump(a) (cerr << #a << "=" << (a) << endl) #define DUMP(list) \ cout << "{ "; ...
[["-", 3, 4, 0, 2, 3, 4, 0, 23, 0, 24], ["-", 3, 4, 0, 2, 3, 4, 0, 23, 0, 25]]
1
383
# -*- coding: utf-8 -*- n,m,q = list(map(int,input().split())) abcd = [list(map(int,input().split())) for i in range(q)] def dfs(x,y,z,que): ret = 0 if x == 0: for a,b,c,d in abcd: if que[b-1] - que[a-1]==c: ret+=d return ret for i in range(y,z+1): ret ...
# -*- coding: utf-8 -*- n,m,q = list(map(int,input().split())) abcd = [list(map(int,input().split())) for i in range(q)] def dfs(x,y,z,que): ret = 0 if x == 0: for a,b,c,d in abcd: if que[b-1] - que[a-1]==c: ret+=d return ret for i in range(y,z+1): ret ...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
152
#include <bits/stdc++.h> using namespace std; #define ll long long int #define vl vector<ll> int main() { int N, M, Q; int a, b, c, d; cin >> N >> M >> Q; vector<vector<int>> t(60); for (int i = 0; i < Q; i++) { cin >> a >> b >> c >> d; t[i].push_back(a); t[i].push_back(b); t[i].push_back(c...
#include <bits/stdc++.h> using namespace std; #define ll long long int #define vl vector<ll> int main() { int N, M, Q; int a, b, c, d; cin >> N >> M >> Q; vector<vector<int>> t(60); for (int i = 0; i < Q; i++) { cin >> a >> b >> c >> d; t[i].push_back(a); t[i].push_back(b); t[i].push_back(c...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]]
1
382
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++) #define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define RITR(x, c) for (__typeof(c....
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++) #define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define RITR(x, c) for (__typeof(c....
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
417
#include <bits/stdc++.h> using namespace std; #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define rep(i, n) for (int i = 0; i < (n); ++i) #define per(i, n) for (int i = n - 1; i >= 0; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #define per1(i, n) for (int i = n; i >= 1; ++i) ...
#include <bits/stdc++.h> using namespace std; #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define rep(i, n) for (int i = 0; i < (n); ++i) #define per(i, n) for (int i = n - 1; i >= 0; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) #define per1(i, n) for (int i = n; i >= 1; ++i) ...
[["+", 51, 16, 31, 16, 31, 69, 341, 342, 0, 73], ["-", 12, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
321
#include <bits/stdc++.h> using namespace std; typedef long long ll; int A[50], B[50], C[50], D[50]; int arr[11]; int N, M, Q; ll sum, ans; void solve(int p, int n) { if (n == N + 1) { sum = 0; for (int i = 0; i < Q; i++) { if (arr[B[i]] - arr[A[i]] == C[i]) { sum += D[i]; } } ans =...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int A[50], B[50], C[50], D[50]; int arr[11]; int N, M, Q; int sum, ans; void solve(int p, int n) { if (n == N + 1) { sum = 0; for (int i = 0; i < Q; i++) { if (arr[B[i]] - arr[A[i]] == C[i]) { sum += D[i]; } } ans ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 0, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["+", 8, 9, 0, 7, 10, ...
1
248
#include <bits/stdc++.h> using namespace std; #define REP(i, init, n) for (int i = (int)(init); i < (int)(n); i++) #define vi vector<int> #define vl vector<long> #define vvi vector<vector<int>> #define vvl vector<vector<long>> #define pint pair<int, int> #define plong pair<long, long> long N, M, Q; vvl Que; long dfs...
#include <bits/stdc++.h> using namespace std; #define REP(i, init, n) for (int i = (int)(init); i < (int)(n); i++) #define vi vector<int> #define vl vector<long> #define vvi vector<vector<int>> #define vvl vector<vector<long>> #define pint pair<int, int> #define plong pair<long, long> long N, M, Q; vvl Que; long dfs...
[["-", 75, 76, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
344
#include <algorithm> #include <bitset> #include <cmath> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; /* sort(sp....
#include <algorithm> #include <bitset> #include <cmath> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <tuple> #include <vector> using namespace std; /* sort(sp....
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
414
#include <algorithm> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <stack> #include <stdlib.h> #include <string> #include <vector> using namespace std; #define PI 3.14159265358979 typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) #include <set> int n, m, q; int m...
#include <algorithm> #include <iomanip> #include <iostream> #include <math.h> #include <queue> #include <stack> #include <stdlib.h> #include <string> #include <vector> using namespace std; #define PI 3.14159265358979 typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) #include <set> int n, m, q; int m...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
338
#include <iostream> //#include <set> //#include <map> //#include <iomanip> //#include <algorithm> //#include <numeric> //#include <queue> //#include <stack> //#include <math.h> #include <vector> //#include <string> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL; // typedef long dou...
#include <iostream> //#include <set> //#include <map> //#include <iomanip> //#include <algorithm> //#include <numeric> //#include <queue> //#include <stack> //#include <math.h> #include <vector> //#include <string> //#include <list> //#include <deque> //#include <unordered_map> typedef long long LL; // typedef long dou...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
370
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define int long long typedef vector<int> VI; typedef pair<int, int> pii; typedef vector<pii> VP; typedef vector<strin...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define int long long typedef vector<int> VI; typedef pair<int, int> pii; typedef vector<pii> VP; typedef vector<strin...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
506
n, m, q = map(int, input().split()) tokutens = [list(input().split()) for i in range(q)] import itertools l = range(1, m+1) sums = [0] for v in itertools.combinations(l, n): v = list(v) sum = 0 for a, b, c, d in tokutens: if v[int(b)-1] - v[int(a)-1] == int(c): sum+=int(d) sums.append(sum) sums.sort...
n, m, q = map(int, input().split()) tokutens = [list(input().split()) for i in range(q)] import itertools l = range(1, m+1) sums = [0] for v in itertools.combinations_with_replacement(l, n): v = list(v) sum = 0 for a, b, c, d in tokutens: if v[int(b)-1] - v[int(a)-1] == int(c): sum+=int(d) sums.appen...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
141
#include <bits/stdc++.h> #include <iomanip> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int query[50][4]; int main() { int n, m, q; cin >> n >> m >> q; vector<int> a(n); rep(i, q) rep(j, 4) { int k; cin >> k; query[i][j] = k;...
#include <bits/stdc++.h> #include <iomanip> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int query[50][4]; int main() { int n, m, q; cin >> n >> m >> q; vector<int> a(n); rep(i, q) rep(j, 4) { int k; cin >> k; query[i][j] = k;...
[["+", 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
341
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) ts = [] for _ in range(Q): ts.append(tuple(map(int, input().split()))) print(ts) scores = [] for A in combinations_with_replacement(range(1, M + 1), N): score = 0 for t in ts: a, b, c, d = t if A[b - 1]...
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) ts = [] for _ in range(Q): ts.append(tuple(map(int, input().split()))) scores = [] for A in combinations_with_replacement(range(1, M + 1), N): score = 0 for t in ts: a, b, c, d = t if A[b - 1] - A[a - 1...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
129
#include "bits/stdc++.h" using namespace std; #define REP(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define rep(i, n) REP((i), 0, (n)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using tp3 = tuple<int, int, int>; using Mat = vector<vector<ll>>; constexpr int INF = 1 << 28; constexpr ...
#include "bits/stdc++.h" using namespace std; #define REP(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define rep(i, n) REP((i), 0, (n)) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using tp3 = tuple<int, int, int>; using Mat = vector<vector<ll>>; constexpr int INF = 1 << 28; constexpr ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
652
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define rep(i, k, n) for (int(i) = (k); (i) < (n); (i)++) #define max(a, b) (a) > (b) ? (a) : (b) #define min(a, b) (a) < (b) ? (a) : (b) #define abs(a, b) (a) < 0 ? (a) : -(a) #define llong long long int next(int *, int, int); int main() {...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define rep(i, k, n) for (int(i) = (k); (i) < (n); (i)++) #define max(a, b) (a) > (b) ? (a) : (b) #define min(a, b) (a) < (b) ? (a) : (b) #define abs(a, b) (a) < 0 ? (a) : -(a) #define llong long long int next(int *, int, int); int main() {...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
0
349
import itertools n,m,q = map(int,input().split()) abcd = [list(map(int,input().split())) for _ in range(q)] # abcd.sort(key=lambda x:x[3],reverse=True) # for x in abcd: # print("") # for v in x: # print(v,end=" ") arr = [i for i in range(1,11)] ans = 0 for per in itertools.combinations_with_replaceme...
import itertools n,m,q = map(int,input().split()) abcd = [list(map(int,input().split())) for _ in range(q)] # abcd.sort(key=lambda x:x[3],reverse=True) # for x in abcd: # print("") # for v in x: # print(v,end=" ") arr = [i for i in range(1,m+1)] ans = 0 for per in itertools.combinations_with_replacem...
[["-", 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
139
#include <bits/stdc++.h> #define ll long long #define ls id << 1 #define rs id << 1 | 1 #define mem(array, value, size, type) \ memset(array, value, ((size) + 5) * sizeof(type)) #define memarray(array, value) memset(array, value, sizeof(array)) #define pb(x) push_back(x) #defi...
#include <bits/stdc++.h> #define ll long long #define ls id << 1 #define rs id << 1 | 1 #define mem(array, value, size, type) \ memset(array, value, ((size) + 5) * sizeof(type)) #define memarray(array, value) memset(array, value, sizeof(array)) #define pb(x) push_back(x) #defi...
[["-", 0, 1, 0, 11, 31, 118, 28, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["-", 8, 9, 0, 1, 0, 11, 31, 118, 17, 131], ["-", 8, 9, 0, 1, 0, 11, 31, 118, 119, 120]]
1
416
#include <iostream> #include <vector> struct abcd { int a; int b; int c; int d; }; bool match(const std::vector<int> &A, const abcd &d) { return (A[d.b] - A[d.a] == d.c); } void setA(std::vector<int> &A, int n, int N, int M, int &result, const std::vector<abcd> &d) { // A[n]を設定 for (int j = A...
#include <iostream> #include <vector> struct abcd { int a; int b; int c; int d; }; bool match(const std::vector<int> &A, const abcd &d) { return (A[d.b] - A[d.a] == d.c); } void setA(std::vector<int> &A, int n, int N, int M, int &result, const std::vector<abcd> &d) { // A[n]を設定 for (int j = A...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
339
n,m,q = map(int ,input().split()) lst = [list(map(int, input().split())) for _ in range(q)] import itertools l = [i+1 for i in range(m)] lst2 = [com for com in itertools.combinations(l, n)] res = 0 for com in lst2: score = 0 for l in lst: if com[l[1]-1] - com[l[0]-1] == l[2]: score += l[3] ...
n,m,q = map(int ,input().split()) lst = [list(map(int, input().split())) for _ in range(q)] import itertools l = [i+1 for i in range(m)] lst2 = [com for com in itertools.combinations_with_replacement(l, n)] res = 0 for com in lst2: score = 0 for l in lst: if com[l[1]-1] - com[l[0]-1] == l[2]: ...
[["-", 12, 658, 0, 659, 12, 652, 63, 319, 319, 22], ["+", 12, 658, 0, 659, 12, 652, 63, 319, 319, 22]]
5
137
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> A; vector<int> B; vector<int> C; vector<int> D; ll MAX = 0; int M, S, Q; vector<int> P; void solve(int i) { if (i == S) { ll m = 0; // for(int j=0;j<P.size();j++){ // cout << P[j]; // } for (int j = 0; j < Q; j++)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> A; vector<int> B; vector<int> C; vector<int> D; ll MAX = 0; int M, S, Q; vector<int> P; void solve(int i) { if (i == S) { ll m = 0; for (int j = 0; j < Q; j++) { if (P[B[j] - 1] - P[A[j] - 1] == C[j]) { m += D[j]; ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
346
#include <bits/stdc++.h> #define select(_1, _2, x, ...) x #define repn(i, n) for (int i = 0; i < (n); i++) #define repr(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__) #define rrepn(i, n) for (int i = (n - 1); i >= 0; i--) #define rrepr(i, a, b) for (int i...
#include <bits/stdc++.h> #define select(_1, _2, x, ...) x #define repn(i, n) for (int i = 0; i < (n); i++) #define repr(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__) #define rrepn(i, n) for (int i = (n - 1); i >= 0; i--) #define rrepr(i, a, b) for (int i...
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
1
459
import itertools N, M, Q = map(int, input().split()) ABCD = [] for _ in range(Q): ABCD.append(list(map(int, input().split()))) M_list = [i+1 for i in range(M)] N_list = itertools.combinations(M_list, N) max_point = 0 for n in N_list: point = 0 for abcd in ABCD: if n[abcd[1]-1] - n[abcd[0]-1] == abc...
import itertools N, M, Q = map(int, input().split()) ABCD = [] for _ in range(Q): ABCD.append(list(map(int, input().split()))) M_list = [i+1 for i in range(M)] N_list = itertools.combinations_with_replacement(M_list, N) max_point = 0 for n in N_list: point = 0 for abcd in ABCD: if n[abcd[1]-1] - n[...
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
136
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, m, q; int a[52], b[52], c[52], d[52]; int v[11]; int ans; void brute(int i) { if (i == n + 1) { int tmp = 0; for (int j = 0; j < q; j++) { if (v[b[j]] - v[a[j]] == c[j]) { tmp += d[j]; } } ans = max(ans,...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, m, q; int a[52], b[52], c[52], d[52]; int v[11]; int ans; void brute(int i) { if (i == n + 1) { int tmp = 0; for (int j = 0; j < q; j++) { if (v[b[j]] - v[a[j]] == c[j]) { tmp += d[j]; } } ans = max(ans,...
[["-", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 31, 69, 28, 22]]
1
249
//#pragma GCC optimize(2) #include <bits/stdc++.h> #define int long long using namespace std; int a[55], n, m, k, b[55], c[55], d[55], s[55]; int ans; int val() { int re = 0; for (int i = 1; i <= k; i++) { if (s[b[i]] - s[a[i]] == c[i]) re += d[i]; } return re; } void dfs(int now, int t) { if (now >...
//#pragma GCC optimize(2) #include <bits/stdc++.h> #define int long long using namespace std; int a[55], n, m, k, b[55], c[55], d[55], s[55]; int ans; int val() { int re = 0; for (int i = 1; i <= k; i++) { if (s[b[i]] - s[a[i]] == c[i]) re += d[i]; } return re; } void dfs(int now, int t) { if (now >...
[["-", 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], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
234
// // Created on 2020/05/02. // #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #includ...
// // Created on 2020/05/02. // #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #includ...
[["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
408
import sys import math input = lambda:sys.stdin.readline().strip() n,m,q = map(int,input().split()) score = 0 def calc_score(arr): val = 0 for i in qs: a,b,c,d = i if arr[b-1]-arr[a-1]==c: val+=d return val def f(i,ne,arr): if i==n: global score score = max(...
import sys import math input = lambda:sys.stdin.readline().strip() n,m,q = map(int,input().split()) score = 0 def calc_score(arr): val = 0 for i in qs: a,b,c,d = i if arr[b-1]-arr[a-1]==c: val+=d return val def f(i,ne,arr): if i==n: global score score = max(...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612]]
5
193
import itertools N, M, Q = input().split() N = int(N) M = int(M) Q = int(Q) Num = [0 for i in range(Q)] for i in range(Q): Num[i] = list(map(int,input().split())) num = list(range(1, M+1)) A = [] for v in itertools.combinations(num, N): A.append(list(v)) score = 0 for w in A: scoreX = 0 for j in range(Q): b...
import itertools N, M, Q = input().split() N = int(N) M = int(M) Q = int(Q) Num = [0 for i in range(Q)] for i in range(Q): Num[i] = list(map(int,input().split())) num = list(range(1, M+1)) A = [] for v in itertools.combinations_with_replacement(num, N): A.append(list(v)) score = 0 for w in A: scoreX = 0 for j i...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
195
import itertools def iln(): return list(map(int, input().split())) def solve(N, M, constraints): max_so_far = 0 for seq in itertools.combinations(range(1, M + 1), N): #print("Processing sequence: ", seq) curr_score = 0 for const in constraints: a,b,c,d = const ...
import itertools def iln(): return list(map(int, input().split())) def solve(N, M, constraints): max_so_far = 0 for seq in itertools.combinations_with_replacement(range(1, M + 1), N): #print("Processing sequence: ", seq) curr_score = 0 for const in constraints: a,b,c,d = co...
[["-", 8, 196, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 7, 12, 652, 63, 319, 319, 22]]
5
149
def resolve(): n, m, q = map(int, input().split()) queue = [] for i in range(q): queue.append(list(map(int, input().split()))) ans = 0 import itertools l = list(itertools.combinations(range(1, n + m), m)) for i in l: a = [x - y for y, x in enumerate(i)] x = 0 ...
def resolve(): n, m, q = map(int, input().split()) queue = [] for i in range(q): queue.append(list(map(int, input().split()))) ans = 0 import itertools l = itertools.combinations(range(1, n + m), n) for i in l: a = [x - y for y, x in enumerate(i)] x = 0 for j ...
[["-", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
163
#include <bits/stdc++.h> #include <iostream> using namespace std; int a[55], b[55], c[55], d[55], n, m, q, x[10], sol = 0; void bkt(int poz, int val) { x[poz] = val; if (poz == n) { int nr = 0; for (int i = 1; i <= q; i++) { if (x[b[i]] - x[a[i]] == c[i]) { nr = nr + d[i]; } } s...
#include <bits/stdc++.h> #include <iostream> using namespace std; int a[55], b[55], c[55], d[55], n, m, q, x[15], sol = 0; void bkt(int poz, int val) { x[poz] = val; if (poz == n) { int nr = 0; for (int i = 1; i <= q; i++) { if (x[b[i]] - x[a[i]] == c[i]) { nr = nr + d[i]; } } s...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
1
224
#include <bits/stdc++.h> using namespace std; #define M 1000000007 #define MM 998244353 #define ll long long #define pb push_back #define mem0(a) memset(a, 0, sizeof(a)) #define mem1(a) memset(a, -1, sizeof(a)) #define memf(a) memset(a, false, sizeof(a)) #define all(v) v.begin(), v.end() #define sz(a) (ll) a.size() #d...
#include <bits/stdc++.h> using namespace std; #define M 1000000007 #define MM 998244353 #define ll long long #define pb push_back #define mem0(a) memset(a, 0, sizeof(a)) #define mem1(a) memset(a, -1, sizeof(a)) #define memf(a) memset(a, false, sizeof(a)) #define all(v) v.begin(), v.end() #define sz(a) (ll) a.size() #d...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
559
import itertools N,M,Q = map(int,input().split()) arr = [] for _ in range(Q): arr.append(list(map(int,input().split()))) ans = 0 nums = range(1,M+1) arrs = itertools.combinations(nums, N) for a in arrs: _sum = 0 a = list(a) for b in arr: if a[b[1]-1]-a[b[0]-1]==b[2]: _sum += b[3] ans = max(ans,_...
import itertools N,M,Q = map(int,input().split()) arr = [] for _ in range(Q): arr.append(list(map(int,input().split()))) ans = 0 nums = range(1,M+1) arrs = itertools.combinations_with_replacement(nums, N) for a in arrs: _sum = 0 a = list(a) for b in arr: if a[b[1]-1]-a[b[0]-1]==b[2]: _sum += b[3] ...
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
138
#!/usr/bin/env python3 import sys import itertools def chkA(A, Q, a, b, c, d): ret=0 for i in range(Q): ret += d[i] if A[b[i]-1] - A[a[i]-1] == c[i] else 0 return ret def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"): P=[i+1 for i in ...
#!/usr/bin/env python3 import sys import itertools #sys.setrecursionlimit(150000) def chkA(A, Q, a, b, c, d): ret=0 for i in range(Q): ret += d[i] if A[b[i]-1] - A[a[i]-1] == c[i] else 0 return ret def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "L...
[["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
384
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <typename T1, typename T2> bool chmin(T1 &a, T2 b) { if (a <= b) return 0; a = b; return 1; } template <typename T1, typename T2> bool chmax(T1 &a, T2 b) { if (a >= b) return 0; a = b; return 1; } int n, m, q; int a[55], b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <typename T1, typename T2> bool chmin(T1 &a, T2 b) { if (a <= b) return 0; a = b; return 1; } template <typename T1, typename T2> bool chmax(T1 &a, T2 b) { if (a >= b) return 0; a = b; return 1; } int n, m, q; int a[55], b...
[["-", 8, 9, 0, 57, 64, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 57, 64, 7, 15, 16, 12, 22]]
1
346
n, m, q = map(int, input().split()) A = [] B = [] C = [] D = [] for i in range(q): a, b, c, d = map(int, input().split()) A.append(a) B.append(b) C.append(c) D.append(d) import itertools ANS = [] for i in list(itertools.combinations_with_replacement([i for i in range(1, 11)], n)): L = list(i)...
n, m, q = map(int, input().split()) A = [] B = [] C = [] D = [] for i in range(q): a, b, c, d = map(int, input().split()) A.append(a) B.append(b) C.append(c) D.append(d) import itertools ANS = [] for i in list(itertools.combinations_with_replacement([i for i in range(1, m+1)], n)): L = list(i...
[["-", 0, 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
180
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define Rep(i, n) for (int i = 1; i <= (n); ++i) using LL = long long; using ULL = unsigned long long; int x[11]{1}, ans, n, m, q, a[51], b[51], c[51], d[51]; void judge() { int sum = 0; Rep(i, q) if (x[b[i]] - x[a[i]] =...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) #define Rep(i, n) for (int i = 1; i <= (n); ++i) using LL = long long; using ULL = unsigned long long; int x[11]{1}, ans, n, m, q, a[51], b[51], c[51], d[51]; void judge() { int sum = 0; Rep(i, q) if (x[b[i]] - x[a[i]] =...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
243
#include <bits/stdc++.h> using namespace std; int retsu[10]; int ans = 0; int n, m, q; int a[55], b[55], c[55], d[55]; void dfs(int num, int last) { //長さがnなら得点を数える // cout << "(" << num << "," << n << ")"; if (num == n) { int tmp = 0; for (int i = 0; i < q; i++) { if (retsu[b[i] - 1] - retsu[a[i] -...
#include <bits/stdc++.h> using namespace std; int retsu[15]; int ans = 0; int n, m, q; int a[55], b[55], c[55], d[55]; void dfs(int num, int last) { //長さがnなら得点を数える // cout << "(" << num << "," << n << ")"; if (num == n) { int tmp = 0; for (int i = 0; i < q; i++) { if (retsu[b[i] - 1] - retsu[a[i] -...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
231
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for (int64 i = 0; i < (n); i++) #define FOR(i, a, b) for (int64 i = (a); i < (b); i++) #define all(x) x.begin(), x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_...
#include <bits/stdc++.h> using namespace std; #define INF_LL (int64)1e18 #define INF (int32)1e9 #define REP(i, n) for (int64 i = 0; i < (n); i++) #define FOR(i, a, b) for (int64 i = (a); i < (b); i++) #define all(x) x.begin(), x.end() #define fs first #define sc second using int32 = int_fast32_t; using uint32 = uint_...
[["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 341, 342, 0, 16, 31, 16, 31, 16, 17, 33], ["+", 341, 342, 0, 16, 31, 16, 31, 16, 12, 13]]
1
743
N, M, Q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(Q)] ans = set() def point(x): temp = 0 for i in range(Q): a, b, c, d = abcd[i] if x[b-1] - x[a-1] == c: temp += d return temp def maker(x): dig = len(x) if dig == N: ans....
N, M, Q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(Q)] ans = set() def point(x): temp = 0 for i in range(Q): a, b, c, d = abcd[i] if x[b-1] - x[a-1] == c: temp += d return temp def maker(x): dig = len(x) if dig == N: ans....
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
175
#include <bits/stdc++.h> #define int long long using namespace std; int ans = 0; int N, M, Q; vector<int> a, b, c, d; void solve(int now, vector<int> vec) { if (now == 0) { int tmp = 0; for (int i = 0; i < Q; i++) { if (vec[b[i] - 1] - vec[a[i] - 1] == c[i]) tmp += d[i]; } ans = max(tm...
#include <bits/stdc++.h> #define int long long using namespace std; int ans = 0; int N, M, Q; vector<int> a, b, c, d; void solve(int now, vector<int> vec) { if (now == 0) { int tmp = 0; for (int i = 0; i < Q; i++) { if (vec[b[i] - 1] - vec[a[i] - 1] == c[i]) tmp += d[i]; } ans = max(tm...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
324
N,M,Q = map(int,input().split()) ab = [list(map(int,input().split())) for i in range(Q)] ans = 0 for i in range(2**(N+M)): cnt = 0 mm = bin(i) for j in list(str(mm)): if j=="1": cnt += 1 if cnt != M: continue li = [0] mm2 = 1 for j in range(N+M): if ...
N,M,Q = map(int,input().split()) ab = [list(map(int,input().split())) for i in range(Q)] ans = 0 for i in range(2**(N+M-1)): cnt = 0 mm = bin(i) for j in list(str(mm)): if j=="1": cnt += 1 if cnt != M-1: continue li = [0] mm2 = 1 for j in range(N+M-1): ...
[["+", 3, 4, 0, 657, 12, 23, 0, 657, 17, 33], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
186
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n); i >= 0; i--) #define repf(i, ...
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <map> #include <queue> #include <vector> using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n); i >= 0; i--) #define repf(i, ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
391
#pragma region Macros #pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define ld long double #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; i++) #define rep3(i, a, b) for (ll i = a; i >= b; i--) #define pii pair<int, int> #define pll pair<ll, ll> #defi...
#pragma region Macros #pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define ld long double #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; i++) #define rep3(i, a, b) for (ll i = a; i >= b; i--) #define pii pair<int, int> #define pll pair<ll, ll> #defi...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
1,574
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, s, f) for (int i = s; i < f; i++) #define INF 1000000000000000000 #define MOD 1000000007 #define endl "\n" #define fcout cout << fixed << setprecision(15) typedef p...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define rep2(i, s, f) for (int i = s; i < f; i++) #define INF 1000000000000000000 #define MOD 1000000007 #define endl "\n" #define fcout cout << fixed << setprecision(15) typedef p...
[["-", 0, 7, 15, 16, 12, 16, 31, 16, 17, 72], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
1
1,062
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> p2; ll n, m, q, a[105], b[105], c[105], d[105], val[15], res; void func(ll i) { if (i == n) { ll sum = 0; for (ll j = 0; j < q; j++) if (val[b[j]] - val[a[j]] == c[j]) sum += d[j]...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> p2; ll n, m, q, a[105], b[105], c[105], d[105], val[15], res; void func(ll i) { if (i == n) { ll sum = 0; for (ll j = 0; j < q; j++) if (val[b[j]] - val[a[j]] == c[j]) sum += d[j]...
[["-", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13]]
1
307
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool nextvect(vector<int> &A, int N, int M) { if (A[N - 1] < M) A[N - 1]++; else { int i = N - 2; while (i >= 0 && A[i] == M) i--; if (i == -1) return false; A[i]++; for (int j = i + 1; j < N; j++) ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; bool nextvect(vector<int> &A, int N, int M) { if (A[N - 1] < M) A[N - 1]++; else { int i = N - 2; while (i >= 0 && A[i] == M) i--; if (i == -1) return false; A[i]++; for (int j = i + 1; j < N; j++) ...
[["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 146], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
319
def next_A(A): rev_A = list(reversed(A)) max_num = M if rev_A[0] < M: rev_A[0] = rev_A[0] + 1 return list(reversed(rev_A)) for i in range(N): if rev_A[i] < max_num: rev_A[i] = rev_A[i] + 1 for j in reversed(range(i)): rev_A[j] = rev_A...
def next_A(A): rev_A = list(reversed(A)) max_num = M if rev_A[0] < M: rev_A[0] = rev_A[0] + 1 return list(reversed(rev_A)) for i in range(N): if rev_A[i] < max_num: rev_A[i] = rev_A[i] + 1 for j in reversed(range(i)): rev_A[j] = rev_A...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72]]
5
339
import itertools N,M,Q = map(int,input().split()) li = [] for i in range(Q): li.append(list(map(int,input().split()))) li.sort(key = lambda x:x[3]) num = [i for i in range(1,M+1)] l = list(itertools.combinations_with_replacement(num, M)) max_sum=-1 for i in range(len(l)): s = 0 for j in range(Q): if l[i][l...
import itertools N,M,Q = map(int,input().split()) li = [] for i in range(Q): li.append(list(map(int,input().split()))) li.sort(key = lambda x:x[3]) num = [i for i in range(1,M+1)] l = list(itertools.combinations_with_replacement(num, N)) max_sum=-1 for i in range(len(l)): s = 0 for j in range(Q): if l[i][l...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
183
#include <bits/stdc++.h> #pragma region Macro #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define SORT(v) sort(v.begin(), v.end()) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define vi vector<int> #define vvi vector<vector<int>> #define chmax(x, y...
#include <bits/stdc++.h> #pragma region Macro #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define SORT(v) sort(v.begin(), v.end()) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define vi vector<int> #define vvi vector<vector<int>> #define chmax(x, y...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
373
#include <bits/stdc++.h> using namespace std; int N, M, Q; vector<int> a(50), b(50), c(50), d(50); long long ans = 0; vector<int> A; void DFS(int pos, int x) { if (pos == M) { long long tmp = 0; for (int i = 0; i < Q; i++) { if (A[b[i] - 1] - A[a[i] - 1] == c[i]) tmp += d[i]; } ans = m...
#include <bits/stdc++.h> using namespace std; int N, M, Q; vector<int> a(50), b(50), c(50), d(50); long long ans = 0; vector<int> A; void DFS(int pos, int x) { if (pos == N) { long long tmp = 0; for (int i = 0; i < Q; i++) { if (A[b[i] - 1] - A[a[i] - 1] == c[i]) tmp += d[i]; } ans = m...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
256
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import combinations_with_replacement, accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from s...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import combinations_with_replacement, accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from s...
[["-", 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
296
N, M, Q = [int(_) for _ in input().split()] ABCD = [[int(_) for _ in input().split()] for _ in range(Q)] cand = [[i] for i in list(range(1, M + 1))] for i in range(M): candn = [] for l in cand: j = l[-1] candn += [l + [k] for k in range(j, M + 1)] cand = candn ans = 0 for l in cand: x = ...
N, M, Q = [int(_) for _ in input().split()] ABCD = [[int(_) for _ in input().split()] for _ in range(Q)] cand = [[i] for i in list(range(1, M + 1))] for i in range(N - 1): candn = [] for l in cand: j = l[-1] candn += [l + [k] for k in range(j, M + 1)] cand = candn ans = 0 for l in cand: ...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 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]]
5
173
#include <bits/stdc++.h> using namespace std; using ll = long long; // container util #define SORT(c) sort((c).begin(), (c).end()) // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // print #define pv(val) cerr << #val << '=' << (val) << endl const int INF = 1e9; in...
#include <bits/stdc++.h> using namespace std; using ll = long long; // container util #define SORT(c) sort((c).begin(), (c).end()) // repetition #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) // print #define pv(val) cerr << #val << '=' << (val) << endl const int INF = 1e9; in...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
295
/* NAME : RISHABH SINGH INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY */ #include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pii pair<int, int> #define bi __builtin_inf() #define ll long ...
/* NAME : RISHABH SINGH INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY */ #include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define int long long #define pii pair<int, int> #define bi __builtin_inf() #define ll long ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
526
def f(A, i, N, reqs, M, Q): if i == N: res = 0 for i in range(Q): a,b,c,d = reqs[i] if A[b] - A[a] == c: res += d return res b = 0 for n in range(A[i-1],M+1): A[i] = n b = max(b, f(A,i+1,N,reqs,M,Q)) return b def main(): ...
def f(A, i, N, reqs, M, Q): if i == N: res = 0 # print(A) for i in range(Q): a,b,c,d = reqs[i] if A[b] - A[a] == c: res += d # print(res) return res b = 0 for n in range(A[i-1],M+1): A[i] = n b = max(b, f(A,i+1,N...
[["-", 0, 652, 3, 4, 0, 657, 31, 634, 0, 612], ["+", 0, 652, 3, 4, 0, 657, 31, 634, 0, 612]]
5
220
#include <bits/stdc++.h> #define int long long const int MOD = 1e9 + 7; using pii = std::pair<int, int>; using namespace std; const int maxq = 55; int n, m, q, a[maxq], b[maxq], c[maxq], d[maxq]; int solve(int mask, int pos, int ma) { if (pos == n) { int cursum = 0; for (int i = 0; i < q; i++) { int ...
#include <bits/stdc++.h> #define int long long const int MOD = 1e9 + 7; using pii = std::pair<int, int>; using namespace std; const int maxq = 55; int n, m, q, a[maxq], b[maxq], c[maxq], d[maxq]; int solve(int mask, int pos, int ma) { if (pos == n) { int cursum = 0; for (int i = 0; i < q; i++) { int ...
[["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
315
#include "bits/stdc++.h" using namespace std; using ll = long long; #define rep(i, begin, n) for (int i = begin; i < n; i++) #define repe(i, begin, n) for (int i = begin; i <= n; i++) #define repr(i, begin, n) for (int i = begin; i > begin - n; i--) #define repre(i, begin, end) for (int i = begin; i >= end; i--) templ...
#include "bits/stdc++.h" using namespace std; using ll = long long; #define rep(i, begin, n) for (int i = begin; i < n; i++) #define repe(i, begin, n) for (int i = begin; i <= n; i++) #define repr(i, begin, n) for (int i = begin; i > begin - n; i--) #define repre(i, begin, end) for (int i = begin; i >= end; i--) templ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
367
import itertools n,m,q=map(int,input().split()) lis=[i for i in range(1,m+1)] lis=list(itertools.combinations(lis,n)) box=[0 for j in range(len(lis))] for i in range(q): que=list(map(int,input().split())) for j in range(len(lis)): if lis[j][que[1]-1]-lis[j][que[0]-1]==que[2]: box[j]+=que[3]...
import itertools n,m,q=map(int,input().split()) lis=[i for i in range(1,m+1)] lis=list(itertools.combinations_with_replacement(lis,n)) box=[0 for j in range(len(lis))] for i in range(q): que=list(map(int,input().split())) for j in range(len(lis)): if lis[j][que[1]-1]-lis[j][que[0]-1]==que[2]: ...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
148
import numpy as np import itertools N, M, Q = map(int, input().split(" ")) vals = [] for i in range(Q): vals.append([list(map(int, input().split(" ")))]) maxv = 0 cand = list(itertools.combinations_with_replacement(range(1, M+1), N)) for c in cand: sumv = 0 for v in vals: if (c[v[1]-1] - c[v...
import numpy as np import itertools N, M, Q = map(int, input().split(" ")) vals = [] for i in range(Q): vals.append(list(map(int, input().split(" ")))) maxv = 0 cand = list(itertools.combinations_with_replacement(range(1, M+1), N)) for c in cand: sumv = 0 for v in vals: if (c[v[1]-1] - c[v[0...
[["-", 0, 1, 0, 652, 3, 4, 0, 634, 0, 70], ["-", 0, 1, 0, 652, 3, 4, 0, 634, 0, 73]]
5
146
#include <iostream> #include <vector> using namespace std; int N, M, Q; int A[10]; int a[50], b[50], c[50], d[50]; long res = 0; void dfs(int depth, int num) { if (depth == N) { long tmp = 0; for (int i = 0; i < M; i++) { if (A[b[i]] - A[a[i]] == c[i]) tmp += d[i]; } res = tmp > res ?...
#include <iostream> #include <vector> using namespace std; int N, M, Q; int A[10]; int a[50], b[50], c[50], d[50]; long res = 0; void dfs(int depth, int num) { if (depth == N) { long tmp = 0; for (int i = 0; i < Q; i++) { if (A[b[i]] - A[a[i]] == c[i]) tmp += d[i]; } res = tmp > res ?...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
243
#include "bits/stdc++.h" using namespace std; /////////////////////////////////////////// const long long int INF = 1LL << 60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using P = pair<int, int>; using PLL = pair<ll, ll...
#include "bits/stdc++.h" using namespace std; /////////////////////////////////////////// const long long int INF = 1LL << 60; const long long int Mod = 1000000007; using ll = long long int; using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using P = pair<int, int>; using PLL = pair<ll, ll...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
627
import itertools n,m,q=list(map(int,input().split())) q_l=[list(map(int,input().split())) for _ in range(q)] #print(q_l) #bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)] bar_m = [i for i in range(m)] #print(bar_m) bar_l = list(itertools.combinations_with_replacement(bar_m,m)) #print(...
import itertools n,m,q=list(map(int,input().split())) q_l=[list(map(int,input().split())) for _ in range(q)] #bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)] bar_m = [i for i in range(m)] bar_l = list(itertools.combinations_with_replacement(bar_m,n)) score = 0 for bar in bar_l: s...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19]]
5
139
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FO...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FO...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
313
n,m,q=gets.split.map &:to_i s=[] result = [] q.times do num = gets.split.map &:to_i s << num end ar = [*(1..m)].combination(n).to_a ar.each do |ar| sum = 0 s.each do |s| a,b,c,d=s[0],s[1],s[2],s[3] sum = sum + d if ar[b-1] - ar[a-1] == c end result << sum end puts result.max
n,m,q=gets.split.map &:to_i s=[] result = [] q.times do num = gets.split.map &:to_i s << num end ar = [*(1..m)].repeated_combination(n).to_a ar.each do |ar| sum = 0 s.each do |s| a,b,c,d=s[0],s[1],s[2],s[3] sum = sum + d if ar[b-1] - ar[a-1] == c end result << sum end puts result.max
[["-", 0, 493, 0, 662, 12, 652, 486, 652, 735, 22], ["+", 0, 493, 0, 662, 12, 652, 486, 652, 735, 22]]
4
129
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPR(i, n) for (int i = (int)(n); i >= 0; i--) #define FOR(i, s, n) for (int i = (s); i < (int)(n); i++) #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; ll N, K, T, W, H, M, C; const int MAX = 5100000; c...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPR(i, n) for (int i = (int)(n); i >= 0; i--) #define FOR(i, s, n) for (int i = (s); i < (int)(n); i++) #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; ll N, K, T, W, H, M, C; const int MAX = 5100000; c...
[["-", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 8, 9, 0, 14, 49, 53, 54, 55, 0, 21], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78]]
1
1,003
from itertools import combinations as cmb N, M, Q = map(int, input().split()) a = [] b = [] c = [] d = [] s = 0 for _ in range(Q): _a, _b, _c, _d = map(int, input().split()) a.append(_a) b.append(_b) c.append(_c) d.append(_d) for A in cmb(range(1,M+1),N): _s = 0 for q in range(Q): ...
from itertools import combinations_with_replacement as cmb N, M, Q = map(int, input().split()) a = [] b = [] c = [] d = [] s = 0 for _ in range(Q): _a, _b, _c, _d = map(int, input().split()) a.append(_a) b.append(_b) c.append(_c) d.append(_d) for A in cmb(range(1,M+1),N): _s = 0 for q in ...
[["-", 0, 656, 0, 686, 141, 704, 141, 673, 0, 22], ["+", 0, 656, 0, 686, 141, 704, 141, 673, 0, 22]]
5
167
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #de...
#include <algorithm> #include <functional> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #de...
[["-", 0, 9, 0, 43, 49, 50, 51, 41, 64, 13], ["+", 0, 9, 0, 43, 49, 50, 51, 41, 64, 13]]
1
319
from itertools import combinations N, M, Q = map(int,input().split()) P = [list(map(int,input().split())) for i in range(Q)] A = list(itertools.combinations_with_replacement(range(1,M+1), N)) number = len(A) amount = 0 max_amount = 0 for i in range(number): #A for j in range(Q): # P bi = P[j][1] ...
import itertools N, M, Q = map(int,input().split()) P = [list(map(int,input().split())) for i in range(Q)] A = list(itertools.combinations_with_replacement(range(1,M+1), N)) number = len(A) amount = 0 max_amount = 0 for i in range(number): #A for j in range(Q): # P bi = P[j][1] ai = P[j][0] ...
[["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["-", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["-", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
175
#c import itertools n, m, q = map(int, input().split()) lslist = [] for i in range(q): a, b, c, d = map(int, input().split()) lslist.append([a, b, c, d]) print(lslist) # n=3 # m=4 # q=3 # ls1 = [1, 3, 3, 100] # ls2 = [1, 2, 2, 10] # ls3 = [1, 1, 0, 1000] # lslist = [ls1, ls2, ls3] acomn = list(itertools.com...
#c import itertools n, m, q = map(int, input().split()) lslist = [] for i in range(q): a, b, c, d = map(int, input().split()) lslist.append([a, b, c, d]) # n=3 # m=4 # q=3 # ls1 = [1, 3, 3, 100] # ls2 = [1, 2, 2, 10] # ls3 = [1, 1, 0, 1000] # lslist = [ls1, ls2, ls3] acomn = list(itertools.combinations_with...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
192
#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, Q; cin >> N >> M >> Q; int a[Q], b[Q], c[Q], d[Q]; rep(i, Q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; a[i]--; b[i]--; } int arr[10]; int ans = 0; for (arr[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, Q; cin >> N >> M >> Q; int a[Q], b[Q], c[Q], d[Q]; rep(i, Q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; a[i]--; b[i]--; } int arr[10]; int ans = 0; for (arr[0...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
1
424
from itertools import combinations_with_replacement as comb n,m,q = map(int, input().split(' ')) lis = [list(map(int, input().split())) for _ in range(q)] tes = comb(range(1,m)) res = 0 for i in tes: te = 0 for a,b,c,d in lis: if c == i[b-1] - i[a-1]: te += d res = max(te,res) print(res...
from itertools import combinations_with_replacement as comb n,m,q = map(int, input().split(' ')) lis = [list(map(int, input().split())) for _ in range(q)] tes = comb(range(1,m+1),n) res = 0 for i in tes: te = 0 for a,b,c,d in lis: if c == i[b-1] - i[a-1]: te += d res = max(te,res) print...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
118
N,M,Q=map(int,input().split()) al=list() for i in range(Q): a,b,c,d=map(int,input().split()) al.append([a,b,c,d]) Sum=0 Summax=0 cnt=0 for i1 in range(1,M+1): for i2 in range(i1,M+1): for i3 in range(i2,M+1): for i4 in range(i3,M+1): for i5 in range(i4,M+1): ...
N,M,Q=map(int,input().split()) al=list() for i in range(Q): a,b,c,d=map(int,input().split()) al.append([a,b,c,d]) Sum=0 Summax=0 cnt=0 for i1 in range(1,M+1): for i2 in range(i1,M+1): for i3 in range(i2,M+1): for i4 in range(i3,M+1): for i5 in range(i4,M+1): ...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
295
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long int llint; typedef pai...
#include <algorithm> #include <complex> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string.h> #include <string> #include <time.h> #include <vector> using namespace std; typedef long long int llint; typedef pai...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 75, 76, 0, 9, 0, 7, 15, 16, 17, 19], ["+", 75, 76, 0, 9, 0, 7, 15, 16, 17, 18]]
1
1,482
import itertools n, m, q = [int(x) for x in input().split()] tmp = [] for i in range(q): a, b, c, d = [int(x) for x in input().split()] tmp.append([a, b, c, d]) t = list(itertools.combinations_with_replacement(range(1, m + 1), m)) score = 0 for _t in t: _s = 0 for a, b, c, d in tmp: try: ...
import itertools n, m, q = [int(x) for x in input().split()] tmp = [] for i in range(q): a, b, c, d = [int(x) for x in input().split()] tmp.append([a, b, c, d]) t = list(itertools.combinations_with_replacement(range(1, m + 1), n)) score = 0 for _t in t: _s = 0 for a, b, c, d in tmp: if c ==...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 246, 0, 247], ["-", 8, 196, 0, 7, 8, 196, 0, 246, 0, 102], ["-", 0, 7, 8, 196, 0, 246, 0, 671, 0, 672], ["-", 0, 7, 8, 196, 0, 246, 0, 671, 0, 102], ["-", 0, 246, 0, 671, 0, 196, 0, 674, 0, 675]]
5
153
N, M, Q = map(int, input().split()) check = list() for i in range(Q): check.append(list(map(int, input().split()))) ans = 0 for i1 in range(1, M+1): for i2 in range(i1, M+1): for i3 in range(i2, M+1): for i4 in range(i3, M+1): for i5 in range(i4, M+1): for i6 in range(i5, M+1): ...
N, M, Q = map(int, input().split()) check = list() for i in range(Q): check.append(list(map(int, input().split()))) ans = 0 for i1 in range(1, M+1): for i2 in range(i1, M+1): for i3 in range(i2, M+1): for i4 in range(i3, M+1): for i5 in range(i4, M+1): for i6 in range(i5, M+1): ...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
288
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define PRINT(v) \ for (auto x : (V)) \ cout << x << " " << endl; using namespace ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define PRINT(v) \ for (auto x : (V)) \ cout << x << " " << endl; using namespace ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
797
#include <algorithm> #include <bitset> #include <cmath> #include <ctype.h> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iostream> #include <istream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack...
#include <algorithm> #include <bitset> #include <cmath> #include <ctype.h> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iostream> #include <istream> #include <list> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <stack...
[["-", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
454