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
N,M,Q = map(int,input().split()) a = [0]*Q b = [0]*Q c = [0]*Q d = [0]*Q for i in range(Q): a[i],b[i],c[i],d[i] = map(int,input().split()) a[i] -= 1 #a,bを0オリジンにそろえる b[i] -= 1 def score(A): score = 0 for ai, bi, ci, di in zip(a, b, c, d): if A[bi] - A[ai] == ci: score += ci ...
N,M,Q = map(int,input().split()) a = [0]*Q b = [0]*Q c = [0]*Q d = [0]*Q for i in range(Q): a[i],b[i],c[i],d[i] = map(int,input().split()) a[i] -= 1 #a,bを0オリジンにそろえる b[i] -= 1 def score(A): score = 0 for ai, bi, ci, di in zip(a, b, c, d): if A[bi] - A[ai] == ci: score += di ...
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]]
5
226
#include <algorithm> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define ll long long #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep1(i, n) for (ll i = 1; i <...
#include <algorithm> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define ll long long #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep1(i, n) for (ll i = 1; i <...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13]]
1
362
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<boo...
#include <bits/stdc++.h> #include <cmath> #include <math.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<boo...
[["-", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13]]
1
935
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<string> vs; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<string> vs; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ...
[["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46], ["-", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13]]
1
409
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define IO ios::sync_with_stdio(false), cin.tie(0) #define endl '\n' #define pi acos(-1.0) #define ms(a, x) memset(a, x, sizeof(a)) #define lowbit(x) ((x) & (-(x))) #define pb push_back #define binarycount __builtin_popcount(x) #define tr t[ro...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define IO ios::sync_with_stdio(false), cin.tie(0) #define endl '\n' #define pi acos(-1.0) #define ms(a, x) memset(a, x, sizeof(a)) #define lowbit(x) ((x) & (-(x))) #define pb push_back #define binarycount __builtin_popcount(x) #define tr t[ro...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
779
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define rep(i, n) for (int i = 0; i < (n); i++) typedef pair<int, int> P; const long double EPS = 1e-10; const long long INF = 1e18; const int MOD = (int)1e9 + 7; const long double PI = acos(-1.0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define rep(i, n) for (int i = 0; i < (n); i++) typedef pair<int, int> P; const long double EPS = 1e-10; const long long INF = 1e18; const int MOD = (int)1e9 + 7; const long double PI = acos(-1.0...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
317
n, m, q = map(int, input().split()) a_list = [] b_list = [] c_list = [] d_list = [] for _ in range(q): a, b, c, d = map(int, input().split()) a_list.append(a) b_list.append(b) c_list.append(c) d_list.append(d) import itertools ans = 0 h_list = [i+1 for i in range(m)] for A in itertools.combination...
n, m, q = map(int, input().split()) a_list = [] b_list = [] c_list = [] d_list = [] for _ in range(q): a, b, c, d = map(int, input().split()) a_list.append(a) b_list.append(b) c_list.append(c) d_list.append(d) import itertools ans = 0 h_list = [i+1 for i in range(m)] for A in itertools.combination...
[["-", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22], ["+", 0, 656, 0, 7, 12, 652, 63, 319, 319, 22]]
5
172
def main(): from itertools import combinations_with_replacement import sys input = sys.stdin.buffer.readline N, M, Q = (int(i) for i in input().split()) T = [[int(i) for i in input().split()] for j in range(Q)] ans = 0 for A in combinations_with_replacement(range(1, M+1), N): A.sort(...
def main(): from itertools import combinations_with_replacement import sys input = sys.stdin.buffer.readline N, M, Q = (int(i) for i in input().split()) T = [[int(i) for i in input().split()] for j in range(Q)] ans = 0 for C in combinations_with_replacement(range(1, M+1), N): A = sor...
[["-", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["+", 0, 656, 0, 14, 8, 196, 0, 7, 31, 22], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
150
def main(): import sys input = sys.stdin.buffer.readline N, M, Q = (int(i) for i in input().split()) T = [[int(i) for i in input().split()] for j in range(Q)] def dfs(A): cur = 0 if len(A) == N: for a, b, c, d in T: if A[b-1] - A[a-1] == c: ...
def main(): import sys input = sys.stdin.buffer.readline N, M, Q = (int(i) for i in input().split()) T = [[int(i) for i in input().split()] for j in range(Q)] def dfs(A): cur = 0 if len(A) == N: for a, b, c, d in T: if A[b-1] - A[a-1] == c: ...
[["-", 64, 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], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
203
// 2020年4月17日現在 #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #includ...
// 2020年4月17日現在 #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <math.h> #include <numeric> #includ...
[["+", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 1...
1
760
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int a[55], b[55], c[55], d[55]; int n, m, q; int num[12] = {0}; int cal() { int ret = 0; for (int i = 0; i < q; i++) { if (num[b[i] - 1] - num[a[i] - 1] == c[i]) ret += d[i]; } return ret; } int dfs(int ind, int maxnum) { ...
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; int a[55], b[55], c[55], d[55]; int n, m, q; int num[12] = {0}; int cal() { int ret = 0; for (int i = 0; i < q; i++) { if (num[b[i] - 1] - num[a[i] - 1] == c[i]) ret += d[i]; } return ret; } int dfs(int ind, int maxnum) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
252
// Many Requirements #include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define rep(i, x, y) for (ll i = x; i < y; i++) #define nvarep(n, a) \ ll n; ...
// Many Requirements #include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define rep(i, x, y) for (ll i = x; i < y; i++) #define nvarep(n, a) \ ll n; ...
[["-", 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
387
# -*- coding: utf-8 -*- class Combination_with_repetition(): def getPattern(self, arr :list, r :int) -> list: self._selected=[] self._all_pattern=[] self._make(arr,r) return self._all_pattern def _make(self, arr :list, r :int): if r == 0: se...
# -*- coding: utf-8 -*- class Combination_with_repetition(): def getPattern(self, arr :list, r :int) -> list: self._selected=[] self._all_pattern=[] self._make(arr,r) return self._all_pattern def _make(self, arr :list, r :int): if r == 0: se...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
261
#include <iostream> int count = 0; int MR(int N, int Q, int *A, int *B, int *C, int *D, int *seq, int pt) { int res = 0; count++; if (pt == -1) { for (int i = 0; i < Q; i++) { if (seq[B[i]] - seq[A[i]] == C[i]) { res += D[i]; } } } else { int ot = 0; for (int i = 1; i <= seq...
#include <iostream> int count = 0; int MR(int N, int Q, int *A, int *B, int *C, int *D, int *seq, int pt) { int res = 0; count++; if (pt == -1) { for (int i = 0; i < Q; i++) { if (seq[B[i]] - seq[A[i]] == C[i]) { res += D[i]; } } } else { int ot = 0; for (int i = 1; i <= seq...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 0, 349], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 141, 22]]
1
337
# 視点を変えてやる全探索 実は条件よりAを全列挙することが可能 n, m, q = map(int, input().split()) koho = [] def rec(arr): if len(arr) == n: koho.append(arr) else: for i in range(arr[-1], m + 1): nex_arr = arr[:] nex_arr.append(i) rec(nex_arr) for i in range(m + 1): rec([i]) ans = ...
# 視点を変えてやる全探索 実は条件よりAを全列挙することが可能 # rec, 1からじゃなくて0からにしてたせいか1ケースでWA???? n, m, q = map(int, input().split()) koho = [] def rec(arr): if len(arr) == n: koho.append(arr) else: for i in range(arr[-1], m + 1): nex_arr = arr[:] nex_arr.append(i) rec(nex_arr) # こ...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
185
N,M,Q=map(int,input().split()) L=[] for i in range(Q): L.append(list(map(int,input().split()))) L[i][0]-=1 L[i][1]-=1 import itertools L=list(range(1,M+1)) A=list(itertools.combinations_with_replacement(L,N)) ans=0 for i in A: tmp=0 for a,b,c,d in L: if (i[b]-i[a])==c: tmp+=d ans=max(ans,tmp) pri...
N,M,Q=map(int,input().split()) L=[] for i in range(Q): L.append(list(map(int,input().split()))) L[i][0]-=1 L[i][1]-=1 #print(L) import itertools R=list(range(1,M+1))#ここで変数Lを使っていた A=list(itertools.combinations_with_replacement(R,N)) ans=0 #print(L)変数を上書きしていた!!!!! for i in A: tmp=0 for a,b,c,d in L: if (i...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
148
package main import ( "bufio" "fmt" "io" "os" "strconv" "strings" ) var n, m, q int var a, b, c, d []int func main() { io := NewIo(os.Stdin, os.Stdout) defer io.Flush() n, m, q = io.NextInt(), io.NextInt(), io.NextInt() a, b, c, d = make([]int, q), make([]int, q), make([]int, q), make([]int, q) for i := 0...
package main import ( "bufio" "fmt" "io" "os" "strconv" "strings" ) var n, m, q int var a, b, c, d []int func main() { io := NewIo(os.Stdin, os.Stdout) defer io.Flush() n, m, q = io.NextInt(), io.NextInt(), io.NextInt() a, b, c, d = make([]int, q), make([]int, q), make([]int, q), make([]int, q) for i := 0...
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22]]
7
703
N, M, Q = map(int, input().split()) a = [0 for _ in range(Q)] b = [0 for _ in range(Q)] c = [0 for _ in range(Q)] d = [0 for _ in range(Q)] for k in range(Q): a[k], b[k], c[k], d[k] = map(int, input().split()) A = [1 for _ in range(N)] def point(A): p = 0 for ai, bi, ci, di in zip(a, b, c, d): if A[bi-1] - A...
N, M, Q = map(int, input().split()) a = [0 for _ in range(Q)] b = [0 for _ in range(Q)] c = [0 for _ in range(Q)] d = [0 for _ in range(Q)] for k in range(Q): a[k], b[k], c[k], d[k] = map(int, input().split()) A = [1 for _ in range(N)] def point(A): p = 0 for ai, bi, ci, di in zip(a, b, c, d): if A[bi-1] - A...
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
285
#include <bits/stdc++.h> #define rep2(x, fr, to) for (int x = (fr); x < (to); x++) #define rep(x, to) for (int x = 0; x < (to); x++) #define repr(x, fr, to) for (int x = (fr); x >= (to); x--) #define all(c) c.begin(), c.end() #define sz(v) (int)v.size() using namespace std; typedef long long ll; typedef vector<int> V...
#include <bits/stdc++.h> #define rep2(x, fr, to) for (int x = (fr); x < (to); x++) #define rep(x, to) for (int x = 0; x < (to); x++) #define repr(x, fr, to) for (int x = (fr); x >= (to); x--) #define all(c) c.begin(), c.end() #define sz(v) (int)v.size() using namespace std; typedef long long ll; typedef vector<int> V...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
371
N,M,Q = gets.split.map(&:to_i) a = [] Q.times do |i| a[i] = gets.split.map(&:to_i) end def score(array,a) tmp = 0 for ai,bi,ci,di in a tmp += di if array[bi-1] - array[ai-1] == ci end tmp end def dfs(array,a) l = array.length return score(array,a) if l == N result = 0 l > 0 ? (prev_last = array[...
N,M,Q = gets.split.map(&:to_i) a = [] Q.times do |i| a[i] = gets.split.map(&:to_i) end def score(array,a) tmp = 0 for ai,bi,ci,di in a tmp += di if array[bi-1] - array[ai-1] == ci end tmp end def dfs(array,a) l = array.length return score(array,a) if l == N result = 0 l > 0 ? (prev_last = array[...
[["-", 8, 736, 0, 88, 51, 267, 0, 475, 17, 757], ["+", 8, 736, 0, 88, 51, 267, 0, 475, 17, 389]]
4
169
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int INF = 1e9; ll n, m, q, ans = 0; ll a[50], b[50], c[50], d[50]; ll A[10]; void dfs(int dep, int num) { if (dep == n) { ll t = 0; rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) t += d[i]; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; const int INF = 1e9; ll n, m, q, ans = 0; ll a[50], b[50], c[50], d[50]; ll A[10]; void dfs(int dep, int num) { if (dep == n) { ll t = 0; rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) t += d[i]; ...
[["-", 15, 339, 51, 16, 31, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 16, 31, 69, 28, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 69, 28, 22]]
1
359
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int MOOD = 998244353; #define PI 3.14159265359 typedef long long ll; using namespace std; int...
#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> const int MOD = 1e9 + 7; const int MOOD = 998244353; #define PI 3.14159265359 typedef long long ll; using namespace std; int...
[["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
336
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define call(var) cout << #var << "=" << var << endl; #define dup(x, y) (((x) + (y)-1) / (y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; using vb = vector<bool>; using Graph = vector<vi>; using P...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define call(var) cout << #var << "=" << var << endl; #define dup(x, y) (((x) + (y)-1) / (y)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; using vb = vector<bool>; using Graph = vector<vi>; using P...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]]
1
463
n, m, q = map(int, input().split()) l = [] for i in range(q): l.append(list(map(int,input().split()))) t = [1]*(n+1) ans = 0 while t[0] == 1: s = 0 for i in range(q): if t[l[i][1]]-t[l[i][0]] == l[i][2]: s += l[i][3] ans = max(ans, s) k = n while t[k] == m and n >= 1: ...
n, m, q = map(int, input().split()) l = [] for i in range(q): l.append(list(map(int,input().split()))) t = [1]*(n+1) ans = 0 while t[0] == 1: s = 0 for i in range(q): if t[l[i][1]]-t[l[i][0]] == l[i][2]: s += l[i][3] ans = max(ans, s) k = n while t[k] == m and k >= 1: ...
[["-", 8, 196, 0, 52, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 52, 15, 679, 12, 666, 0, 22]]
5
184
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return [LIST() for _ in range(n)] # 昇順列の巡回 def ascending(N, M): ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return [LIST() for _ in range(n)] # 昇順列の巡回 def ascending(N, M): ...
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
306
import itertools n,m,q = map(int, input().split()) list_ = [list(map(int, input().split())) for _ in range(q)] num=1 seed = [[i] for i in range(1,m+1)] while num!=n: num+=1 tmp_list = [] while seed: tmp = seed.pop() for i in range(tmp[-1]+1,m+1): tmp_list.append(tmp+[i]) seed = tmp_list.copy() ...
import itertools n,m,q = map(int, input().split()) list_ = [list(map(int, input().split())) for _ in range(q)] num=1 seed = [[i] for i in range(1,m+1)] while num!=n: num+=1 tmp_list = [] while seed: tmp = seed.pop() for i in range(tmp[-1],m+1): tmp_list.append(tmp+[i]) seed = tmp_list.copy() ma...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
189
#include <algorithm> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; // long long mod = 998244353; long long mod = 1000000007; vector<long long> fact(1000001); vector<long long> invFact(1...
#include <algorithm> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; // long long mod = 998244353; long long mod = 1000000007; vector<long long> fact(1000001); vector<long long> invFact(1...
[["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
1,636
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) typedef float fl; typedef long long ll; vector<int> A; int n, m, q; int a[50], b[50], c[50], d[50]; ll score(vector<int> A) { ll ans = 0; rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) ans += d[i]; return ans; } ll dfs(vect...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) typedef float fl; typedef long long ll; vector<int> A; int n, m, q; int a[50], b[50], c[50], d[50]; ll score(vector<int> A) { ll ans = 0; rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) ans += d[i]; return ans; } ll dfs(vect...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
279
import sys sys.setrecursionlimit(10**9) n,m,q=map(int,input().split()) l=[list(map(int,input().split())) for i in range(q)] def dfs(a_l): if len(a_l)==n: global ans t_ans=0 for a,b,c,d in l: a-=1 b-=1 if (a_l[b]-a_l[a]==c): t_ans+=d ans=max(ans,t_ans) return a_last=...
import sys sys.setrecursionlimit(10**9) n,m,q=map(int,input().split()) l=[list(map(int,input().split())) for i in range(q)] def dfs(a_l): if len(a_l)==n: global ans t_ans=0 for a,b,c,d in l: a-=1 b-=1 if (a_l[b]-a_l[a]==c): t_ans+=d ans=max(ans,t_ans) return a_last=...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
167
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; using ll = long long; using P = pair<int, int>; int N, M, Q; vector<int> a, b, c, d; int ans; void dfs(vector<int> A) { if (A.size() == N + 1) { int n...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; using ll = long long; using P = pair<int, int>; int N, M, Q; vector<int> a, b, c, d; int ans; void dfs(vector<int> A) { if (A.size() == N + 1) { int n...
[["-", 31, 16, 31, 69, 341, 342, 0, 69, 28, 22], ["+", 31, 16, 31, 69, 341, 342, 0, 69, 28, 22], ["-", 31, 16, 12, 69, 341, 342, 0, 69, 28, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 69, 28, 22]]
1
256
#include <bits/stdc++.h> using namespace std; long n, m, q, ans = 0; vector<long> a(50); vector<long> b(50); vector<long> c(50); vector<long> d(50); void zentansaku(vector<long> x) { if (x.size() - 1 == n) { long score = 0; for (long i = 0; i < q; i++) { if (x[b[i]] - x[a[i]] == c[i]) score +=...
#include <bits/stdc++.h> using namespace std; long n, m, q, ans = 0; vector<long> a(50); vector<long> b(50); vector<long> c(50); vector<long> d(50); void zentansaku(vector<long> x) { if (x.size() - 1 == n) { long score = 0; for (long i = 0; i < q; i++) { if (x[b[i]] - x[a[i]] == c[i]) score +=...
[["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35], ["-", 0, 1, 0, 2, 3, 4, 0, 83, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 83, 0, 13]]
1
243
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define REP(i, n) for (int i = 1; i < (int)(n); ++i) using namespace std; int N, M, Q; vector<int> a(50), b(50), c(50), d(50); vector<int> A(10); int ans = 0; void dfs(int n) { if (n == 0) { rep(i, M...
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define REP(i, n) for (int i = 1; i < (int)(n); ++i) using namespace std; int N, M, Q; vector<int> a(50), b(50), c(50), d(50); vector<int> A(10); int ans = 0; void dfs(int n) { if (n == 0) { rep(i, M...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
271
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, M, Q = mapint() abcd = [list(mapint()) for _ in range(Q)] from itertools import combinations_with_replacement lis = range(1, 11) ans = 0 for l in combinations_with_replacement(li...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, M, Q = mapint() abcd = [list(mapint()) for _ in range(Q)] from itertools import combinations_with_replacement lis = range(1, M+1) ans = 0 for l in combinations_with_replacement(l...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612]]
5
142
#include <bits/stdc++.h> #define PREP(i, s, x) for (ll i = (s); i < (x); i++) #define MREP(i, s, x) for (ll i = (s); i >= (x); i--) #define REP(i, x) PREP(i, 0, x) using namespace std; typedef long long ll; typedef pair<ll, ll> P; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return...
#include <bits/stdc++.h> #define PREP(i, s, x) for (ll i = (s); i < (x); i++) #define MREP(i, s, x) for (ll i = (s); i >= (x); i--) #define REP(i, x) PREP(i, 0, x) using namespace std; typedef long long ll; typedef pair<ll, ll> P; template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return...
[["+", 49, 50, 51, 4, 0, 16, 31, 16, 17, 33], ["+", 49, 50, 51, 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, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 82, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 82, 8, 9, 0, 43, 49, 50, 51, 13]]
1
469
n, m, q = map(int, input().split()) req = [] [req.append(tuple(map(int, input().split()))) for _ in range(q)] a = [0 for _ in range(m)] def check(): res = 0 for i in range(q): ra, rb, rc, rd = req[i] if a[rb - 1] - a[ra - 1] == rc: res += rd return res def set_a(idx: int, au: i...
n, m, q = map(int, input().split()) req = [] [req.append(tuple(map(int, input().split()))) for _ in range(q)] a = [0 for _ in range(n)] def check(): res = 0 for i in range(q): ra, rb, rc, rd = req[i] if a[rb - 1] - a[ra - 1] == rc: res += rd return res def set_a(idx: int, au: i...
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22]]
5
191
#include <bits/stdc++.h> #define _LIBCPP_DEBUG 0 using namespace std; typedef long long int ll; ll MOD = 1e9 + 7; int INF = 1 << 30; int N, M, Q; vector<int> vec; ll maxim = 0; vector<int> a(50 + 2, 0), b(50 + 2, 0), c(50 + 2, 0), d(50 + 2, 0); void search() { ll sum = 0; for (int i = 1; i <= Q; ++i) { if (ve...
#include <bits/stdc++.h> #define _LIBCPP_DEBUG 0 using namespace std; typedef long long int ll; ll MOD = 1e9 + 7; int INF = 1 << 30; int N, M, Q; vector<int> vec; ll maxim = 0; vector<int> a(50 + 2, 0), b(50 + 2, 0), c(50 + 2, 0), d(50 + 2, 0); void search() { ll sum = 0; for (int i = 1; i <= Q; ++i) { if (ve...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
291
#include <iostream> using namespace std; int N, M, Q; long long int a[50], b[50], c[50], d[50]; int A[10]; long long int dfs(int n, int value) { A[n] = value; if (n == N - 1) { long long int ans = 0; for (int i = 0; i < Q; i++) { if (A[b[i] - 1] - A[a[i] - 1] == c[i]) ans += d[i]; } ...
#include <iostream> using namespace std; int N, M, Q; long long int a[50], b[50], c[50], d[50]; int A[10]; long long int dfs(int n, int value) { A[n] = value; if (n == N - 1) { long long int ans = 0; for (int i = 0; i < Q; i++) { if (A[b[i] - 1] - A[a[i] - 1] == c[i]) ans += d[i]; } ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
320
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RNG(i, from, to) for (int i = (from); i < (int)(to); i++) #define gcd(i, j) __gcd((i), (j)) typedef long long ll; typedef pair<int, int> pii; typedef vector<ll> vecll; template <typename S, typename T> string to_s...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define RNG(i, from, to) for (int i = (from); i < (int)(to); i++) #define gcd(i, j) __gcd((i), (j)) typedef long long ll; typedef pair<int, int> pii; typedef vector<ll> vecll; template <typename S, typename T> string to_s...
[["-", 75, 76, 0, 9, 0, 14, 8, 9, 0, 45], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 36, 36, 0, 30, 0, 14, 8, 9, 0, 46], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
684
from itertools import combinations_with_replacement n, m, q = map(int, input().split()) A = combinations_with_replacement(range(1, m), n) L = [] for _ in range(q): L.append(list(map(int, input().split()))) r = 0 for a in A: t = 0 for l in L: if a[l[1] - 1] - a[l[0] - 1] == l[2]: t += l...
from itertools import combinations_with_replacement n, m, q = map(int, input().split()) A = combinations_with_replacement(range(m), n) L = [] for _ in range(q): L.append(list(map(int, input().split()))) r = 0 for a in A: t = 0 for l in L: if a[l[1] - 1] - a[l[0] - 1] == l[2]: t += l[3]...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21]]
5
127
from itertools import combinations_with_replacement n, m, q = map(int, input().split()) cond = [] for _ in range(q): a, b, c, d = map(int, input().split()) a -= 1 b -= 1 cond.append((a, b, c, d)) def calc(l): score = 0 for a, b, c, d in cond: if l[b] - l[a] == c: score += ...
from itertools import combinations_with_replacement n, m, q = map(int, input().split()) cond = [] for _ in range(q): a, b, c, d = map(int, input().split()) a -= 1 b -= 1 cond.append((a, b, c, d)) def calc(l): score = 0 for a, b, c, d in cond: if l[b] - l[a] == c: score += ...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 612]]
5
192
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; long long ans = 0; vector<long long> a, b, c, d; int n, m, q; void print(vector<long long> v) { for (int i = 0; i < v.size(); i++) { cout << i << ":" << v[i] << endl; } } void solve(vector<long ...
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; long long ans = 0; vector<long long> a, b, c, d; int n, m, q; void print(vector<long long> v) { for (int i = 0; i < v.size(); i++) { cout << i << ":" << v[i] << endl; } } void solve(vector<long ...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22]]
1
351
N, M, Q = gets.split(" ").map(&:to_i) abcd = [] ans = 0 Q.times do |i| abcd[i] = gets.split(" ").map(&:to_i) end [*1..M].repeated_combination(n) do |arr| score = 0 abcd.each do |e| a, b, c, d = [e[0] - 1, e[1] - 1, e[2], e[3]] score += d if arr[b] - arr[a] == c end ans = [score, ans...
N, M, Q = gets.split(" ").map(&:to_i) abcd = [] ans = 0 Q.times do |i| abcd[i] = gets.split(" ").map(&:to_i) end [*1..M].repeated_combination(N) do |arr| score = 0 abcd.each do |e| a, b, c, d = [e[0] - 1, e[1] - 1, e[2], e[3]] score += d if arr[b] - arr[a] == c end ans = [score, ans...
[["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 743]]
4
140
#include <bits/stdc++.h> using namespace std; typedef long long ll; int getScore(vector<vector<int>> &v, vector<int> &here) { int ret = 0; for (int i = 0; i < v.size(); ++i) { int a = v[i][0]; int b = v[i][1]; if (here[b] - here[a] == v[i][2]) { ret += v[i][3]; } } return ret; } void p...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int getScore(vector<vector<int>> &v, vector<int> &here) { int ret = 0; for (int i = 0; i < v.size(); ++i) { int a = v[i][0]; int b = v[i][1]; if (here[b] - here[a] == v[i][2]) { ret += v[i][3]; } } return ret; } void p...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
370
#include <algorithm> #include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define ALL(a) (a).begin(), (a).end() using namespace std; vector<int> a, b, c, d; int check(const vector<int> &cur) { int point = 0; REP(i, a.size()) { ...
#include <algorithm> #include <iostream> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define ALL(a) (a).begin(), (a).end() using namespace std; vector<int> a, b, c, d; int check(const vector<int> &cur) { int point = 0; REP(i, a.size()) { ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
347
#include <bits/stdc++.h> #define ll long long #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, n, a) for (int i = n; i >= a; i--) #define endl '\n' #define mem(a, b) memset(a, b, sizeof(a)) #define IO \ ios::sync_with_stdio(false); ...
#include <bits/stdc++.h> #define ll long long #define rep(i, a, n) for (int i = a; i <= n; i++) #define per(i, n, a) for (int i = n; i >= a; i--) #define endl '\n' #define mem(a, b) memset(a, b, sizeof(a)) #define IO \ ios::sync_with_stdio(false); ...
[["+", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 7, 8, 9, 0, 46]]
1
290
# -*- coding: utf-8 -*- import itertools 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) a_list = [] for i in range(10): a_list.append(i) suuretsu_list = itertools.combinat...
# -*- coding: utf-8 -*- import itertools 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) a_list = [] for i in range(m): a_list.append(i) suuretsu_list = itertools.combinati...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
183
#include <bits/stdc++.h> #define maxn 300005 #define maxa 2000005 #define MOD 100000000 // 1000000007 //998244353 #define INF 1000000000000000000 #define ll unsigned long long using namespace std; #define pii pair<ll, ll> #define piii pair<ll, pii> #define ft first #define sd second #define pb push_back #define rep(i...
#include <bits/stdc++.h> #define maxn 300005 #define maxa 2000005 #define MOD 100000000 // 1000000007 //998244353 #define INF 1000000000000000000 #define ll unsigned long long using namespace std; #define pii pair<ll, ll> #define piii pair<ll, pii> #define ft first #define sd second #define pb push_back #define rep(i...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
448
import itertools n, m, q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(q)] A_list = list(itertools.combinations_with_replacement(range(1,m),n)) ans = 0 for A in A_list: sum = 0 for a,b,c,d in abcd: if A[b-1] - A[a-1] == c: sum += d ans = max(ans, s...
import itertools n, m, q = map(int, input().split()) abcd = [list(map(int, input().split())) for _ in range(q)] A_list = list(itertools.combinations_with_replacement(range(1,m+1),n)) ans = 0 for A in A_list: sum = 0 for a,b,c,d in abcd: if A[b-1] - A[a-1] == c: sum += d ans = max(ans,...
[["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
118
#include <bits/stdc++.h> #define re register using namespace std; inline int read() { re int t = 0; re char v = getchar(); while (v < '0') v = getchar(); while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar(); return t; } int n, m, q, ans, a[52], b[52], c[52], d[52], f[52]; inline void dfs(r...
#include <bits/stdc++.h> #define re register using namespace std; inline int read() { re int t = 0; re char v = getchar(); while (v < '0') v = getchar(); while (v >= '0') t = (t << 3) + (t << 1) + v - 48, v = getchar(); return t; } int n, m, q, ans, a[52], b[52], c[52], d[52], f[52]; inline void dfs(r...
[["-", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 31, 22]]
1
329
#include <algorithm> #include <bitset> #include <cmath> #include <ctime> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; #define rep(i, n)...
#include <algorithm> #include <bitset> #include <cmath> #include <ctime> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <tuple> #include <vector> using namespace std; #define rep(i, n)...
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 82, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 82, 8, 9, 0, 43, 49, 50, 51, 13]]
1
476
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { int n, m, 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]--; } ll maxv = 0; vector<int> nums; rep...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { int n, m, 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]--; } ll maxv = 0; vector<int> nums; rep...
[["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
283
import itertools import numpy as np N,M,Q = map(int, input().split()) a = range(1,M+1) arr = np.asarray(list(itertools.combinations_with_replacement(a,M))) #重複組み合わせ #print(arr) sc = np.zeros(arr.shape[0],dtype=int) #print(sc) for i in range(Q): abcd = list(map(int, input().split())) f = (arr[:,abcd[1]-1]-arr[:,...
import itertools import numpy as np N,M,Q = map(int, input().split()) a = range(1,M+1) arr = np.asarray(list(itertools.combinations_with_replacement(a,N))) #重複組み合わせ #print(arr) sc = np.zeros(arr.shape[0],dtype=int) #print(sc) for i in range(Q): abcd = list(map(int, input().split())) f = (arr[:,abcd[1]-1]-arr[:,...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
146
N ,M ,Q = map(int,input().split()) l = [list(map(int,input().split())) for i in range(Q)] ans=[] score = 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()) l = [list(map(int,input().split())) for i in range(Q)] ans=[] score = 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): ...
[["-", 15, 666, 0, 657, 31, 206, 206, 657, 17, 72], ["+", 15, 666, 0, 657, 31, 206, 206, 657, 17, 33], ["-", 15, 666, 0, 657, 12, 206, 206, 657, 17, 72], ["+", 15, 666, 0, 657, 12, 206, 206, 657, 17, 33]]
5
244
#include <bits/stdc++.h> using namespace std; int n, m, q, ans, sum; vector<int> a(51); vector<int> b(51); vector<int> c(51); vector<int> d(51); vector<int> A(12); void dfs(int num, int add) { if (num == n + 1) { sum = 0; for (int i = 0; i < m; i++) { if (A[b[i]] - A[a[i]] == c[i]) { sum += d[i...
#include <bits/stdc++.h> using namespace std; int n, m, q, ans, sum; vector<int> a(51); vector<int> b(51); vector<int> c(51); vector<int> d(51); vector<int> A(12); void dfs(int num, int add) { if (num == n + 1) { sum = 0; for (int i = 0; i < q; i++) { if (A[b[i]] - A[a[i]] == c[i]) { sum += d[i...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38]]
1
242
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) L = [] for _ in range(Q): L.append(tuple(map(int, input().split()))) ans = 0 _N = N if N < M: _N = M for A in combinations_with_replacement(range(1, M + 1), _N): tmp = 0 for a, b, c, d in L: if a < _N and ...
from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) L = [] for _ in range(Q): L.append(tuple(map(int, input().split()))) ans = 0 _N = N if N < M: _N = M for A in combinations_with_replacement(range(1, M + 1), _N): tmp = 0 for a, b, c, d in L: if a <= _N and...
[["-", 0, 57, 15, 679, 31, 679, 31, 666, 667, 18], ["+", 0, 57, 15, 679, 31, 679, 31, 666, 667, 19], ["-", 0, 57, 15, 679, 31, 679, 12, 666, 667, 18], ["+", 0, 57, 15, 679, 31, 679, 12, 666, 667, 19]]
5
139
#include <bits/stdc++.h> #define trace1(a) cout << #a << ": " << a << endl #define trace2(a, b) cout << #a << ": " << a << " | ", trace1(b) #define trace3(a, b, c) cout << #a << ": " << a << " | ", trace2(b, c) #define trace4(a, b, c, d) cout << #a << ": " << a << " | ", trace3(b, c, d) #define trace5(a, b, c, d, e) ...
#include <bits/stdc++.h> #define trace1(a) cout << #a << ": " << a << endl #define trace2(a, b) cout << #a << ": " << a << " | ", trace1(b) #define trace3(a, b, c) cout << #a << ": " << a << " | ", trace2(b, c) #define trace4(a, b, c, d) cout << #a << ": " << a << " | ", trace3(b, c, d) #define trace5(a, b, c, d, e) ...
[["-", 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
1,606
#include <algorithm> #include <cassert> #include <cfloat> #include <cmath> #include <cstdint> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> ...
#include <algorithm> #include <cassert> #include <cfloat> #include <cmath> #include <cstdint> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> ...
[["-", 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
574
#include <algorithm> #include <iostream> #include <limits.h> #include <math.h> #include <queue> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; int N, M, Q, ans = 0; vector<pair<int, int>> query1, query2; void dfs(int idx, vector<int> A) { if (idx == N) { int su...
#include <algorithm> #include <iostream> #include <limits.h> #include <math.h> #include <queue> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; int N, M, Q, ans = 0; vector<pair<int, int>> query1, query2; void dfs(int idx, vector<int> A) { if (idx == N) { int su...
[["-", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13], ["+", 0, 43, 49, 50, 51, 23, 0, 41, 64, 13]]
1
290
import itertools n, m, q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for _ in range(Q)] ans = 0 for com in itertools.combinations_with_replacement(range(1, M + 1), N): score = sum([d for a, b, c, d in abcd if com[b-1] - com[a-1] == c]) if ans < score: ans = score print(ans)
import itertools n, m, q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for _ in range(q)] ans = 0 for com in itertools.combinations_with_replacement(range(1, m + 1), n): score = sum([d for a, b, c, d in abcd if com[b-1] - com[a-1] == c]) if ans < score: ans = score print(ans)
[["-", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 12, 658, 0, 659, 12, 652, 3, 4, 0, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
114
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m, q, a[55], b[55], c[55], d[55], ans, aa[55]; void Calc() { int s = 0; for (int i = 1; i <= q; i++) if (aa[b[i]] - aa[a[i]] == c[i]) s += d[i]; ans = max(ans, s); } void DFS(int x) { if (x > n) { Calc(); return; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m, q, a[55], b[55], c[55], d[55], ans, aa[55]; void Calc() { int s = 0; for (int i = 1; i <= q; i++) if (aa[b[i]] - aa[a[i]] == c[i]) s += d[i]; ans = max(ans, s); } void DFS(int x) { if (x > n) { Calc(); return; } ...
[["+", 0, 7, 10, 43, 49, 50, 51, 2, 63, 22], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 10, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
226
import itertools N,M,Q = map(int,input().split()) L = [list(map(int,input().split())) for _ in range(Q)] data = list(range(1,M+1)) A=list(itertools.combinations_with_replacement(data,N)) max_score = 0 for Ai in A: x = 0 for a,b,c,d in L: if Ai[b] - Ai[a] == c: x += d max_score = max(max_score,x) print...
import itertools N,M,Q = map(int,input().split()) L = [list(map(int,input().split())) for _ in range(Q)] data = list(range(1,M+1)) A=list(itertools.combinations_with_replacement(data,N)) max_score = 0 for Ai in A: x = 0 for a,b,c,d in L: if Ai[b-1] - Ai[a-1] == c: x += d max_score = max(max_score,x) p...
[["+", 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
122
#include <bits/stdc++.h> #include <cmath> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() #define sz(x) (int)(x).size() #define v(T) vector<T> #define VEC vecto...
#include <bits/stdc++.h> #include <cmath> using namespace std; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() #define sz(x) (int)(x).size() #define v(T) vector<T> #define VEC vecto...
[["-", 0, 1, 0, 11, 31, 69, 28, 2, 63, 22], ["+", 0, 1, 0, 11, 31, 69, 28, 2, 63, 22], ["+", 0, 11, 31, 69, 28, 2, 3, 4, 0, 21], ["+", 0, 11, 31, 69, 28, 2, 3, 4, 0, 13], ["+", 31, 69, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 31, 69, 28, 2, 3, 4, 0, 16, 12, 13]]
1
485
#include <bits/stdc++.h> using namespace std; #define fastio() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define ll lo...
#include <bits/stdc++.h> using namespace std; #define fastio() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define ll lo...
[["-", 15, 16, 12, 16, 31, 16, 31, 16, 17, 33], ["-", 15, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["-", 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, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 22]]
1
369
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repe(i, n) for (int i = 1; i <= (int)(n); ++i) #define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit) #define ll long long using namespace std; typedef vector<vector<int>> Graph; int ans = 0; int N, M, Q; vector<int> a, b, c, d;...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define repe(i, n) for (int i = 1; i <= (int)(n); ++i) #define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit) #define ll long long using namespace std; typedef vector<vector<int>> Graph; int ans = 0; int N, M, Q; vector<int> a, b, c, d;...
[["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]]
1
278
#!/usr/bin/env python3 n, m, q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for i in range(q)] ans = 0 def check(A): global ans max_ = 0 # 点数計算 for (a, b, c, d) in abcd: if A[b-1] - A[a-1] == c: max_ += d # 最大値更新 ans = max(ans, max_) def suretu(...
#!/usr/bin/env python3 n, m, q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for i in range(q)] ans = 0 def check(A): global ans max_ = 0 # 点数計算 for (a, b, c, d) in abcd: if A[b-1] - A[a-1] == c: max_ += d # 最大値更新 ans = max(ans, max_) def suretu(...
[["-", 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, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
5
160
import sys n,m,q=map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(0,q): ay,by,cy,dy=map(int,input().split()) a.append(ay) b.append(by) c.append(cy) d.append(dy) s=0 smax=-100 sys.setrecursionlimit(3000) def dfs(h): global smax if len(h)==n+1: s=0 for j in ran...
import sys n,m,q=map(int,input().split()) a=[] b=[] c=[] d=[] for i in range(0,q): ay,by1,cy,dy=map(int,input().split()) a.append(ay) b.append(by1) c.append(cy) d.append(dy) s=0 smax=-100 sys.setrecursionlimit(3000) def dfs(h): global smax if len(h)==n+1: s=0 for j in r...
[["-", 8, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 12, 652, 3, 4, 0, 657, 31, 657, 31, 22], ["+", 12, 652, 3, 4, 0, 657, 31, 657, 31, 22], ["-", 12, 652, 3, 4, 0, 657, 31, 657, 12, 612], ["+...
5
232
#dfs試す #挙動追うのきつい n,m,q=map(int, input().split( )) qs=tuple(tuple(map(int, input().split( ))) for _ in range(q)) def dfs(ll): if len(ll)==n+1: sm=0 for ai,bi,ci,di in qs: if ll[bi]-ll[ai]==ci: sm+=di return sm res=[] for i in range(ll[-1],m+1): ll2...
#dfs試す n,m,q=map(int, input().split( )) qs=tuple(tuple(map(int, input().split( ))) for _ in range(q)) def dfs(ll): if len(ll)==n+1: sm=0 for ai,bi,ci,di in qs: if ll[bi]-ll[ai]==ci: sm+=di return sm res=[] for i in range(ll[-1],m):#+1 ll2=ll+[i] ...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
150
#20C10のcombinatrics全探索? #本番でCでこれ見たら凍るw n,m,q=map(int, input().split( )) qs=tuple(tuple(map(int, input().split( ))) for _ in range(q)) import itertools ans=0 for comb in itertools.combinations(range(1,n+m+1),n): tmp=0 comb2=[comb[i]-i for i in range(n)] for ai,bi,ci,di in qs: if comb2[bi-1]-comb2[ai-...
#20C10のcombinatrics全探索? #本番でCでこれ見たら凍るw #少なくとも combinatrics が組込みでなかったら C問題 じゃないな n,m,q=map(int, input().split( )) qs=tuple(tuple(map(int, input().split( ))) for _ in range(q)) import itertools ans=0 for comb in itertools.combinations(range(1,n+m),n):##+1ない? tmp=0 comb2=[comb[i]-i for i in range(n)] for ai,bi...
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
136
#include <bits/stdc++.h> using namespace std; //イコールがあるのでビット全探索ではない //再帰で書くのでここに書いておく int N, M, Q; int a[55], b[55], c[55], d[55], A[10]; int ans = 0; void check() { int sum = 0; for (int i = 0; i < Q; i++) { if (A[b[i]] - A[a[i]] == c[i]) { sum += d[i]; } } ans = max(sum, ans); } //深さ優先探索 void...
#include <bits/stdc++.h> using namespace std; //イコールがあるのでビット全探索ではない //再帰で書くのでここに書いておく int N, M, Q; int a[55], b[55], c[55], d[55], A[10]; int ans = 0; void check() { int sum = 0; for (int i = 0; i < Q; i++) { if (A[b[i]] - A[a[i]] == c[i]) { sum += d[i]; } } ans = max(sum, ans); } //深さ優先探索 void...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
285
import itertools #19 choose 9 #92378 def main(): N, M, Q = map(int, input().split()) Q = [] final_score = 0 for i in range(Q): Q.append(list(map(int, input().split()))) for A in itertools.combinations_with_replacement(range(1, M+1), N): score = 0 for q in Q: if ...
import itertools #19 choose 9 #92378 def main(): N, M, Q = map(int, input().split()) Q_l = [] final_score = 0 for i in range(Q): Q_l.append(list(map(int, input().split()))) for A in itertools.combinations_with_replacement(range(1, M+1), N): score = 0 for q in Q_l: ...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 12, 22]]
5
138
from collections import deque de = deque() 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)) de.append([1]) maxscore = 0 while de: li = de.popleft() if len(li) < n: for i in range(li[-1],11): new_li = li + [...
from collections import deque de = deque() 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)) de.append([1]) maxscore = 0 while de: li = de.popleft() if len(li) < n: for i in range(li[-1],m+1): new_li = li + ...
[["-", 64, 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
import itertools n,m,q = map(int,input().split()) array = [] A = [i for i in range(1,m+1)] A_list = list(itertools.combinations(A,n)) max_sum = [0]*len(A_list) for i in range(q): a,b,c,d = map(int,input().split()) for j in range(len(A_list)): if A_list[j][b-1]-A_list[j][a-1] == c: max_sum[j...
import itertools n,m,q = map(int,input().split()) array = [] A = [i for i in range(1,m+1)] A_list = list(itertools.combinations_with_replacement(A,n)) max_sum = [0]*len(A_list) for i in range(q): a,b,c,d = map(int,input().split()) for j in range(len(A_list)): if A_list[j][b-1]-A_list[j][a-1] == c: ...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
138
import itertools n,m,q=map(int,input().split()) abcd=[None]*q for i in range(q): abcd[i]=list(map(int,input().split())) num=0 for l in list(map(list, itertools.combinations(range(1,m+1), n))): num_ = 0 for x in abcd: if l[x[1]-1]-l[x[0]-1] == x[2]: num_ += x[3] num = max(num ,num_) p...
import itertools n,m,q=map(int,input().split()) abcd=[None]*q for i in range(q): abcd[i]=list(map(int,input().split())) num=0 for l in list(map(list, itertools.combinations_with_replacement(range(1,m+1), n))): num_ = 0 for x in abcd: if l[x[1]-1]-l[x[0]-1] == x[2]: num_ += x[3] num =...
[["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
137
n, m, q = gets.chomp.split().map(&:to_i) array = [] q.times do array << gets.chomp.split.map(&:to_i) end ans = 0 [*1..m].combination(n).to_a.each do |comb| sum = 0 array.each do |a, b, c, d| sum += d if (comb[b-1] - comb[a-1]) == c end ans = [ans, sum].max end puts ans
n, m, q = gets.chomp.split().map(&:to_i) array = [] q.times do array << gets.chomp.split.map(&:to_i) end ans = 0 [*1..m].repeated_combination(n).to_a.each do |comb| sum = 0 array.each do |a, b, c, d| sum += d if (comb[b-1] - comb[a-1]) == c end ans = [ans, sum].max end puts ans
[["-", 0, 493, 0, 652, 486, 652, 486, 652, 735, 22], ["+", 0, 493, 0, 652, 486, 652, 486, 652, 735, 22]]
4
113
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second #define pb push_back #define ios \ std::ios::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second #define pb push_back #define ios \ std::ios::sync_with_stdio(false); ...
[["+", 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
555
import itertools N,M,Q=map(int,input().split()) a=[] for _ in range(Q): b=list(map(int,input().split())) a.append(b) s=[] for i in range(M+1): s.append(i) alist=list(itertools.combinations_with_replacement(s, r=N+1)) tmp=0 for j in alist: s=0 for i in range(Q): j=list(j) if j[a[i][...
import itertools N,M,Q=map(int,input().split()) a=[] for _ in range(Q): b=list(map(int,input().split())) a.append(b) s=[] for i in range(1,M+1): s.append(i) alist=list(itertools.combinations_with_replacement(s, r=N+1)) tmp=0 for j in alist: s=0 for i in range(Q): j=list(j) if j[a[i...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
169
n,m,q = map(int,input().split()) a = [0 for i in range(q)] for i in range(q): a[i] = list(map(int,input().split())) for i in range(1,m+1): for j in range(i,m+1): for k in range(j,m+1): for s in range(k,m+1): for p in range(s,m+1): for l in range(p,m+1): ...
n,m,q = map(int,input().split()) a = [0 for i in range(q)] ans = 0 for i in range(q): a[i] = list(map(int,input().split())) for i in range(1,m+1): for j in range(i,m+1): for k in range(j,m+1): for s in range(k,m+1): for p in range(s,m+1): for l in range(p,...
[["+", 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], ["-", 8, 196, 0, 1, 0, 662, 12, 634, 0, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 22]]
5
256
n,m,q = map(int,input().split()) a = [0] * q b = [0] * q c = [0] * q d = [0] * q for i in range(q): a[i], b[i], c[i], d[i]= map(int, input().split()) s = [1] * n #st[b[i]] - st[a[i]] = c[i] num = n-1 #ans1 = [0] * 10000000 ans = 0 pre_ans = 0 t = 0 while(s[0] != m ): for i in range(q): if s[b[i]-1] ...
n,m,q = map(int,input().split()) a = [0] * q b = [0] * q c = [0] * q d = [0] * q for i in range(q): a[i], b[i], c[i], d[i]= map(int, input().split()) s = [1] * n #st[b[i]] - st[a[i]] = c[i] num = n-1 #ans1 = [0] * 10000000 ans = 0 pre_ans = 0 t = 0 while(s[0] != m ): for i in range(q): if s[b[i]-1] ...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
323
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define ll long long int main() { ll int n, m, q, ans = 0, max = 0; scanf("%lld%lld%lld", &n, &m, &q); ll int a[q], b[q], c[q], d[q], A[11]; for (int i = 1; i <= q; i++) { scanf("%lld%lld%lld%lld", &a[i], &b[i], &c[i], &d[i]); } ...
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define ll long long int main() { ll int n, m, q, ans = 0, max = 0; scanf("%lld%lld%lld", &n, &m, &q); ll int a[q], b[q], c[q], d[q], A[11]; for (int i = 1; i <= q; i++) { scanf("%lld%lld%lld%lld", &a[i], &b[i], &c[i], &d[i]); } ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
0
429
from itertools import combinations_with_replacement n, m, q = map(int,input().split()) l = [] s = [] for _ in range(q): a, b, c, d = map(int,input().split()) l.append([a, b, c, d]) ps = list(combinations_with_replacement(range(2, m+1), n-1)) n_p = len(ps) for i in range(n_p): ns = [1] + list(ps[i]) s...
from itertools import combinations_with_replacement n, m, q = map(int,input().split()) l = [] s = [] for _ in range(q): a, b, c, d = map(int,input().split()) l.append([a, b, c, d]) ps = list(combinations_with_replacement(range(1, m+1), n-1)) n_p = len(ps) for i in range(n_p): ns = [1] + list(ps[i]) s...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
181
#include "bits/stdc++.h" #define ll long long #define mk make_pair #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define pil pair<int, ll> #define pli pair<ll, int> using namespace std; const int MAXN = 1e5 + 9; ll ans = 0; int n, m, q, a[100][4]; vector<int> v; inline void recurse(int len) {...
#include "bits/stdc++.h" #define ll long long #define mk make_pair #define pb push_back #define pii pair<int, int> #define pll pair<ll, ll> #define pil pair<int, ll> #define pli pair<ll, int> using namespace std; const int MAXN = 1e5 + 9; ll ans = 0; int n, m, q, a[100][4]; vector<int> v; inline void recurse(int len) {...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
324
import itertools n, m, q = map(int, input().split()) q_list = [list(map(int, input().split())) for _ in range(q)] ans = 0 seleted = [x for x in range(1, m+1)] A_list = list(itertools.combinations(seleted, n)) # print(A_list) for A in A_list: tmp = 0 for q in q_list: if A[q[1]-1] - A[q[0]-1] == q[2]: ...
import itertools n, m, q = map(int, input().split()) q_list = [list(map(int, input().split())) for _ in range(q)] ans = 0 seleted = [x for x in range(1, m+1)] A_list = list(itertools.combinations_with_replacement(seleted, n)) for A in A_list: tmp = 0 for q in q_list: if A[q[1]-1] - A[q[0]-1] == q[2]: ...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
137
import itertools as itr N,M,Q = map(int,input().split()) sheat = list() for i in range(Q): sheat.append(list(map(int,input().split()))) comb = tuple(itr.combinations(range(1,M+1),N)) Maxsum = 0 # print(sheat) # print(comb) sumd = 0 for i in range(len(comb)): ansum = 0 for j in range(Q): if(comb[i][...
import itertools as itr N,M,Q = map(int,input().split()) sheat = list() for i in range(Q): sheat.append(list(map(int,input().split()))) comb = tuple(itr.combinations_with_replacement(range(1,M+1),N)) Maxsum = 0 # print(sheat) # print(comb) sumd = 0 for i in range(len(comb)): ansum = 0 for j in range(Q): ...
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 12, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
183
import copy 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) seq = [[] for i in range(n)] for i in range(1, m + 1): seq[0].append([i]) for i in range(1, n): for j in range...
import copy 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) seq = [[] for i in range(n)] for i in range(1, m + 1): seq[0].append([i]) for i in range(1, n): for j in range...
[["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73]]
5
311
n, m, q = input().split() n = int( n ) m = int( m ) q = int( q ) a = [] b = [] c = [] d = [] for i in range( int( q ) ): a_i, b_i, c_i, d_i = input().split() a.append( int( a_i ) ) b.append( int( b_i ) ) c.append( int( c_i ) ) d.append( int( d_i ) ) array = [ 1 ] * n array_list = [ array ] i = 0 w...
n, m, q = input().split() n = int( n ) m = int( m ) q = int( q ) a = [] b = [] c = [] d = [] for i in range( int( q ) ): a_i, b_i, c_i, d_i = input().split() a.append( int( a_i ) ) b.append( int( b_i ) ) c.append( int( c_i ) ) d.append( int( d_i ) ) array = [ 1 ] * n array_list = [ array ] i = 0 w...
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612]]
5
244
#include <bits/stdc++.h> using namespace std; template <typename T> istream &operator>>(istream &istr, vector<T> &v) { for (T &x : v) istr >> x; return istr; } template <typename T, typename U> istream &operator>>(istream &istr, pair<T, U> &p) { istr >> p.first >> p.second; return istr; } template <typen...
#include <bits/stdc++.h> using namespace std; template <typename T> istream &operator>>(istream &istr, vector<T> &v) { for (T &x : v) istr >> x; return istr; } template <typename T, typename U> istream &operator>>(istream &istr, pair<T, U> &p) { istr >> p.first >> p.second; return istr; } template <typen...
[["+", 31, 69, 28, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 69, 28, 2, 3, 4, 0, 16, 12, 13]]
1
908
N, M, Q = map(int, input().split()) X = [] for _ in range(Q): a, b, c, d = map(int, input().split()) X.append((a, b, c, d)) def calc(L): s = 0 for a, b, c, d in X: if L[b] - L[a] == c: s += d return s def rec(L): if len(L) == N + 1: return calc(L) ma = 0 for i in range(...
N, M, Q = map(int, input().split()) X = [] for _ in range(Q): a, b, c, d = map(int, input().split()) X.append((a, b, c, d)) def calc(L): s = 0 for a, b, c, d in X: if L[b] - L[a] == c: s += d return s def rec(L): if len(L) == N + 1: return calc(L) ma = 0 for i in range(...
[["-", 3, 4, 0, 652, 3, 4, 0, 634, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 634, 0, 612]]
5
168
import itertools def main(): N, M, Q = map(int, input().split()) a = [0 for _ in range(Q)] b = [0 for _ in range(Q)] c = [0 for _ in range(Q)] d = [0 for _ in range(Q)] for i in range(Q): a[i], b[i], c[i], d[i] = map(int, input().split()) seq = [i for i in range(1, max(11, M+1))] ...
import itertools def main(): N, M, Q = map(int, input().split()) a = [0 for _ in range(Q)] b = [0 for _ in range(Q)] c = [0 for _ in range(Q)] d = [0 for _ in range(Q)] for i in range(Q): a[i], b[i], c[i], d[i] = map(int, input().split()) seq = [i for i in range(1, min(11, M+1))] ...
[["-", 0, 659, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 652, 63, 22]]
5
217
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; //#define int int64_t #define pcnt __builtin_popcount #define pb push_back #define ALL(x) (x).begin(), (x).end() #define vec vector<int> #define mat vector<vector<int>> // mat データ名(縦,vec(横)); int64_t INF = 1000000000000000001; // 10^18+1 int MOD = ...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; //#define int int64_t #define pcnt __builtin_popcount #define pb push_back #define ALL(x) (x).begin(), (x).end() #define vec vector<int> #define mat vector<vector<int>> // mat データ名(縦,vec(横)); int64_t INF = 1000000000000000001; // 10^18+1 int MOD = ...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
348
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = int; int main() { ll n, m, q; cin >> n >> m >> q; ll a[100], b[100], c[100], d[100]; for (ll i = 0; i < q; i++) { ci...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; using ll = int; int main() { ll n, m, q; cin >> n >> m >> q; ll a[100], b[100], c[100], d[100]; for (ll i = 0; i < q; i++) { ci...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
435
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <sstream> #include <string> #include <vector> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target( \ "sse,sse2,sse3,ssse3...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <numeric> #include <sstream> #include <string> #include <vector> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target( \ "sse,sse2,sse3,ssse3...
[["+", 75, 76, 0, 9, 0, 43, 49, 50, 0, 32], ["+", 75, 76, 0, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32]]
1
378
#include <stdio.h> #define ull unsigned long long int #define ll long long #define rep(x) for (A[x] = A[x - 1]; A[x] <= M; A[x]++) ll max(ll a, ll b) { if (b > a) return b; return a; }; typedef struct quatt { int a, b, c; long d; } quat; ll hyouka(quat q[], int n, int A[]) { ll sum = 0; for (int k = ...
#include <stdio.h> #define ull unsigned long long int #define ll long long #define rep(x) for (A[x] = A[x - 1]; A[x] <= M; A[x]++) ll max(ll a, ll b) { if (b > a) return b; return a; }; typedef struct quatt { int a, b, c; long d; } quat; ll hyouka(quat q[], int n, int A[]) { ll sum = 0; for (int k = ...
[["+", 0, 7, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 0, 7, 0, 42, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 7, 0, 42, 0, 2, 63, 22], ["+", 0, 7, 0, 42, 0, 2, 3, 4, 0, 24]]
0
343
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef vector<vector<ll>> Graph; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T ...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef vector<vector<ll>> Graph; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T ...
[["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 12, 22]]
1
418
#ifdef _MSC_VER #include "stdc++.h" #endif #ifdef __GNUC__ #include <bits/stdc++.h> #endif using namespace std; using ll = long long; // constant const double EPS = 1e-10; #define REP(i, n) for (ll i = 0; i < n; i++) #define FOR(i, s, e) for (ll i = s; i < e; i++) #define ALL(x) (x).begin(), (x).end() #define RALL(x...
#ifdef _MSC_VER #include "stdc++.h" #endif #ifdef __GNUC__ #include <bits/stdc++.h> #endif using namespace std; using ll = long long; // constant const double EPS = 1e-10; #define REP(i, n) for (ll i = 0; i < n; i++) #define FOR(i, s, e) for (ll i = s; i < e; i++) #define ALL(x) (x).begin(), (x).end() #define RALL(x...
[["-", 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
502
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <queue> #include <vector> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, m, q; cin >> n >> m >> q; vector<int> x(10, -1001001001); ll an...
#include <algorithm> #include <cmath> #include <deque> #include <iostream> #include <queue> #include <vector> #define rep(i, a, n) for (int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n, m, q; cin >> n >> m >> q; vector<int> x(10, -1001001001); ll an...
[["-", 0, 9, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 9, 0, 9, 0, 1, 0, 11, 12, 22]]
1
966
#include <bits/stdc++.h> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; template <class T> using vec = std::vector<T>; typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } tem...
#include <bits/stdc++.h> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; template <class T> using vec = std::vector<T>; typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } tem...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 15, 23, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 15, 23, 0, 2, 3, 4, 0, 16, 12, 13]]
1
598
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // #include <boost...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> // #include <boost...
[["+", 49, 53, 54, 55, 0, 56, 0, 153, 0, 154], ["+", 49, 53, 54, 55, 0, 56, 49, 352, 0, 67], ["-", 8, 9, 0, 43, 49, 50, 51, 41, 75, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 41, 75, 13]]
1
430
#include <iostream> #include <vector> using namespace std; int odp = 0, n, m, q; void rec(vector<int> x, int nr, int co, vector<int> &a, vector<int> &b, vector<int> &c, vector<int> &d) { x[nr] = co; if (nr == n) { int wyn = 0; for (int i = 0; i < q; ++i) if (x[b[i]] - x[a[i]] == c[i]) ...
#include <iostream> #include <vector> using namespace std; int odp = 0, n, m, q; void rec(vector<int> x, int nr, int co, vector<int> &a, vector<int> &b, vector<int> &c, vector<int> &d) { x[nr] = co; if (nr == n - 1) { int wyn = 0; for (int i = 0; i < q; ++i) if (x[b[i]] - x[a[i]] == c[i]) ...
[["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
314
#import numpy as np import math #from fractions import gcd def check_Q(current_list,Qset): sum_d = 0 for i in range(len(Qset)): current_Qset = Qset[i] if (current_list[current_Qset[1]-1]-current_list[current_Qset[0]-1])==current_Qset[2]: sum_d = sum_d+current_Qset[3] return su...
#import numpy as np import math #from fractions import gcd def check_Q(current_list,Qset): sum_d = 0 for i in range(len(Qset)): current_Qset = Qset[i] #print(current_Qset) #print(current_list) #print(sum_d) if (current_list[current_Qset[1]-1]-current_list[current_Qset[0...
[["-", 12, 657, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 12, 657, 12, 652, 3, 4, 0, 657, 12, 612]]
5
302
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; #define vll vector<ll> #define FOR(i, b, e) for (int i = (b); i < (e); ++i) #define REP(i, e) FOR(i, 0, e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define RE...
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; #define vll vector<ll> #define FOR(i, b, e) for (int i = (b); i < (e); ++i) #define REP(i, e) FOR(i, 0, e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define RE...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
381