fix(tests): refactor fixture directory
This commit is contained in:
parent
2fda5a74ca
commit
8ba2a598fe
26 changed files with 9 additions and 23319 deletions
|
|
@ -63,13 +63,13 @@ def run_scraper_offline(fixture_text):
|
|||
target = target.removeprefix("https://cses.fi")
|
||||
|
||||
if target.strip("/") == "problemset":
|
||||
return fixture_text("cses_contests.html")
|
||||
return fixture_text("cses/cses_contests.html")
|
||||
|
||||
if target.startswith("/problemset/task/") or target.startswith(
|
||||
"problemset/task/"
|
||||
):
|
||||
pid = target.rstrip("/").split("/")[-1]
|
||||
return fixture_text(f"cses_task_{pid}.html")
|
||||
return fixture_text(f"cses/cses_task_{pid}.html")
|
||||
|
||||
raise AssertionError(f"No fixture for CSES path={path!r} url={url!r}")
|
||||
|
||||
|
|
@ -77,12 +77,12 @@ def run_scraper_offline(fixture_text):
|
|||
if not url:
|
||||
raise AssertionError("AtCoder expects url routing")
|
||||
if "/contests/archive" in url:
|
||||
return fixture_text("atcoder_contests.html")
|
||||
return fixture_text("atcoder/atcoder_contests.html")
|
||||
if url.endswith("/tasks"):
|
||||
return fixture_text("atcoder_abc100_tasks.html")
|
||||
return fixture_text("atcoder/atcoder_abc100_tasks.html")
|
||||
if "/tasks/" in url:
|
||||
slug = url.rsplit("/", 1)[-1]
|
||||
return fixture_text(f"atcoder_task_{slug}.html")
|
||||
return fixture_text(f"atcoder/atcoder_task_{slug}.html")
|
||||
raise AssertionError(f"No fixture for AtCoder url={url!r}")
|
||||
|
||||
def _router_codeforces(*, path: str | None = None, url: str | None = None) -> str:
|
||||
|
|
@ -90,17 +90,17 @@ def run_scraper_offline(fixture_text):
|
|||
raise AssertionError("Codeforces expects url routing")
|
||||
if "/contest/" in url and url.endswith("/problems"):
|
||||
contest_id = url.rstrip("/").split("/")[-2]
|
||||
return fixture_text(f"codeforces_{contest_id}_problems.html")
|
||||
return fixture_text(f"codeforces/codeforces_{contest_id}_problems.html")
|
||||
if "/contests" in url and "/problem/" not in url:
|
||||
return fixture_text("codeforces_contests.html")
|
||||
return fixture_text("codeforces/codeforces_contests.html")
|
||||
if "/problem/" in url:
|
||||
parts = url.rstrip("/").split("/")
|
||||
contest_id, index = parts[-3], parts[-1]
|
||||
return fixture_text(f"codeforces_{contest_id}_{index}.html")
|
||||
return fixture_text(f"codeforces/codeforces_{contest_id}_{index}.html")
|
||||
if "/problemset/problem/" in url:
|
||||
parts = url.rstrip("/").split("/")
|
||||
contest_id, index = parts[-2], parts[-1]
|
||||
return fixture_text(f"codeforces_{contest_id}_{index}.html")
|
||||
return fixture_text(f"codeforces/codeforces_{contest_id}_{index}.html")
|
||||
|
||||
raise AssertionError(f"No fixture for Codeforces url={url!r}")
|
||||
|
||||
|
|
|
|||
5754
tests/fixtures/codechef_P2209.html
vendored
5754
tests/fixtures/codechef_P2209.html
vendored
File diff suppressed because it is too large
Load diff
5101
tests/fixtures/codechef_P3209.html
vendored
5101
tests/fixtures/codechef_P3209.html
vendored
File diff suppressed because it is too large
Load diff
5940
tests/fixtures/codechef_P4209.html
vendored
5940
tests/fixtures/codechef_P4209.html
vendored
File diff suppressed because it is too large
Load diff
6175
tests/fixtures/codechef_P5209.html
vendored
6175
tests/fixtures/codechef_P5209.html
vendored
File diff suppressed because it is too large
Load diff
85
tests/fixtures/codechef_START209D_P2209.json
vendored
85
tests/fixtures/codechef_START209D_P2209.json
vendored
|
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"category_name": "main",
|
||||
"contest_code": "START209D",
|
||||
"contest_name": "Starters 209 (Rated)",
|
||||
"status": "success",
|
||||
"submit_error": "You need to login to submit.",
|
||||
"is_verified": false,
|
||||
"problem_code": "P2209",
|
||||
"contest_category": "9",
|
||||
"problem_name": "Divisible Duel",
|
||||
"intended_contest_code": "START209",
|
||||
"body": "This is an example problem statement in markdown, and a mini guide on writing statements. Please make sure to remove everything here before publishing your problem.\n\n- Codechef uses markdown for its problem statements. Markdown syntax can be found [here](https:\/\/github.com\/showdownjs\/showdown\/wiki\/Showdown's-Markdown-syntax). Note the `[text](link)` syntax to insert a hyperlink.\n- Codechef also uses $\\LaTeX$ to render mathematical expressions, and you are advised to make liberal use of it to make your statement look good.\n- Text can be made **bold** or *italicized*.\n- **Do not** use HTML tags (p, ul, li, pre, br, ...) in the statement.\n- To insert an image, first upload it to an online hosting service (for an official contest, ask a Codechef admin to do this for you \u2014 this is important) and then use the following syntax: ``.\n- If your problem doesn't contain subtasks, ensure that the Subtasks section below is disabled and **all content is deleted from it**.\n\nIf you face any issues, either contact a Codechef admin directly or send us an email at help@codechef.com.\n\nBelow is an example problem statement that uses some of the above-mentioned features.\n\n---------\n\nChef has a simple undirected graph $G$ with $N$ vertices and $M$ edges. A [subgraph](https:\/\/mathworld.wolfram.com\/Subgraph.html) $H$ of $G$ is called *good* if:\n- $H$ is connected\n- $H$ contains all $N$ vertices of $G$\n- There is a unique path between any two vertices in $H$, using only edges in $H$\n\nCount the number of *good* subgraphs of $G$. Since this number might be large, report it modulo $10^9 + 7$.\n\nIn other news, here's a completely unrelated image:\n\n.\n\n\n<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.<\/div><\/aside>",
|
||||
"problemComponents": {
|
||||
"constraints": "- $1 \\leq T \\leq 10^4$\n- $1 \\leq X,Y \\leq 100$",
|
||||
"constraintsState": true,
|
||||
"subtasks": "- **Subtask 1 (10 points):** $1 \\leq M \\leq 10$\n- **Subtask 2 (20 points):** The sum of $N$ across all test cases won't exceed $20$.\n- **Subtask 3 (70 points):** No further constraints.",
|
||||
"subtasksState": false,
|
||||
"statement": "Alice loves working with numbers. One day, she takes two integers $X$ and $Y$ ($Y \\ge X$) and becomes curious about the numbers between them.\n\nShe looks at all integers between $X$ and $Y$ (inclusive) that are divisible by $X$. \nAmong these numbers, she separates them into even and odd numbers.\n\nLet the sum of all even numbers Alice has be $S_{even}$, and the sum of all odd numbers she has be $S_{odd}$.\n\nIf $S_{even} \\ge S_{odd}$, Alice will be happy; otherwise, she will be sad. \nAlice wants to know whether she will be happy or not.",
|
||||
"inputFormat": "- The first line contains a single integer $T$ \u2014 the number of test cases.\n- Each of the next $T$ lines contains two integers $X$ and $Y$, representing the lower and upper bound of integers Alice looked at.\n",
|
||||
"inputFormatState": true,
|
||||
"outputFormat": "For each test case, print the answer on a new line: `YES` if Alice will be happy, otherwise `NO`.\n\nYou may print each character of the answer in uppercase either or lowercase (for example, the strings `YES`, `yEs`, `yes`, and `yeS` will all be treated as identical).\n",
|
||||
"outputFormatState": true,
|
||||
"sampleTestCases": [
|
||||
{
|
||||
"id": "1",
|
||||
"input": "3\n1 4\n3 9\n4 100\n",
|
||||
"output": "YES\nNO\nYES",
|
||||
"explanation": "**Test case $1$:** Alice has $X = 1$ and $Y = 4$. \nThe multiples of $X$ in this range are $1, 2, 3, 4$. \nSo, $S_{even} = 2+4 = 6$, and $S_{odd} = 1+3 = 4$. \nSince $S_{even} \\ge S_{odd}$, Alice is happy.\n\n**Test case $2$:** Alice has $X = 3$ and $Y = 9$. \nThe multiples of $X$ in this range are $3, 6, 9$.\nSo, $S_{even} = 6$, and $S_{odd} = 3+9 = 12$. \nSince $S_{even} \\lt S_{odd}$, Alice is not happy.",
|
||||
"isDeleted": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"gumlet_video_url": "",
|
||||
"video_editorial_url": "https:\/\/youtu.be\/DReIsGthZtY?si=4_3w50idMKuVf07I",
|
||||
"text_editorial_body": "<h1><a name=\"problem-link-1\" class=\"anchor\" href=\"#problem-link-1\"><\/a>PROBLEM LINK:<\/h1>\n<p><a href=\"https:\/\/www.codechef.com\/problems\/P2209\">Practice<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209A\/problems\/P2209\">Contest: Division 1<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209B\/problems\/P2209\">Contest: Division 2<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209C\/problems\/P2209\">Contest: Division 3<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209D\/problems\/P2209\">Contest: Division 4<\/a><\/p>\n<p><em><strong>Author:<\/strong><\/em> <a href=\"https:\/\/www.codechef.com\/users\/pols_agyi_pols\">pols_agyi_pols<\/a><br>\n<em><strong>Tester:<\/strong><\/em> <a href=\"https:\/\/www.codechef.com\/users\/kingmessi\">kingmessi<\/a><br>\n<em><strong>Editorialist:<\/strong><\/em> <a href=\"https:\/\/www.codechef.com\/users\/iceknight1093\">iceknight1093<\/a><\/p>\n<h1><a name=\"difficulty-2\" class=\"anchor\" href=\"#difficulty-2\"><\/a>DIFFICULTY:<\/h1>\n<p>Cakewalk<\/p>\n<h1><a name=\"prerequisites-3\" class=\"anchor\" href=\"#prerequisites-3\"><\/a>PREREQUISITES:<\/h1>\n<p>None<\/p>\n<h1><a name=\"problem-4\" class=\"anchor\" href=\"#problem-4\"><\/a>PROBLEM:<\/h1>\n<p>You\u2019re given <span class=\"math\">X<\/span> and <span class=\"math\">Y<\/span>.<br>\nLet <span class=\"math\">S_{even}<\/span> be the sum of all even multiples of <span class=\"math\">X<\/span> in the range <span class=\"math\">[X, Y]<\/span>, and <span class=\"math\">S_{odd}<\/span> be the sum of all odd multiples of <span class=\"math\">X<\/span> in this range.<br>\nChef will be happy only if <span class=\"math\">S_{even} \\ge S_{odd}<\/span>.<\/p>\n<p>Decide if Chef will be happy, given <span class=\"math\">X<\/span> and <span class=\"math\">Y<\/span>.<\/p>\n<h1><a name=\"explanation-5\" class=\"anchor\" href=\"#explanation-5\"><\/a>EXPLANATION:<\/h1>\n<p>Since <span class=\"math\">X<\/span> and <span class=\"math\">Y<\/span> are small (both being <span class=\"math\">\\le 100<\/span>), this problem can be solved by just brute-forcing it.<br>\nThat is, iterate over every integer <span class=\"math\">Z<\/span> in the range <span class=\"math\">[X, Y]<\/span>; and:<\/p>\n<ul>\n<li>If <span class=\"math\">Z<\/span> is not a multiple of <span class=\"math\">X<\/span>, ignore it.<\/li>\n<li>If <span class=\"math\">Z<\/span> is an even multiple of <span class=\"math\">X<\/span>, add <span class=\"math\">Z<\/span> to <span class=\"math\">S_{even}<\/span>.<\/li>\n<li>If <span class=\"math\">Z<\/span> is an odd multiple of <span class=\"math\">X<\/span>, add <span class=\"math\">Z<\/span> to <span class=\"math\">S_{odd}<\/span>.<\/li>\n<\/ul>\n<p>Finally, check if <span class=\"math\">S_{even} \\ge S_{odd}<\/span> or not.<\/p>\n<hr>\n<p>It\u2019s also possible to solve the problem mathematically.<\/p>\n<p>The multiples of in the range <span class=\"math\">[X, Y]<\/span> will be<br>\n<span class=\"math\">X, 2X, 3X, \\ldots, kX<\/span> for some integer <span class=\"math\">k \\ge 1<\/span>.<\/p>\n<p>If <span class=\"math\">X<\/span> is even, then all multiples of <span class=\"math\">X<\/span> will also be even; so <span class=\"math\">S_{odd}<\/span> will always equal <span class=\"math\">0<\/span>.<br>\nThus, <span class=\"math\">S_{even} \\ge S_{odd}<\/span> will always be true.<\/p>\n<p>If <span class=\"math\">X<\/span> is odd, then the multiples of <span class=\"math\">X<\/span> will alternate between odd and even.<br>\nIt can then be seen that:<\/p>\n<ul>\n<li>If <span class=\"math\">k<\/span> is odd, then <span class=\"math\">S_{odd} \\gt S_{even}<\/span>.<br>\n(Recall that <span class=\"math\">k<\/span> is the largest integer such that <span class=\"math\">k \\le Y<\/span>).<\/li>\n<li>If <span class=\"math\">k<\/span> is even, then <span class=\"math\">S_{odd} \\lt S_{even}<\/span>.<\/li>\n<\/ul>\n<p><span class=\"math\">k<\/span> can be computed mathematically by taking <span class=\"math\">\\frac{Y}{X}<\/span> and rounding it down to the nearest integer, so the problem is solved in constant time.<\/p>\n<h1><a name=\"time-complexity-6\" class=\"anchor\" href=\"#time-complexity-6\"><\/a>TIME COMPLEXITY:<\/h1>\n<p><span class=\"math\">\\mathcal{O}(Y)<\/span> or <span class=\"math\">\\mathcal{O}(1)<\/span> per testcase.<\/p>\n<h1><a name=\"code-7\" class=\"anchor\" href=\"#code-7\"><\/a>CODE:<\/h1>\n<details>\n<summary>\nEditorialist's code (PyPy3)<\/summary>\n<pre><code class=\"lang-python\">for _ in range(int(input())):\n x, y = map(int, input().split())\n k = y\/\/x\n \n if x%2 == 0 or k%2 == 0: print('Yes')\n else: print('No')\n<\/code><\/pre>\n<\/details>",
|
||||
"text_editorial_is_markdown": 0,
|
||||
"text_editorial_topic_id": 124411,
|
||||
"languages_supported": "CPP20, PYTH 3, C, JAVA, PYP3, CS2, NODEJS, GO, TS, PHP, kotlin, rust, R",
|
||||
"max_timelimit": "1",
|
||||
"source_sizelimit": "50000",
|
||||
"problem_author": "archit_adm",
|
||||
"problem_display_authors": ["archit_adm"],
|
||||
"problem_display_authors_html_handle": "<div class=\"multiple-usernames-container\"><a href='\/users\/archit_adm'>archit_adm<\/a><\/div>",
|
||||
"problem_tester": null,
|
||||
"problem_testers_usernames": ["kingmessi"],
|
||||
"problem_tester_html_handle": "<div class=\"multiple-usernames-container\"><a href='\/users\/kingmessi'><span \n class='rating' \n style='display: inline-block; \n font-size: 10px; \n background: #D0011B;\n padding: 0 3px; \n line-height: 1.3; \n color: white;\n margin-right: 2px;'>7★<\/span><span class='m-username--link'>kingmessi<\/span><\/a><\/div>",
|
||||
"problem_editorialist": "iceknight1093",
|
||||
"date_added": "21-10-2025",
|
||||
"ready_for_debug": false,
|
||||
"problem_stats": {
|
||||
"accuracy": 64.370000000000005,
|
||||
"successful_submissions": "22082",
|
||||
"total_submissions": "37661"
|
||||
},
|
||||
"user_tags": ["archit_adm", "cakewalk", "start209"],
|
||||
"computed_tags": [],
|
||||
"difficulty_rating": "628",
|
||||
"best_tag": "",
|
||||
"editorial_url": "",
|
||||
"time": {
|
||||
"view_start_date": 1761143406,
|
||||
"submit_start_date": 1761143406,
|
||||
"visible_start_date": 1761150606,
|
||||
"end_date": 1761150606,
|
||||
"current": 1761365589,
|
||||
"practice_submission_allowed": false
|
||||
},
|
||||
"user": { "username": null, "access": "default", "isPremiumUser": false },
|
||||
"bookmark_status": false,
|
||||
"contest_problem_status": "unattempted",
|
||||
"problem_status": "unattempted",
|
||||
"is_direct_submittable": false,
|
||||
"problemDiscussURL": "https:\/\/discuss.codechef.com\/search?q=P2209",
|
||||
"is_a_practice_or_college_contest": false,
|
||||
"votes_data": {
|
||||
"SolutionVoteData": { "upvote_count": 0, "user_vote": 0 },
|
||||
"HintsVoteData": { "upvote_count": 0, "user_vote": 0 },
|
||||
"ProblemStatementVoteData": { "upvote_count": 33, "user_vote": 0 },
|
||||
"DoubtSupportVoteData": { "upvote_count": 0, "user_vote": 0 }
|
||||
},
|
||||
"is_proctored": false,
|
||||
"is_user_verified_for_proctoring": false,
|
||||
"visitedContests": [],
|
||||
"isSupportedByJudge": true
|
||||
}
|
||||
85
tests/fixtures/codechef_START209D_P3209.json
vendored
85
tests/fixtures/codechef_START209D_P3209.json
vendored
|
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"category_name": "main",
|
||||
"contest_code": "START209D",
|
||||
"contest_name": "Starters 209 (Rated)",
|
||||
"status": "success",
|
||||
"submit_error": "You need to login to submit.",
|
||||
"is_verified": false,
|
||||
"problem_code": "P3209",
|
||||
"contest_category": "9",
|
||||
"problem_name": "Small GCD Sort",
|
||||
"intended_contest_code": "START209",
|
||||
"body": "This is an example problem statement in markdown, and a mini guide on writing statements. Please make sure to remove everything here before publishing your problem.\n\n- Codechef uses markdown for its problem statements. Markdown syntax can be found [here](https:\/\/github.com\/showdownjs\/showdown\/wiki\/Showdown's-Markdown-syntax). Note the `[text](link)` syntax to insert a hyperlink.\n- Codechef also uses $\\LaTeX$ to render mathematical expressions, and you are advised to make liberal use of it to make your statement look good.\n- Text can be made **bold** or *italicized*.\n- **Do not** use HTML tags (p, ul, li, pre, br, ...) in the statement.\n- To insert an image, first upload it to an online hosting service (for an official contest, ask a Codechef admin to do this for you \u2014 this is important) and then use the following syntax: ``.\n- If your problem doesn't contain subtasks, ensure that the Subtasks section below is disabled and **all content is deleted from it**.\n\nIf you face any issues, either contact a Codechef admin directly or send us an email at help@codechef.com.\n\nBelow is an example problem statement that uses some of the above-mentioned features.\n\n---------\n\nChef has a simple undirected graph $G$ with $N$ vertices and $M$ edges. A [subgraph](https:\/\/mathworld.wolfram.com\/Subgraph.html) $H$ of $G$ is called *good* if:\n- $H$ is connected\n- $H$ contains all $N$ vertices of $G$\n- There is a unique path between any two vertices in $H$, using only edges in $H$\n\nCount the number of *good* subgraphs of $G$. Since this number might be large, report it modulo $10^9 + 7$.\n\nIn other news, here's a completely unrelated image:\n\n.\n\n\n<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.<\/div><\/aside>",
|
||||
"problemComponents": {
|
||||
"constraints": "- $1 \\leq T \\leq 100$\n- $1 \\leq N \\leq 100$",
|
||||
"constraintsState": true,
|
||||
"subtasks": "- **Subtask 1 (10 points):** $1 \\leq M \\leq 10$\n- **Subtask 2 (20 points):** The sum of $N$ across all test cases won't exceed $20$.\n- **Subtask 3 (70 points):** No further constraints.",
|
||||
"subtasksState": false,
|
||||
"statement": "There are $N$ players, numbered from $1$ to $N$.\n\nPlayer $i$'s score is defined to be $\\gcd(i, N)$. \nHere, $\\gcd(i, N)$ refers to the largest positive integer that divides both $i$ and $N$.\n\nYour task is to find an ordering of the players, from left to right, that satisfies the following conditions:\n- Between two players with different scores, the one with a higher score must appear somewhere to the left of the one with a lower score.\n- Between two players with the same score, the player with a smaller number must appear somewhere to the left of the one with a lower score.\n\nIt can be proved that these rules uniquely define an ordering of the $N$ people. \nYour task is to find this ordering.",
|
||||
"inputFormat": "- The first line contains a single integer $T$ \u2014 the number of test cases.\n- Each of the next $T$ lines contains a single integer $N$ \u2014 the number of players.",
|
||||
"inputFormatState": true,
|
||||
"outputFormat": "For each test case, print $N$ space-separated integers on a new line \u2014 the player numbers in the required preference order.\n",
|
||||
"outputFormatState": true,
|
||||
"sampleTestCases": [
|
||||
{
|
||||
"id": "1",
|
||||
"input": "5\n1\n2\n3\n4\n5",
|
||||
"output": "1\n2 1\n3 1 2\n4 2 1 3\n5 1 2 3 4",
|
||||
"explanation": "**Test case $1$:** There is only one player.\n\n**Test case $2$:** There are two players. \nPlayer $1$ has a score of $\\gcd(1, 2) = 1$, while player $2$ has a score of $\\gcd(2, 2) = 2$. \nPlayer $2$ has a higher score, and so appears to the left of player $1$, making the only possible order $[2, 1]$.\n\n**Test case $4$:** There are four players. It can be verified that players $1$ and $3$ have a score of $1$, player $2$ has a score of $2$, and player $4$ has a score of $4$. \nSo,\n- Player $4$ has the highest score, and so must be placed first.\n- Player $2$ has the second highest score, and so must be placed second.\n- Players $1$ and $3$ have the same score. \nAmong them, $1$ has the smaller number, and so must be placed ahead of $3$.\n\nThus, the final order is $[4, 2, 1, 3]$.",
|
||||
"isDeleted": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"gumlet_video_url": "",
|
||||
"video_editorial_url": "https:\/\/youtu.be\/QAK_KGXyvt0?si=ArRmUattqydRwtZH",
|
||||
"text_editorial_body": "<h1><a name=\"problem-link-1\" class=\"anchor\" href=\"#problem-link-1\"><\/a>PROBLEM LINK:<\/h1>\n<p><a href=\"https:\/\/www.codechef.com\/problems\/P3209\">Practice<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209A\/problems\/P3209\">Contest: Division 1<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209B\/problems\/P3209\">Contest: Division 2<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209C\/problems\/P3209\">Contest: Division 3<\/a><br>\n<a href=\"https:\/\/www.codechef.com\/START209D\/problems\/P3209\">Contest: Division 4<\/a><\/p>\n<p><em><strong>Author:<\/strong><\/em> <a href=\"https:\/\/www.codechef.com\/users\/pols_agyi_pols\">pols_agyi_pols<\/a><br>\n<em><strong>Tester:<\/strong><\/em> <a href=\"https:\/\/www.codechef.com\/users\/kingmessi\">kingmessi<\/a><br>\n<em><strong>Editorialist:<\/strong><\/em> <a href=\"https:\/\/www.codechef.com\/users\/iceknight1093\">iceknight1093<\/a><\/p>\n<h1><a name=\"difficulty-2\" class=\"anchor\" href=\"#difficulty-2\"><\/a>DIFFICULTY:<\/h1>\n<p>Cakewalk<\/p>\n<h1><a name=\"prerequisites-3\" class=\"anchor\" href=\"#prerequisites-3\"><\/a>PREREQUISITES:<\/h1>\n<p>None<\/p>\n<h1><a name=\"problem-4\" class=\"anchor\" href=\"#problem-4\"><\/a>PROBLEM:<\/h1>\n<p>There are <span class=\"math\">N<\/span> players, numbered <span class=\"math\">1<\/span> to <span class=\"math\">N<\/span>.<br>\nThe score of player <span class=\"math\">i<\/span> is <span class=\"math\">\\gcd(i, N)<\/span>.<\/p>\n<p>Find an ordering of the players such that:<\/p>\n<ul>\n<li>A player with higher score always appears before one with lower score.<\/li>\n<li>Between players with the same score, the one with a smaller label comes first.<\/li>\n<\/ul>\n<h1><a name=\"explanation-5\" class=\"anchor\" href=\"#explanation-5\"><\/a>EXPLANATION:<\/h1>\n<p>This is pretty much just a straightforward implementation task.<br>\nHere\u2019s one way of doing it.<\/p>\n<p>First, note that <span class=\"math\">\\gcd(i, N)<\/span> will always be an integer between <span class=\"math\">1<\/span> and <span class=\"math\">N<\/span>.<br>\nSo, let\u2019s create <span class=\"math\">N<\/span> lists <span class=\"math\">L_1, L_2, \\ldots, L_N<\/span>.<br>\nThe list <span class=\"math\">L_g<\/span> will hold a list of all the people <span class=\"math\">i<\/span> such that <span class=\"math\">\\gcd(i, N) = g<\/span>, sorted in ascending order.<\/p>\n<p>The lists can be populated as follows:<\/p>\n<ul>\n<li>Start with all the lists being empty.<\/li>\n<li>Then, for each <span class=\"math\">i = 1, 2, \\ldots, N<\/span> in order:\n<ul>\n<li>Compute <span class=\"math\">g = \\gcd(i, N)<\/span>.<br>\nThis can be done either using a loop, or with your language\u2019s inbuilt <code>gcd<\/code> function.<\/li>\n<li>Then, append <span class=\"math\">i<\/span> to the back of <span class=\"math\">L_g<\/span>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Once this is done, we are ready to compute the necessary order.<br>\nLet <span class=\"math\">A<\/span> be an empty array (that will eventually hold the answer).<br>\nWe do the following:<\/p>\n<ul>\n<li>Iterate over <span class=\"math\">g<\/span> from <span class=\"math\">N<\/span> down to <span class=\"math\">1<\/span>.<\/li>\n<li>When processing <span class=\"math\">g<\/span>, simply append all the elements of <span class=\"math\">L_g<\/span> to <span class=\"math\">A<\/span> in order.<\/li>\n<\/ul>\n<p>In the end, the array <span class=\"math\">A<\/span> will hold the order we want, so print it.<\/p>\n<h1><a name=\"time-complexity-6\" class=\"anchor\" href=\"#time-complexity-6\"><\/a>TIME COMPLEXITY:<\/h1>\n<p><span class=\"math\">\\mathcal{O}(N\\log N)<\/span> per testcase.<\/p>\n<h1><a name=\"code-7\" class=\"anchor\" href=\"#code-7\"><\/a>CODE:<\/h1>\n<details>\n<summary>\nEditorialist's code (PyPy3)<\/summary>\n<pre><code class=\"lang-python\">for _ in range(int(input())):\n n = int(input())\n ids = [ [] for i in range(n+1) ]\n \n import math\n for i in range(1, n+1):\n ids[math.gcd(i, n)].append(i)\n ans = []\n for i in reversed(range(1, n+1)):\n ans.extend(ids[i])\n print(*ans)\n<\/code><\/pre>\n<\/details>",
|
||||
"text_editorial_is_markdown": 0,
|
||||
"text_editorial_topic_id": 124412,
|
||||
"languages_supported": "CPP20, PYTH 3, C, JAVA, PYP3, CS2, NODEJS, GO, TS, PHP, kotlin, rust, R",
|
||||
"max_timelimit": "1",
|
||||
"source_sizelimit": "50000",
|
||||
"problem_author": "archit_adm",
|
||||
"problem_display_authors": ["archit_adm"],
|
||||
"problem_display_authors_html_handle": "<div class=\"multiple-usernames-container\"><a href='\/users\/archit_adm'>archit_adm<\/a><\/div>",
|
||||
"problem_tester": null,
|
||||
"problem_testers_usernames": ["kingmessi"],
|
||||
"problem_tester_html_handle": "<div class=\"multiple-usernames-container\"><a href='\/users\/kingmessi'><span \n class='rating' \n style='display: inline-block; \n font-size: 10px; \n background: #D0011B;\n padding: 0 3px; \n line-height: 1.3; \n color: white;\n margin-right: 2px;'>7★<\/span><span class='m-username--link'>kingmessi<\/span><\/a><\/div>",
|
||||
"problem_editorialist": "iceknight1093",
|
||||
"date_added": "21-10-2025",
|
||||
"ready_for_debug": false,
|
||||
"problem_stats": {
|
||||
"accuracy": 76.489999999999995,
|
||||
"successful_submissions": "13635",
|
||||
"total_submissions": "19367"
|
||||
},
|
||||
"user_tags": ["archit_adm", "cakewalk", "start209"],
|
||||
"computed_tags": [],
|
||||
"difficulty_rating": "1039",
|
||||
"best_tag": "",
|
||||
"editorial_url": "",
|
||||
"time": {
|
||||
"view_start_date": 1761143406,
|
||||
"submit_start_date": 1761143406,
|
||||
"visible_start_date": 1761150606,
|
||||
"end_date": 1761150606,
|
||||
"current": 1761365589,
|
||||
"practice_submission_allowed": false
|
||||
},
|
||||
"user": { "username": null, "access": "default", "isPremiumUser": false },
|
||||
"bookmark_status": false,
|
||||
"contest_problem_status": "unattempted",
|
||||
"problem_status": "unattempted",
|
||||
"is_direct_submittable": false,
|
||||
"problemDiscussURL": "https:\/\/discuss.codechef.com\/search?q=P3209",
|
||||
"is_a_practice_or_college_contest": false,
|
||||
"votes_data": {
|
||||
"SolutionVoteData": { "upvote_count": 0, "user_vote": 0 },
|
||||
"HintsVoteData": { "upvote_count": 0, "user_vote": 0 },
|
||||
"ProblemStatementVoteData": { "upvote_count": 27, "user_vote": 0 },
|
||||
"DoubtSupportVoteData": { "upvote_count": 0, "user_vote": 0 }
|
||||
},
|
||||
"is_proctored": false,
|
||||
"is_user_verified_for_proctoring": false,
|
||||
"visitedContests": [],
|
||||
"isSupportedByJudge": true
|
||||
}
|
||||
85
tests/fixtures/codechef_START209D_P4209.json
vendored
85
tests/fixtures/codechef_START209D_P4209.json
vendored
File diff suppressed because one or more lines are too long
85
tests/fixtures/codechef_START209D_P5209.json
vendored
85
tests/fixtures/codechef_START209D_P5209.json
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue