problem_id stringlengths 12 45 | cp_id stringlengths 2 4 | name stringlengths 3 34 | description stringlengths 940 4.03k | problem_level stringclasses 4
values | problem_link stringlengths 56 58 | contest_link stringclasses 45
values | description_no_samples stringlengths 713 3.03k | samples listlengths 1 3 | num_samples int64 1 3 | solution_python3 stringlengths 106 4.14k | solution_english stringlengths 154 7.91k | tests listlengths 9 23 | num_tests int64 9 23 | runtime_limit_sec int64 2 15 | memory_limit_mb int64 256 512 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1333_platinum_good_bitstrings | 1333 | Good Bitstrings |
For any two positive integers $a$ and $b$, define the function
$\texttt{gen_string}(a,b)$ by the following Python code:
def gen_string(a: int, b: int):
res = ""
ia, ib = 0, 0
while ia + ib < a + b:
if ia * b <= ib * a:
res += '0'
ia += 1
else:
res += '1'
ib += 1
return res
Equivalent C++ code:
... | platinum | http://www.usaco.org/index.php?page=viewproblem2&cpid=1333 | http://www.usaco.org/index.php?page=open23results |
For any two positive integers $a$ and $b$, define the function
$\texttt{gen_string}(a,b)$ by the following Python code:
def gen_string(a: int, b: int):
res = ""
ia, ib = 0, 0
while ia + ib < a + b:
if ia * b <= ib * a:
res += '0'
ia += 1
else:
res += '1'
ib += 1
return res
Equivalent C++ code:
... | [
{
"input": "6\n1 1\n3 5\n4 7\n8 20\n4 10\n27 21",
"output": "1\n5\n7\n10\n6\n13",
"explanation": "",
"input_explanation": "",
"output_explanation": ""
}
] | 1 |
def solve(a, b):
crs_below, crs_above = b, a # cross(f_1, f'), cross(f', f_2)
ans = 0
on_y_axis = True
while True:
if crs_below > crs_above: # f_1 = f_1 + f_2
mul = (crs_below - 1) // crs_above
ans += mul * (1 + (not on_y_axis))
crs_below -= mul * crs_above... | (Analysis by Benjamin Qi, Reviewed by Richard Qi)
Note: The model solutions for all subtasks are very short, though
understanding why they work is not easy.
Suppose we are trying to compute the answer for $A=a$ and $B=b$.
Subtask 2: $O((a+b)^2)$
Let $s=\texttt{gen_string}(a,b)$. For each prefix of $s$, count the numbe... | [
{
"input": "6\n1 1\n3 5\n4 7\n8 20\n4 10\n27 21\n",
"output": "1\n5\n7\n10\n6\n13\n"
},
{
"input": "10\n85 13\n71 66\n28 66\n29 71\n96 63\n38 31\n17 68\n36 58\n36 4\n63 33\n",
"output": "20\n32\n12\n15\n27\n16\n36\n12\n15\n17\n"
},
{
"input": "10\n906 527\n608 244\n263 174\n839 281\n153 ... | 21 | 2 | 256 |
1330_gold_pareidolia | 1330 | Pareidolia | "\nPareidolia is the phenomenon where your eyes tend to see familiar patterns in\nimages where none (...TRUNCATED) | gold | http://www.usaco.org/index.php?page=viewproblem2&cpid=1330 | http://www.usaco.org/index.php?page=open23results | "\nPareidolia is the phenomenon where your eyes tend to see familiar patterns in\nimages where none (...TRUNCATED) | [{"input":"besssie\n1 1 5 4 6 1 1","output":"1\n4","explanation":"By deleting the 's' at position 4 (...TRUNCATED) | 3 | "s = input()\ncosts = list(map(int, input().split()))\n\ntarget = \"bessie\"\ndp = [(float(\"-inf\")(...TRUNCATED) | "(Analysis by Danny Mittal)\nLet $s$ be the given string, and $c$ be the given list of deletion cost(...TRUNCATED) | [{"input":"besssie\n1 1 5 4 6 1 1\n","output":"1\n4\n"},{"input":"bebesconsiete\n6 5 2 3 6 5 7 9 8 1(...TRUNCATED) | 17 | 2 | 256 |
1326_silver_milk_sum | 1326 | Milk Sum | "\n**Note: The time limit for this problem is 4s, 2x the default.**\nFarmer John's $N$ cows ($1\\le (...TRUNCATED) | silver | http://www.usaco.org/index.php?page=viewproblem2&cpid=1326 | http://www.usaco.org/index.php?page=open23results | "\n**Note: The time limit for this problem is 4s, 2x the default.**\nFarmer John's $N$ cows ($1\\le (...TRUNCATED) | [{"input":"5\n1 10 4 2 6\n3\n2 1\n2 8\n4 5","output":"55\n81\n98","explanation":"For the first query(...TRUNCATED) | 1 | "\nimport bisect\n\nN = int(input())\narr = list(map(int, input().split()))\nord = sorted(range(N), (...TRUNCATED) | "(Analysis by David Hu)\nNote that it is optimal for Farmer John to milk his cows such that the cow (...TRUNCATED) | [{"input":"5\n1 10 4 2 6\n3\n2 1\n2 8\n4 5\n","output":"55\n81\n98\n"},{"input":"1000\n620 364 41 88(...TRUNCATED) | 11 | 4 | 256 |
1327_silver_field_day | 1327 | Field Day | "\n**Note: The time limit for this problem in Python is 15s. Other languages have the default time (...TRUNCATED) | silver | http://www.usaco.org/index.php?page=viewproblem2&cpid=1327 | http://www.usaco.org/index.php?page=open23results | "\n**Note: The time limit for this problem in Python is 15s. Other languages have the default time (...TRUNCATED) | [{"input":"5 3\nGHGGH\nGHHHH\nHGHHG","output":"5\n3\n5","explanation":"The first and third teams dif(...TRUNCATED) | 1 | "\nC, N = map(int, input().split())\nto_bin = lambda s: sum(1 << i for i in range(C) if s[i] == \"H\(...TRUNCATED) | "(Analysis by Benjamin Qi)\nA naive solution runs in $O(N^2C)$ time and is too slow to pass any inpu(...TRUNCATED) | [{"input":"5 3\nGHGGH\nGHHHH\nHGHHG\n","output":"5\n3\n5\n"},{"input":"10 100000\nGHGHHHGGHH\nHGHHHH(...TRUNCATED) | 20 | 15 | 256 |
1328_silver_pareidolia | 1328 | Pareidolia | "\n**Note: The time limit for this problem is 4s, 2x the default.**\nPareidolia is the phenomenon wh(...TRUNCATED) | silver | http://www.usaco.org/index.php?page=viewproblem2&cpid=1328 | http://www.usaco.org/index.php?page=open23results | "\n**Note: The time limit for this problem is 4s, 2x the default.**\nPareidolia is the phenomenon wh(...TRUNCATED) | [{"input":"bessiebessie","output":"14","explanation":"Twelve substrings contain exactly 1 \"bessie\"(...TRUNCATED) | 2 | "\nt = input()\nanswer = 0\nwaiting = [0] * 7\nrem = len(t)\nfor letter in t:\n waiting[0] += 1\n(...TRUNCATED) | "(Analysis by Danny Mittal, Benjamin Qi)\nLet's first consider the easier problem of computing $B(s)(...TRUNCATED) | [{"input":"bessiebessie\n","output":"14\n"},{"input":"abcdefghssijebessie\n","output":"28\n"},{"inpu(...TRUNCATED) | 12 | 4 | 256 |
1325_bronze_rotate_and_shift | 1325 | Rotate and Shift | "\n**Note: The time limit for this problem is 4s, 2x the default.**\nTo celebrate the start of sprin(...TRUNCATED) | bronze | http://www.usaco.org/index.php?page=viewproblem2&cpid=1325 | http://www.usaco.org/index.php?page=open23results | "\n**Note: The time limit for this problem is 4s, 2x the default.**\nTo celebrate the start of sprin(...TRUNCATED) | [{"input":"5 3 4\n0 2 3","output":"1 2 3 4 0","explanation":"For the example above, here are the cow(...TRUNCATED) | 1 | "\nN, K, T = map(int, input().split())\nA = list(map(int, input().split())) + [N]\n\nans = [-1] * N\(...TRUNCATED) | "(Analysis by Richard Qi)\nFor $N \\le 1000, T \\le 10000$, we can directly simulate the process des(...TRUNCATED) | [{"input":"5 3 4\n0 2 3\n","output":"1 2 3 4 0\n"},{"input":"1000 294 10000\n0 2 6 8 15 17 19 21 24 (...TRUNCATED) | 13 | 4 | 256 |
1302_silver_bakery | 1302 | Bakery | "\nBessie has opened a bakery!\n\nIn her bakery, Bessie has an oven that can produce a cookie in $t_(...TRUNCATED) | silver | http://www.usaco.org/index.php?page=viewproblem2&cpid=1302 | http://www.usaco.org/index.php?page=feb23results | "\nBessie has opened a bakery!\n\nIn her bakery, Bessie has an oven that can produce a cookie in $t_(...TRUNCATED) | [{"input":"2\n\n3 7 9\n4 3 18\n2 4 19\n1 1 6\n\n5 7 3\n5 9 45\n5 2 31\n6 4 28\n4 1 8\n5 2 22","outpu(...TRUNCATED) | 1 | "\nTC = int(input())\n\nfor tc in range(TC):\n _ = input()\n\n N, X, Y = map(int, input().spli(...TRUNCATED) | "(Analysis by David Hu)\nSuppose Bessie's oven ends up taking $x$ units of time to produce a cookie (...TRUNCATED) | [{"input":"2\n\n3 7 9\n4 3 18\n2 4 19\n1 1 6\n\n5 7 3\n5 9 45\n5 2 31\n6 4 28\n4 1 8\n5 2 22\n","out(...TRUNCATED) | 11 | 2 | 256 |
1303_silver_cow-libi | 1303 | Cow-libi | "\n**Note: The time limit for this problem is 4s, two times the default.**\n\nSomebody has been graz(...TRUNCATED) | silver | http://www.usaco.org/index.php?page=viewproblem2&cpid=1303 | http://www.usaco.org/index.php?page=feb23results | "\n**Note: The time limit for this problem is 4s, two times the default.**\n\nSomebody has been graz(...TRUNCATED) | [{"input":"2 4\n0 0 100\n50 0 200\n0 50 50\n1000 1000 0\n50 0 200\n10 0 170","output":"2","explanati(...TRUNCATED) | 1 | "\nimport bisect\n\nG, N = map(int, input().split())\n \ndef read():\n x, y, t = map(int, input()(...TRUNCATED) | "(Analysis by Andi Qu)\nFirst, let's think about how to determine if a cow can go from $(x_1, y_1)$ (...TRUNCATED) | [{"input":"2 4\n0 0 100\n50 0 200\n0 50 50\n1000 1000 0\n50 0 200\n10 0 170\n","output":"2\n"},{"inp(...TRUNCATED) | 11 | 4 | 256 |
1299_bronze_hungry_cow | 1299 | Hungry Cow | "\nBessie is a hungry cow. Each day, for dinner, if there is a haybale in the barn,\nshe will eat on(...TRUNCATED) | bronze | http://www.usaco.org/index.php?page=viewproblem2&cpid=1299 | http://www.usaco.org/index.php?page=feb23results | "\nBessie is a hungry cow. Each day, for dinner, if there is a haybale in the barn,\nshe will eat on(...TRUNCATED) | [{"input":"1 5\n1 2","output":"2","explanation":"","input_explanation":"","output_explanation":""},{(...TRUNCATED) | 3 | "N, T = map(int, input().split())\ndeliveries = [tuple(map(int, input().split())) for _ in range(N)](...TRUNCATED) | "(Analysis by Mihir Singhal)\nWe process the deliveries in time order (as given), keeping track of t(...TRUNCATED) | [{"input":"1 5\n1 2\n","output":"2\n"},{"input":"2 5\n1 2\n5 10\n","output":"3\n"},{"input":"2 5\n1 (...TRUNCATED) | 13 | 2 | 256 |
1300_bronze_stamp_grid | 1300 | Stamp Grid | "\nA stamp painting is a black and white painting on an $N \\times N$ canvas,\nwhere certain cells a(...TRUNCATED) | bronze | http://www.usaco.org/index.php?page=viewproblem2&cpid=1300 | http://www.usaco.org/index.php?page=feb23results | "\nA stamp painting is a black and white painting on an $N \\times N$ canvas,\nwhere certain cells a(...TRUNCATED) | [{"input":"4\n\n2\n**\n*.\n1\n*\n\n3\n.**\n.**\n***\n2\n.*\n**\n\n3\n...\n.*.\n...\n3\n.*.\n...\n...(...TRUNCATED) | 1 | "\nT = int(input())\nfor _ in range(T):\n input()\n N = int(input())\n grid = [list(input()(...TRUNCATED) | "\n(Analysis by Claire Zhang) \nConsider stamping wherever possible - that is, for each position and(...TRUNCATED) | [{"input":"4\n\n2\n**\n*.\n1\n*\n\n3\n.**\n.**\n***\n2\n.*\n**\n\n3\n...\n.*.\n...\n3\n.*.\n...\n...(...TRUNCATED) | 14 | 2 | 256 |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 21