submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s313470683
p04051
Time Limit Exceeded
from collections import defaultdict def solve(): Base = 2000 MAX = Base*2 p = 10**9+7 F = [1]; Finv = [0]*(MAX*2+1) for i in xrange(MAX*2): F.append(F[i]*(i+1)%p) Finv[MAX*2] = pow(F[MAX*2],p-2,p) for i in xrange(MAX*2,0,-1): Finv[i-1] = Finv[i]*i%p N = int(raw_input()) dup = A_MAX = B_MAX = 0 dp = [[0]*(MAX+...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s498436523
p04051
Time Limit Exceeded
from collections import defaultdict def solve(): Base = 2000 MAX = Base*2 p = 10**9+7 F = [1]; Finv = [0]*(MAX+1) for i in xrange(MAX*2): F.append(F[i]*(i+1)%p) Finv[MAX] = pow(F[MAX],p-2,p) for i in xrange(MAX,0,-1): Finv[i-1] = Finv[i]*i%p N = int(raw_input()) dup = 0 dp = [[0]*(MAX+2) for i in xrange(MAX+2...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s450910072
p04051
Time Limit Exceeded
import math set_num = int(raw_input()) bbqsets = [] _append = bbqsets.append for _ in xrange(set_num): _append([ int(x) for x in raw_input().split() ]) maxnum = math.pow(10, 9) + 7 cache = {} total = 0 fact = math.factorial for x in xrange(set_num): setA = bbqsets[x] for y in xrange(x + 1, set_num): ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s950889610
p04051
Time Limit Exceeded
import math set_num = int(raw_input()) bbqsets = [] _append = bbqsets.append for _ in xrange(set_num): _append([ int(x) for x in raw_input().split() ]) maxnum = math.pow(10, 9) + 7 cache = {} total = 0 for x in xrange(set_num): setA = bbqsets[x] for y in xrange(x + 1, set_num): setB = bbqsets[y] ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s478505632
p04051
Time Limit Exceeded
import scipy.misc as scm def combi(p,q): return scm.comb(p,q,1) ans=0 n=int(input()) k=[] for i in range(n): a,b=map(int,input().split()) k.append([a,b]) for i in range(n-1): for j in range(i+1,n): p=k[i][0]+k[i][1]+k[j][0]+k[j][1] q=k[i][0]+k[j][0] ans += combi(p,q) % (10**9+7...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s890197679
p04051
Time Limit Exceeded
def calc(ab1,ab2): meat = ab1[0] + ab2[0] vege = ab1[1] + ab2[1] pattern = fact_list[meat+vege] / (fact_list[meat] * fact_list[vege]) return pattern if __name__ == '__main__': N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] fact_list = {} fact_list[0] = 1 ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s706405673
p04051
Time Limit Exceeded
def calc(ab1,ab2): meat = ab1[0] + ab2[0] vege = ab1[1] + ab2[1] pattern = fact_list[meat+vege] / (fact_list[meat] * fact_list[vege]) return pattern if __name__ == '__main__': N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] fact_list = {} fact_list[0] = 1 ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s262144512
p04051
Time Limit Exceeded
def calc(ab1,ab2): meat = ab1[0] + ab2[0] vege = ab1[1] + ab2[1] pattern = fact_list[meat+vege] / (fact_list[meat] * fact_list[vege]) return pattern if __name__ == '__main__': N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] fact_list = {} fact_list[0] = 1 ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s322096708
p04051
Time Limit Exceeded
import math set_num = int(raw_input()) bbqsets = [] _append = bbqsets.append for _ in xrange(set_num): _append([ int(x) for x in raw_input().split() ]) maxnum = math.pow(10, 9) + 7 cache = {} def get_combinations(meats, veges): nums = sorted([meats, veges]) key = '{}:{}'.format(nums[0], nums[1]) if k...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s948075523
p04051
Accepted
import sys from collections import defaultdict import numpy as np def prepare(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s860871725
p04051
Accepted
import sys from collections import defaultdict import numpy as np def prepare(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s227650434
p04051
Accepted
import sys from collections import defaultdict import numpy as np def prepare(n, MOD): f = 1 factorials = [1] for m in range(1, n + 1): f *= m f %= MOD factorials.append(f) inv = pow(f, MOD - 2, MOD) invs = [1] * (n + 1) invs[n] = inv for m in range(n, 1, -1): ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s450623609
p04051
Accepted
mod = 10**9+7 mod2 = 998244353 rng = 100100 fctr = [1] finv = [1] for i in range(1,rng): fctr.append(fctr[-1]*i%mod) for i in range(1,rng): finv.append(pow(fctr[i],mod-2,mod)) def cmb(n,k): if n<0 or k<0: return 0 else: return fctr[n]*finv[n-k]*finv[k]%mod n = int(input()) ab = [list(map(int,input().spl...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s776194541
p04051
Accepted
import numpy as np N = int(input()) A = [list(map(int, input().split())) for _ in range(N)] mod = int(1e+9) + 7 def extgcd(a, b): if b == 0: return 1, 0 else: x, y, u, v, k, l = 1, 0, 0, 1, a, b while l != 0: x, y, u, v = u, v, x - u * (k // l), y - v * (k // l) k, l = l, k % l return x...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s283438001
p04051
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 N = int(readline()) m = map(int,read().split()) AB = zip(m,m) D = 2000 U = 10 ** 4 fact = [1] * U for n in range(1,U): fact[n] = fact[n-1] * n % MOD fact_inv ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s051907309
p04051
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 N = int(readline()) m = map(int,read().split()) AB = zip(m,m) D = 2000 U = 10 ** 4 fact = [1] * U for n in range(1,U): fact[n] = fact[n-1] * n % MOD fact_inv ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s218722401
p04051
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 N = int(readline()) m = map(int,read().split()) AB = zip(m,m) D = 2000 def cumprod(arr,MOD): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2)....
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s522586576
p04051
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 N = int(readline()) m = map(int,read().split()) AB = zip(m,m) D = 2000 def cumprod(arr,MOD): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2)....
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s186603920
p04051
Accepted
from collections import defaultdict def solve(): Base = 2000 MAX = Base*2 p = 10**9+7 F = [1]; Finv = [0]*(MAX*2+1) for i in xrange(MAX*2): F.append(F[i]*(i+1)%p) Finv[MAX] = pow(F[MAX],p-2,p) for i in xrange(MAX,0,-1): Finv[i-1] = Finv[i]*i%p N = int(raw_input()) dup = A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s482351851
p04051
Runtime Error
import math n = int(input()) list = [] for i in range(n): list.append(input().split()) sum = 0 for j in range(n): for k in range(j+1,n): if j!=k: num = math.factorial(int(list[j][0])+int(list[j][1])+int(list[k][0])+int(list[k][1])) / (math.factorial(int(list[j][0])+int(list[k][0]))*math.factorial(int(list[j]...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s525778405
p04051
Runtime Error
#include<bits/stdc++.h> using namespace std; const int N=2e5+50,M=4040,mod=1e9+7,L=2000; int n,a[N],b[N],f[M][M],ans,J[N],I[N]; int C(int n,int m){return 1ll*J[n]*I[m]%mod*I[n-m]%mod;} int main(){ scanf("%d",&n);J[0]=I[0]=I[1]=1; for(int i=2;i<=4*L;i++)I[i]=mod-1ll*mod/i*I[mod%i]%mod; for(int i=1;i<=4*L;i++)J[i]=1ll...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s389585547
p04051
Runtime Error
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 N = int(readline()) m = map(int,read().split()) AB = zip(m,m) D = 2000 def cumprod(arr,MOD): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2)....
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s797478744
p04051
Runtime Error
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np MOD = 10 ** 9 + 7 N = int(readline()) m = map(int,read().split()) AB = zip(m,m) D = 2000 def cumprod(arr,MOD): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2)....
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s089948526
p04051
Runtime Error
def co(a, b): a += b res = 1 for i in range(1,b+1): res *= ((a-i+1) / i) return int(res) n = int(input()) a = [0 for i in range(n)] b = [0 for i in range(n)] for ni in range(n): a[ni], b[ni] = (int(i) for i in input().split(" ")) a = tuple(a) b = tuple(b) res = 0 for i in range(n): ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s293146402
p04051
Runtime Error
def co(a, b): a += b res = 1 for i in range(1,b+1): res *= ((a-i+1) / i) return int(res) n = int(input()) a = [0 for i in range(n)] b = [0 for i in range(n)] for ni in range(n): a[ni], b[ni] = (int(i) for i in input().split(" ")) res = 0 for i in range(n): for j in range(i+1,n): ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s140871420
p04051
Runtime Error
def co(a, b): res = 1 for i in range(1,b+1): res *= ((a-i+1) / i) return int(res) n = int(input()) a = [0 for i in range(n)] b = [0 for i in range(n)] for ni in range(n): a[ni], b[ni] = (int(i) for i in input().split(" ")) res = 0 for i in range(n): for j in range(i+1,n): res += ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s200518468
p04051
Runtime Error
# your code goes here from itertools import combinations from scipy.misc import comb N = int(input()) A = [] B = [] for n in range(N): a, b = [int(x) for x in input().split()] A.append(a) B.append(b) S = 0 for n1, n2 in combinations(range(N),2): a1, b1 = A[n1], B[n1] a2, b2 = A[n2], B[n2] s = comb(a1+b1+a2+b2,...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s350121004
p04051
Runtime Error
# your code goes here from itertools import combinations from scipy.special import comb # a = comb(n, r) # a = comb(n, r, exact=True) N = int(input()) A = [] B = [] for n in range(N): a, b = [int(x) for x in input().split()] A.append(a) B.append(b) S = 0 for n1, n2 in combinations(range(N),2): a1, b1 = A[n1], B[...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s504475340
p04051
Runtime Error
def fact(n): ret = 1 for i in range(2, n+1): ret *= i return ret def C(a,b,c): ret = 1 for i in range(b+1, a + 1): ret *= i return int(ret / fact(c)) n = int(input()) gu = [] for i in range(n): gu.append(list(map(int, input().split(' ')))) ret = 0 for i in range(n - 1): for j in range(i+1,...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s917522426
p04051
Runtime Error
def fact(n): ret = 1 for i in range(2, n+1): ret *= i return ret def C(a,b,c): ret = 1 for i in range(b+1, a + 1): ret *= i return int(ret / fact(c)) n = int(input()) gu = [] for i in range(n): gu.append(list(map(int, input().split(' ')))) ret = 0 for i in range(n - 1):...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s853958902
p04051
Runtime Error
def fact(n): ret = 1 for i in range(2, n+1): ret *= i return ret n = int(input()) gu = [] for i in range(n): gu.append(list(map(int, input().split(' ')))) ret = 0 for i in range(n - 1): for j in range(i+1, n): ret += int(fact(gu[i][0] + gu[i][1] + gu[j][0] + gu[j][1]) / fact(gu[...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s608875432
p04051
Runtime Error
def fact(n): if n == 1: return 1 else: return fact(n - 1) * n n = int(input()) gu = [] for i in range(n): gu.append(list(map(int, input().split(' ')))) ret = 0 for i in range(n - 1): for j in range(i+1, n): ret += int(fact(gu[i][0] + gu[i][1] + gu[j][0] + gu[j][1]) / fact(gu...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s741244779
p04051
Runtime Error
import scipy.misc as scm def combi(p,q): return scm.comb(p,q,1) ans=0 n=int(input()) k=[] for i in range(n): a,b=map(int,input().split()) k.append([a,b]) for i in range(n-1): for j in range(1,n): p=k[i][0]+k[i][1]+k[j][0]+k[j][1] q=k[i][0]+k[j][0] ans += combi(p,q) % (10**9+7) ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s510438237
p04051
Runtime Error
def calc(ab1,ab2): meat = ab1[0] + ab2[0] vege = ab1[1] + ab2[1] pattern = fact_list[meat+vege] / (fact_list[meat] * fact_list[vege]) return pattern if __name__ == '__main__': N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] fact_list = {} fact_list[0] = 1 ...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s959683316
p04051
Runtime Error
def calc(ab1,ab2,fact_list): meat = ab1[0] + ab2[0] vege = ab1[1] + ab2[1] pattern = fact_list[meat+vege] / (fact_list[meat] * fact_list[vege]) return pattern if __name__ == '__main__': N = int(input()) AB = [list(map(int, input().split())) for i in range(N)] fact_list = {} fact_list...
3 1 1 1 1 2 1
26
<span class="lang-en"> <p>Score : <var>1400</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke is having another barbeque party.</p> <p>This time, he will make one serving of <em>Skewer Meal</em>.</p> <p>He has a stock of <var>N</var> <em>Skewer Meal Packs</em>. The <var>i</var>-th Skewer ...
s947077253
p04052
Wrong Answer
n, k = map(int, input().split()) nums = list(map(int, input().split())) dict_indexs = {} for i, num in enumerate(nums): dict_indexs[num - 1] = i while True: flag = False for i in range(n - 1): a = dict_indexs[i] b = dict_indexs[i + 1] if a - b >= k: dict_indexs[i] = b ...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s669918514
p04052
Wrong Answer
NK=input() NK="".join(NK).rstrip("\n").split(" ") N,K,ans=int(NK[0]),int(NK[1]),[] DP=[0 for s in range(N+1)]#各数字があるかどうか[数字],取りだせるのがindex lis=input() lis = "".join(lis).split(" ") lis=[int(s) for s in lis] print(lis) St=0 for s in range(N): DP[lis[s]]=s+1 #if DP[lis[s]]!=0: #DP[lis[s]]+=[s+1]#同じ数字が複数個ある場合の処理 def se...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s102943485
p04052
Wrong Answer
NK=input() NK="".join(NK).rstrip("\n").split(" ") N,K,ans=int(NK[0]),int(NK[1]),[] DP=[0 for s in range(N+1)]#各数字があるかどうか[数字],取りだせるのがindex lis=input() lis = "".join(lis).split(" ") lis=[int(s) for s in lis] print(lis) St=0 for s in range(N): DP[lis[s]]=s+1 def search(num): comp=DP[num]#先頭が4の場合はここで3を探す if comp<DP[num+...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s751397118
p04052
Wrong Answer
NK=input() NK="".join(NK).rstrip("\n").split(" ") N,K,ans=int(NK[0]),int(NK[1]),[] DP=[0 for s in range(N+1)]#各数字があるかどうか[数字],取りだせるのがindex lis=input() lis = "".join(lis).split(" ") lis=[int(s) for s in lis] for s in range(N): DP[lis[s]]=s+1 def search(num): comp=DP[num]#先頭が4の場合はここで3を探す if comp<DP[num+1]: return ...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s289012101
p04052
Wrong Answer
NK=input() NK="".join(NK).rstrip("\n").split(" ") N,K,ans=int(NK[0]),int(NK[1]),[] DP=[0 for s in range(N+1)]#各数字があるかどうか[数字],取りだせるのがindex lis=input() lis = "".join(lis).split(" ") lis=[int(s) for s in lis] for s in range(N): DP[lis[s]]=s+1 def search(num): comp=DP[num]#先頭が4の場合はここで3を探す if comp<DP[num+1]: return 0 ...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s792069043
p04052
Time Limit Exceeded
N,K = input().split() N,K = int(N), int(K) P = [[int(x),i] for i,x in enumerate(input().split())] P = sorted(P) # [(1, 3), (2, 1), (3, 2), (4, 0)] flag = False i = -1 while(True): if P[i-1][1] - P[i][1] >= K: temp = P[i-1][1] P[i-1][1] = P[i][1] P[i][1] = temp flag = True ...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s248844511
p04052
Time Limit Exceeded
N, K = [int(x) for x in input().split()] nums = {int(x):i for i, x in enumerate(input().split())} swap = True while swap: swap = False for x in range(1, N): if nums[x] - nums[x+1] >= K: nums[x], nums[x+1] = nums[x+1], nums[x] swap = True for k, v in sorted(nums.items(), key=lambda item: item[1]...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s534545425
p04052
Time Limit Exceeded
N, K = [int(x) for x in input().split()] nums = [int(x) for x in input().split()] def f_swap(nums, N, K): for i in range(0, N-K): for j in range(i+K, N): if nums[i] - nums[j] == 1: nums[i], nums[j] = nums[j], nums[i] return 1 return 0 while True: if not f_swap(nums, N, K): break f...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s897196251
p04052
Time Limit Exceeded
import numpy as np def func(): line1 = input('') line2 = input('') line1 = line1.split(' ') line2 = line2.split(' ') N = int(line1[0]) K = int(line1[1]) ar = np.zeros([N],np.int) for i in range(0,N): ar[i] = line2[i] flag = True while flag: flag = False ...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s994712690
p04052
Time Limit Exceeded
input_word = input() input_list = input_word.split(" ") N = int(input_list[0]) K = int(input_list[1]) input_word = input() tmp_list = input_word.split(" ") input_list = [ int(i) for i in tmp_list ] while True: flag = 0 for i in range(1,N): number = input_list.index(i) number_1 = input_list.index(i+1) i...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s410912300
p04052
Time Limit Exceeded
input_word = input() input_list = input_word.split(" ") N = int(input_list[0]) K = int(input_list[1]) input_word = input() tmp_list = input_word.split(" ") input_list = [ int(i) for i in tmp_list ] while True: flag = 0 for i in range(1,N+1): number = input_list.index(i) for j in range(0,number): if n...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s619005967
p04052
Time Limit Exceeded
n, k = (int(s) for s in input().strip().split(' ')) p = [int(s) for s in input().strip().split(' ')] index = len(p) while index > k: changed = False for i in range(0, index - k): if p[i] == p[index - 1] + 1: p[i], p[index - 1] = p[index - 1], p[i] changed = True index...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s120612309
p04052
Time Limit Exceeded
n, k = (int(s) for s in input().strip().split(' ')) p = [int(s) for s in input().strip().split(' ')] index = len(p) while index > 0: changed = False for i in range(0, index - k): if p[i] == p[index - 1] + 1: p[i], p[index - 1] = p[index - 1], p[i] changed = True index...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...
s332524056
p04052
Accepted
def invert(p, q): for i, pi in enumerate(p): q[pi] = i def sort_insertion(k, data, first, last): length = last - first if length <= 2: if length == 2 and data[first] - data[first + 1] >= k: data[first], data[first + 1] = data[first + 1], data[first] return for i in range(fir...
4 2 4 2 3 1
2 1 4 3
<span class="lang-en"> <p>Score : <var>2000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>You are given a permutation <var>P_1 ... P_N</var> of the set {<var>1</var>, <var>2</var>, ..., <var>N</var>}.</p> <p>You can apply the following operation to this permutation, any number of times (pos...