submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s938174787
p04049
Runtime Error
import sys from collections import deque, defaultdict def bfs(links, s, limit): not_reachable = [True] * len(links) q = deque([(0, s, -1)]) while q: cost, v, p = q.popleft() if cost > limit: break not_reachable[v] = False cost += 1 q.extend((cost, u, v) ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s369512498
p04049
Runtime Error
#C n,k = [int(i) for i in input().split()] edges = [[] for _ in range(n)] for i in range(n-1): a,b = [int(j) for j in input().split()] edges[a-1].append(b-1) edges[b-1].append(a-1) def dfs(u, cost): if dist[u]>=0: #if searched already return dist[u] = cost e = edges[u] for ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s434611661
p04049
Runtime Error
#C n,k = [int(i) for i in input().split()] edges = [[] for _ in range(n)] for i in range(n-1): a,b = [int(j) for j in input().split()] edges[a-1].append(b-1) edges[b-1].append(a-1) ans = n #when k is even, we should think about each node if k%2==0: def dfs(u, cost): if dist[u]>=0: #if s...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s296170347
p04049
Runtime Error
n, k = map(int, input().split()) tree = [[] for i in range(n)] for _ in range(n - 1): a, b = sorted(map(int, input().split())) tree[a - 1].append(b - 1) tree[b - 1].append(a - 1) def search(tree, pos, past=None, depth=0): """ 子孫ノードを探索して、最深のノードとその深さを返す """ # 子ノードを探索する ress = [] # 子ノードの...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s989027159
p04049
Runtime Error
n, k = map(int, input().split()) tree = [[] for i in range(n)] for _ in range(n - 1): a, b = sorted(map(int, input().split())) tree[a - 1].append(b - 1) tree[b - 1].append(a - 1) def search(tree, pos, past=None, depth=0): """ 子孫ノードを探索して、最深のノードとその深さを返す """ # 子ノードを探索する ress = [] # 子ノードの...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s406256226
p04049
Runtime Error
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ n,k = map(int, input().split()) G = [[] for i in range(n)] edges = [] for i in range(n-1): a,b = map(int, input().split()) a,b = a-1,b-1 G[a].append(b) G[b].append(a) edges.append((a,b)) cnt = [0] def search(cur, prev, dep...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s510777512
p04049
Runtime Error
#include <stdio.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s076769013
p04049
Runtime Error
n,k = map(int,input().split()) INF = float("inf") edges = [[] for i in range(n)] ega = [] for i in range(n-1): a,b = map(int,input().split()) a = a-1 b = b-1 edges[a].append(b) edges[b].append(a) ega.append([a,b]) def dfs(v): d= [0] * n q=[v] visited = [0] * n while q: ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s963926242
p04049
Runtime Error
n,k = map(int,input().split()) import numpy as np INF = float("inf") edges = [[] for i in range(n)] ega = [] for i in range(n-1): a,b = map(int,input().split()) a = a-1 b = b-1 edges[a].append(b) edges[b].append(a) ega.append([a,b]) def dfs(v): visited = [] INF = float("inf") d=[...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s215625013
p04049
Runtime Error
N, K = map(int, input().split()) G = [[] for i in range(N)] for i in range(N - 1): a, b = map(int, input().split()) G[a - 1].append(b - 1) G[b - 1].append(a - 1) def dfs(u, par, d): global tmp if d > K // 2: tmp += 1 for w in G[u]: if w == par: continue dfs...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s609326818
p04049
Runtime Error
#import sys #input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append((a-1,b-1)) def f(x,y,c): global tmp c += 1 for e in edge[x]: ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s532382604
p04049
Runtime Error
import sys sys.setrecursionlimit(5000000) input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append((a-1,b-1)) if n==2: print(0) exit() def ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s931452563
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s238312663
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x): #c +=1 for e in e...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s587581130
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y): #c +=1 for e in...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s300255193
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s691044328
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 if len...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s299004138
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 if len...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s584456806
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s310044627
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s621226825
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append([a-1,b-1]) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s726216232
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append((a-1,b-1)) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s811438918
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append((a-1,b-1)) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s626659322
p04049
Runtime Error
#import sys #input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append((a-1,b-1)) if n==2: print(0) exit() def f(x,y,c): c += 1 for ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s397303827
p04049
Runtime Error
import sys input = sys.stdin.readline n,k = map(int,input().split()) edge = [[] for i in range(n)] alledge = [] for i in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) alledge.append((a-1,b-1)) if n==2: print(0) exit() def f(x,y,c): c += 1 for e ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s098360855
p04049
Runtime Error
n, k = map(int, input().split()) import sys sys.setrecursionlimit(2000) l = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) l[a-1].append(b-1) l[b-1].append(a-1) def first_search(first, depth): record = 0 for i in l[first]: temp = search(first, i, depth-1) ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s651912799
p04049
Runtime Error
n, k = map(int, input().split()) import sys sys.setrecursionlimit(2000) l = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) l[a-1].append(b-1) l[b-1].append(a-1) def first_search(first, depth): record = 0 for i in l[first]: temp = search(first, i, depth-1) ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s070727505
p04049
Runtime Error
n, k = map(int, input().split()) import sys sys.setrecursionlimit(2000) l = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) l[a-1].append(b-1) l[b-1].append(a-1) def first_search(first, depth): record = 0 for i in l[first]: temp = search(first, i, depth-1) ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s799452240
p04049
Runtime Error
n, k = map(int, input().split()) l = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) l[a-1].append(b-1) l[b-1].append(a-1) l2 = [0 for i in range(n)] def first_search(first, depth): record = 0 for i in l[first]: temp = search(first, i, depth-1) if re...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s284151588
p04049
Runtime Error
import sys stdin = sys.stdin def li(): return map(int, stdin.readline().split()) def li_(): return map(lambda x: int(x)-1, stdin.readline().split()) def lf(): return map(float, stdin.readline().split()) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return list(ns()) def...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s304854364
p04049
Runtime Error
import numpy as np N, K = map(int, input().split()) E = np.zeros((N, N), dtype=int) # Elist = [] for e in range(N-1): i, o = map(int, input().split()) # Elist.append((i-1, o-1)) E[i-1][o-1] = 1 E[o-1][i-1] = 1 # print("N, K=", N, K) # for e in Elist: # print(e[0], e[1]) I = np.eye(N, dtype=int)...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s669543599
p04049
Runtime Error
import numpy as np N, K = map(int, input().split()) E = np.zeros((N, N), dtype=int) Elist = [] for e in range(N-1): i, o = map(int, input().split()) Elist.append((i-1, o-1)) E[i-1][o-1] = 1 E[o-1][i-1] = 1 # print("N, K=", N, K) # for e in Elist: # print(e[0], e[1]) I = np.eye(N, dtype=int)...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s624676471
p04049
Runtime Error
import numpy as np N, K = map(int, input().split()) E = np.zeros((N, N), dtype=int) Elist = [] for e in range(N-1): i, o = map(int, input().split()) Elist.append((i-1, o-1)) E[i-1][o-1] = 1 E[o-1][i-1] = 1 # print("N, K=", N, K) # for e in Elist: # print(e[0], e[1]) I = np.eye(N, dtype=int)...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s423454121
p04049
Runtime Error
from collections import deque N, K = map(int, input().split()) T = [[] for i in range(N)] E = [] for i in range(N-1): a, b = map(int, input().split()) a, b = a-1, b-1 T[a].append(b) T[b].append(a) E.append((a, b)) def bfs(n): visited = [False] * N dist = [0] * N queue = deque([n]) ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s889802136
p04049
Runtime Error
from collections import deque N, K = map(int, input().split()) T = [[] for i in range(N)] E = [] for i in range(N-1): a, b = map(int, input().split()) a, b = a-1, b-1 T[a].append(b) T[b].append(a) E.append((a, b)) def bfs(n): visited = [False] * N dist = [0] * N queue = deque([n]) ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s566373062
p04049
Runtime Error
o=lambda:map(int,raw_input().split());r=range(n);a=10**5 n,k=o() e=[[]for _ in [0]*n] for _ in [0]*(n-1):a,b=o();e[a-1]+=[b-1];e[b-1]+=[a-1] def U(x,f): l[f]=1;q=[(x,0)] while len(q): v,c=q.pop(0) if c>k/2:break l[v]=1 for w in e[v]: if not l[w]:q+=[(w,c+1)] return n-l.count(1) if k%2: for i in r: for ...
6 2 1 2 3 2 4 2 1 6 5 6
2
<span class="lang-en"> <p>Score : <var>600</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Given an undirected tree, let the distance between vertices <var>u</var> and <var>v</var> be the number of edges on the simple path from <var>u</var> to <var>v</var>. The diameter of a tree is the maxim...
s287463219
p04050
Wrong Answer
from sys import exit n, m = map(int, input().split()) a = list(map(int, input().split())) odd = [] even = [] for x in a: if x%2 == 0: even.append(x) else: odd.append(x) if n%2 == 0: if len(odd) > 2: print("Impossible") exit() if len(odd) == 2: a = [odd[0]] + even + [odd[1]] b = [odd[0]+1] + even + [od...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s104198375
p04050
Wrong Answer
from sys import exit n, m = map(int, input().split()) a = list(map(int, input().split())) odd = [] even = [] for x in a: if x%2 == 0: even.append(x) else: odd.append(x) if n%2 == 0: if len(odd) > 2: print("Impossible") exit() if len(odd) == 2: a = [odd[0]] + even + [odd[1]] b = [odd[0]+1] + even + [od...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s607817470
p04050
Wrong Answer
import sys def solve(n, m, arr): odds = [] evens = [] for a in arr: if a % 2 == 0: evens.append(a) else: odds.append(a) if len(odds) > 2: print('Impossible') return if len(odds) == 2: o1, o2 = odds aaa = [o1] + evens + [o2] ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s701292968
p04050
Wrong Answer
import sys def solve(n, m, arr): odds = [] evens = [] for a in arr: if a % 2 == 0: evens.append(a) else: odds.append(a) if len(odds) > 2: print('Impossible') return if len(odds) == 2: o1, o2 = odds aaa = [o1] + evens + [o2] ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s498481701
p04050
Wrong Answer
n,m=map(int,input().split()) a=list(map(int,input().split())) b=[] o=[] for i in a: if i%2:o.append(i) else:b.append(i) if len(o)>2:print("Impossible");exit() if len(o)==1:b=o+b elif len(o)==2:b=[o[0]]+b+[o[1]] ans=[] for i in range(len(b)): if i==0:ans.append(b[i]-1) elif i==len(b)-1:ans.append(b[i]+1) else:...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s799170240
p04050
Wrong Answer
n,m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] breakFlag = False for i in range(1,m-1): if a[i]%2==1: if a[0]%2==1: if a[len(a)-1]%2==1: print("Impossible") breakFlag = True break else: a[...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s252919422
p04050
Wrong Answer
n,m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] breakFlag = False for i in range(m): if a[i]%2==1: if a[0]%2==1: if a[len(a)-1]%2==1: print("Impossible") breakFlag = True break else: a[i],a...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s257283179
p04050
Wrong Answer
import sys n, m = map(int, input().split(' ')) A = list(map(int, input().split(' '))) A_odds = [x for x in A if x % 2 == 0] A_evens = [x for x in A if x % 2 == 1] a = [] b = [] if len(A_odds) > 2: print('Impossible') sys.exit(); if len(A_odds) != 0: a.append(A_odds[0]) a += A_evens if len(A_odds) == 2: a.ap...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s499016448
p04050
Wrong Answer
n, m = map(int, raw_input().split()) a = map(int,raw_input().split()) cntodd = 0 for x in a:cntodd += x % 2 if cntodd > 2: print "Impossible" exit() evens = [x for x in a if x % 2 == 0] odds = [x for x in a if x % 2 == 1] if len(a) == 1: print a[0] print 2 print a[0]-1,1 exit() if cntodd...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s931854329
p04050
Wrong Answer
n, m = map(int, raw_input().split()) a = map(int,raw_input().split()) cntodd = 0 for x in a:cntodd += x % 2 if cntodd > 2: print "Impossible" exit() evens = [x for x in a if x % 2 == 0] odds = [x for x in a if x % 2 == 1] if cntodd == 2: a = odds[0] + evens + odds[1] b = a[::] b[0] += 1 b[-1]...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s743351234
p04050
Accepted
from sys import exit n, m = map(int, input().split()) a = list(map(int, input().split())) odd = [] even = [] for x in a: if x%2 == 0: even.append(x) else: odd.append(x) if n%2 == 0: if len(odd) > 2: print("Impossible") exit() if len(odd) == 2: a = [odd[0]] + even + [odd[1]] b = [odd[0]+1] + even + [od...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s965943795
p04050
Accepted
import sys def solve(n, m, arr): odds = [] evens = [] for a in arr: if a % 2 == 0: evens.append(a) else: odds.append(a) if len(odds) > 2: print('Impossible') return if len(odds) == 2: o1, o2 = odds aaa = [o1] + evens + [o2] ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s571339864
p04050
Accepted
n,m=map(int,input().split()) a=list(map(int,input().split())) b=[] o=[] for i in a: if i%2:o.append(i) else:b.append(i) if len(o)>2:print("Impossible");exit() if len(o)==1:b=o+b elif len(o)==2:b=[o[0]]+b+[o[1]] ans=[] for i in range(len(b)): if i==0:ans.append(b[i]-1) elif i==len(b)-1:ans.append(b[i]+1) else:...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s943528127
p04050
Accepted
n,m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] breakFlag = False for i in range(1,m-1): if a[i]%2==1: if a[0]%2==1: if a[len(a)-1]%2==1: print("Impossible") breakFlag = True break else: a[...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s065079131
p04050
Accepted
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) N,M = map(int,readline().split()) A = [int(x) for x in readline().split()] OD = [x for x in A if x&1] EV = [x for x in A if not x&1] if len(OD) >= 3: print('Impossible') exit() if len(A) == 1: if N ==...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s952339729
p04050
Accepted
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc001 D """ n, m = map(int, input().split()) ali = list(map(int, input().split())) if m == 1 and ali[0] == 1: print(1) print(1) print(1) exit() if m == 1: print(ali[0]) print(2) print(ali[0]-1, 1) exit() flag = 0...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s213815438
p04050
Accepted
#!/usr/bin/env python3 def solve(n, m, a): odd = [] even = [] for a_i in a: if a_i % 2 == 0: even += [ a_i ] else: odd += [ a_i ] if len(odd) >= 3: return None a, b = [], [] if odd: x = odd.pop() a += [ x ] b += [ x - 1 ] ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s637050993
p04050
Accepted
S, N = map(int, input().split()) A = list(map(int, input().split())) O = [a for a in A if a % 2 == 1] E = [a for a in A if a % 2 == 0] if len(O) > 2: print("Impossible") else: A = O[:min(len(O), 1)] + E + O[1:] B = A[:] + ([0] if N == 1 else []) B[0] -= 1 B[-1] += 1 if B[0] == 0: B = B[...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s709919279
p04050
Accepted
S, N = map(int, input().split()) A = list(map(int, input().split())) O = [a for a in A if a % 2 == 1] E = [a for a in A if a % 2 == 0] if len(O) > 2: print("Impossible") else: A = O[:min(len(O), 1)] + E + O[min(1, len(O)):] B = A[:] + ([0] if len(A) == 1 else []) B[0] -= 1 B[-1] += 1 if B[0] ==...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s934501506
p04050
Accepted
n, m = map(int, raw_input().split()) a = map(int,raw_input().split()) cntodd = 0 for x in a:cntodd += x % 2 if cntodd > 2: print "Impossible" exit() evens = [x for x in a if x % 2 == 0] odds = [x for x in a if x % 2 == 1] if len(a) == 1: if a[0] == 1: print 1 print 1 print 1 ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s678667268
p04050
Accepted
from sys import stdout def main(): n, m = map(int, raw_input().split()) a = map(int, raw_input().split()) if m == 1: print a[0] if n == 1: print 1 print 1 else: print 2 print 1, n - 1 return if sum(x % 2 for x in a) > 2: ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s960682356
p04050
Runtime Error
n,m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] breakFlag = False for i in range(1,m-1): if a[i]%2==1: if a[0]%2==1: if a[len(a)-1]%2==1: print("Impossible") breakFlag = True break else: a[...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s347349727
p04050
Runtime Error
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) N,M = map(int,readline().split()) A = [int(x) for x in readline().split()] OD = [x for x in A if x&1] EV = [x for x in A if not x&1] if len(OD) >= 3: print('Impossible') exit() if len(A) == 1: if N ==...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s747140087
p04050
Runtime Error
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc001 D """ n, m = map(int, input().split()) ali = list(map(int, input().split())) if m == 1: print(ali[0]) print(2) print(ali[0]-1, 1) exit() flag = 0 c = [] for a in ali: if a % 2 == 1: if flag == 0: lm ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s950372139
p04050
Runtime Error
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # """ agc001 D """ n, m = map(int, input().split()) ali = list(map(int, input().split())) if m == 1: print(ali[0]) print(1) print(ali[0]-1, 1) exit() flag = 0 c = [] for a in ali: if a & 1: if flag == 0: lm = a ...
3 2 2 1
1 2 1 3
<span class="lang-en"> <p>Score : <var>1000</var> points</p> <div class="part"> <section> <h3>Problem Statement</h3><p>Snuke got a present from his mother on his birthday. The present was a pair of two sequences <var>a</var> and <var>b</var>, consisting of positive integers. They satisfied all of the following properti...
s507846696
p04051
Wrong Answer
from scipy.special import comb MOD = 1000000007 #n = 3 #a = [1,1,2] #b = [1,1,1] n = int(input()) a = [0] * n b = [0] * n for i in range(n): a[i], b[i] = map(int, input().split()) count = 0 for i in range(n-1): M = a[i] + b[i] for j in range(i+1, n): N = M + a[j] + b[j] # print(i+1, j+1, co...
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 ...
s857122274
p04051
Wrong Answer
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 ...
s357060639
p04051
Wrong Answer
U = 10**6 MOD = 10**9+7 fact = [1]*(U+1) fact_inv = [1]*(U+1) for i in range(1,U+1): fact[i] = (fact[i-1]*i)%MOD fact_inv[U] = pow(fact[U],MOD-2,MOD) for i in range(U,0,-1): fact_inv[i-1] = (fact_inv[i]*i)%MOD def comb(n,k): if k < 0 or k > n: return 0 z = fact[n] z *= fact_inv[k] z %= MOD z *...
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 ...
s185569170
p04051
Wrong Answer
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 ...
s033294395
p04051
Wrong Answer
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 ...
s214606202
p04051
Wrong Answer
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 ...
s041011593
p04051
Wrong Answer
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) N = int(input()) L = list(list(map(int, input().split())) for i in range(N)) cnt = 0 roop = 0 for i in range(N): for j in range(i+1, N): n = L[i][0] + L[i][1] + L[j][0] + L[j][1] r = L[i][0]...
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 ...
s057479359
p04051
Wrong Answer
def proc(n): res = 1 for i in range(1,n+1): res *= i return res def co(a, b): res = proc(a) // proc(a-b) // proc(b) return 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 i...
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 ...
s609443365
p04051
Wrong Answer
n = int(input()) arr = [map(int,raw_input().split()) for i in range(n)] count = 0 for i in range(n-1): for j in range(i+1,n): s = sum(arr[i]) + sum(arr[j]) comb = s*(s-1)/2 count += comb print count%(1000000000+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 ...
s577485755
p04051
Wrong Answer
n = int(input()) arr = [map(int,raw_input().split()) for i in range(n)] count = 0 for i in range(n-1): for j in range(i+1,n): s = sum(arr[i]) + sum(arr[j]) comb = s*(s-1)/2 count += comb print count
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 ...
s620955904
p04051
Wrong Answer
n = int(input()) arr = [[map(int,raw_input().split())] for i in range(n)] count = 0 for i in range(n): for j in range(i+1,n): if i != j : s = sum(arr[i][0]) + sum(arr[j][0]) comb = s*(s-1)/2 count += comb print count
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 ...
s841108737
p04051
Wrong Answer
import math #--- define function ___# def counter(x, y): return math.factorial(x + y) // (math.factorial(x) * math.factorial(y)) #--- main ___# N = int(input()) st = [] for i in range(N): a, b = input().split() st.append([int(a), int(b)]) count = 0 for i in range(N): for j in range(i + 1,N): l...
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 ...
s581614051
p04051
Wrong Answer
ans=0 N=int(input()) kushi=[] for s in range(N): kushi.append(input()) for s in range(N): kushi1="".join(kushi[s]).rstrip("\n").split(" ") for j in range(N-s): if j==0: continue kushi2="".join(kushi[s+j]).rstrip("\n").split(" ") n=int(kushi1[0])+int(kushi2[0])+int(kushi1[1])+int(kushi2[1]) k=int(kushi1[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 ...
s926826185
p04051
Wrong Answer
ans=0 N=int(input()) kushi=[] for s in range(N): kushi.append(input()) for s in range(N): kushi1="".join(kushi[s]).rstrip("\n").split(" ") for j in range(N-s): if j==0: continue kushi2="".join(kushi[s+j]).rstrip("\n").split(" ") n=int(kushi1[0])+int(kushi2[0])+int(kushi1[1])+int(kushi2[1]) k=int(kushi1[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 ...
s494423384
p04051
Wrong Answer
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 = A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for i...
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 ...
s668150351
p04051
Wrong Answer
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 = A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for i...
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 ...
s322726026
p04051
Wrong Answer
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 = A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for i...
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 ...
s205364448
p04051
Wrong Answer
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 = A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for i...
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 ...
s255848007
p04051
Wrong Answer
from collections import defaultdict def solve(): Base = 10 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 = A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for i i...
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 ...
s799491390
p04051
Wrong Answer
from collections import defaultdict def solve(): Base = 2000 p = 10**9+7 F = [1]; Finv = [0]*(Base*4+1) for i in xrange(Base*4): F.append(F[i]*(i+1)%p) Finv[Base*4] = pow(F[Base*4],p-2,p) for i in xrange(Base*4,0,-1): Finv[i-1] = Finv[i]*i%p N = int(raw_input()) dup = A_MAX = B_MAX = 0 dp = [[0]*(Base*2+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 ...
s914842946
p04051
Wrong Answer
from collections import defaultdict def solve(): Base = 2000 p = 10**9+7 F = [1]; Finv = [0]*(Base*4+1) for i in xrange(Base*4): F.append(F[i]*(i+1)) Finv[Base*4] = pow(F[Base*4],p-2,p) for i in xrange(Base*4,0,-1): Finv[i-1] = Finv[i]*i%p N = int(raw_input()) dup = A_MAX = B_MAX = 0 dp = [[0]*(Base*2+2) for i...
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 ...
s606876553
p04051
Wrong Answer
def combi(p,q): m=10**9+7 bunsi=1 bunbo=1 for i in range(q): bunsi *= (p-i)%m bunbo *= (q-i)%m bunsi = bunsi%m bunbo = bunbo%m return bunsi//bunbo % m 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): ...
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 ...
s094292724
p04051
Wrong Answer
N = int(raw_input()) L = [] for i in xrange(N): l = raw_input() L.append(map(int, l.split(" "))) result = 0 for j in xrange(N): M = range(N) del M[0:j + 1] for k in M: niku = (L[j][0] + L[j][1]) yasai = (L[k][0] + L[k][1]) niku_tmp = niku food = niku + yasai p...
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 ...
s864574613
p04051
Wrong Answer
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 ...
s721193811
p04051
Wrong Answer
N = int(input()) L = [] for x in range(N): L.append(list(map(int,input().split()))) val = 0 for i in range(len(L)-1): for j in range(i+1,len(L)): vvv = (L[i][0] + L[j][0] + L[i][1] + L[j][1]) val = val + int(((vvv * (vvv-1))/2)) print(val)
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 ...
s843924782
p04051
Wrong Answer
N = int(raw_input()) L = [] for i in xrange(N): l = raw_input() L.append(map(int, l.split(" "))) result = 0 for j in xrange(N): M = range(N) del M[0:j + 1] for k in M: niku = (L[j][0] + L[j][1]) yasai = (L[k][0] + L[k][1]) niku_tmp = niku food = niku + yasai p...
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 ...
s425879688
p04051
Wrong Answer
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 ...
s194798494
p04051
Time Limit Exceeded
import sys from collections import defaultdict from itertools import accumulate 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,...
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 ...
s385245666
p04051
Time Limit Exceeded
N = int(input()) mod = int(1e+9 + 7) def extgcd(a, b): 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, y def inved(x): a, b = extgcd(x, mod) return a % mod frac = [1] for i in range(8000): frac.append((frac[i]*(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 ...
s712033068
p04051
Time Limit Exceeded
U = 10**6 MOD = 10**9+7 fact = [1]*(U+1) fact_inv = [1]*(U+1) for i in range(1,U+1): fact[i] = (fact[i-1]*i)%MOD fact_inv[U] = pow(fact[U],MOD-2,MOD) for i in range(U,0,-1): fact_inv[i-1] = (fact_inv[i]*i)%MOD def comb(n,k): if k < 0 or k > n: return 0 z = fact[n] z *= fact_inv[k] z %= MOD z *...
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 ...
s413675452
p04051
Time Limit Exceeded
def proc(n): res = 1 for i in range(1,n+1): res *= i return res def co(a, b): res = proc(a) // proc(a-b) // proc(b) return 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 i...
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 ...
s973525278
p04051
Time Limit Exceeded
ans=0 N=int(input()) kushi=[] def nCk(n,k): N,K=n-1,k-1 tempN=n-1 tempK=k-1 for s in range(k-2): N=N*(tempN-1) K=K*(tempK-1) tempN-=1 tempK-=1 first=N//K N,K=n-1,k tempN=n-1 for s in range(k-1): N=N*(tempN-1) K=K*(k-1) tempN-=1 k-=1 second=N//K return int(first+second) for s in range(N): kush...
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 ...
s896267625
p04051
Time Limit Exceeded
ans=0 N=int(input()) kushi=[] for s in range(N): kushi.append(input()) for s in range(N): kushi1="".join(kushi[s]).rstrip("\n").split(" ") for j in range(N-s): if j==0: continue kushi2="".join(kushi[s+j]).rstrip("\n").split(" ") n=int(kushi1[0])+int(kushi2[0])+int(kushi1[1])+int(kushi2[1]) k=int(kushi1[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 ...
s310335791
p04051
Time Limit Exceeded
ans=0 N=int(input()) kushi=[] for s in range(N): kushi.append(input()) for s in range(N): kushi1="".join(kushi[s]).rstrip("\n").split(" ") for j in range(N-s): if j==0: continue kushi2="".join(kushi[s+j]).rstrip("\n").split(" ") n=int(kushi1[0])+int(kushi2[0])+int(kushi1[1])+int(kushi2[1]) k=int(kushi1[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 ...
s977454608
p04051
Time Limit Exceeded
# Solution to: # http://agc001.contest.atcoder.jp/tasks/agc001_e import numpy as np from scipy import signal N = int(raw_input()) A = [] B = [] MAX_SIZE = 2000 MOD = 10**9+7 # Preompute choose table # CT = [[1], [1, 1]] # for a in xrange(2, MAX_SIZE*4+2): # CT.append([1]) # for b in xrange(1, a): # C...
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 ...
s255547495
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 = int(math.pow(10, 9) + 7) fact = [0] * 8001 rev = [0] * 8001 for i in xrange(0, 8001): if i == 0: fact[0] = 1 rev[0] = 1 cont...
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 ...
s752508606
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 = int(math.pow(10, 9) + 7) fact = [0] * 4001 rev = [0] * 4001 for i in xrange(0, 4001): if i == 0: fact[0] = 1 rev[0] = 1 cont...
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 ...
s394431474
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] = pow(F[MAX],p-2,p) for i in xrange(MAX,0,-1): Finv[i-1] = Finv[i]*i%p N = int(raw_input()) A_MAX = B_MAX = 0 dp = [[0]*(MAX+2) for i in ...
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 ...
s438313939
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] = 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 ...