From 2183e351d96e7155ac4d783bfee7c9daa463d56c Mon Sep 17 00:00:00 2001 From: cgiosy Date: Mon, 13 Apr 2026 18:52:13 +0900 Subject: [PATCH 1/3] feat: i18n codebattle --- src/components/Code.tsx | 3 + src/components/PostLayout.tsx | 24 +- src/components/ProblemList.tsx | 7 +- src/components/styles.css | 5 + src/routes/en/$year.$page.tsx | 28 ++ src/routes/en/$year.notice.$page.tsx | 28 ++ src/routes/en/2025-codebattle/finals_1.mdx | 346 ++++++++++++++++++ src/routes/en/2025-codebattle/index.tsx | 57 +++ src/routes/en/2025-codebattle/notice/rule.mdx | 289 +++++++++++++++ src/routes/en/2025-codebattle/notice/tool.mdx | 321 ++++++++++++++++ src/routes/en/2025-codebattle/online_1.mdx | 203 ++++++++++ src/routes/en/2025-codebattle/online_p.mdx | 207 +++++++++++ src/routes/en/index.tsx | 87 +++++ 13 files changed, 1598 insertions(+), 7 deletions(-) create mode 100644 src/components/styles.css create mode 100644 src/routes/en/$year.$page.tsx create mode 100644 src/routes/en/$year.notice.$page.tsx create mode 100644 src/routes/en/2025-codebattle/finals_1.mdx create mode 100644 src/routes/en/2025-codebattle/index.tsx create mode 100644 src/routes/en/2025-codebattle/notice/rule.mdx create mode 100644 src/routes/en/2025-codebattle/notice/tool.mdx create mode 100644 src/routes/en/2025-codebattle/online_1.mdx create mode 100644 src/routes/en/2025-codebattle/online_p.mdx create mode 100644 src/routes/en/index.tsx diff --git a/src/components/Code.tsx b/src/components/Code.tsx index be5531f7..e767493f 100644 --- a/src/components/Code.tsx +++ b/src/components/Code.tsx @@ -2,6 +2,9 @@ import styled from "@emotion/styled"; export const Code = styled.code` font-family: "IBM Plex Mono", "Pretendard", monospace; + display: inline-block; + max-width: 100%; + overflow-x: auto; tab-size: 4; &:not([class*="language-"]) { background-color: ${({ theme }) => theme.color.background.card.main}; diff --git a/src/components/PostLayout.tsx b/src/components/PostLayout.tsx index c89b94df..ea348ce2 100644 --- a/src/components/PostLayout.tsx +++ b/src/components/PostLayout.tsx @@ -3,6 +3,7 @@ import { Container, Divider, Footer, Space, Typo } from "@solved-ac/ui-react"; import { IconArrowLeft } from "@tabler/icons-react"; import { createLink } from "@tanstack/react-router"; import type { Post } from "content-collections"; +import "./styles.css"; const NavigationContainer = styled.div` padding-top: 32px; @@ -48,6 +49,7 @@ interface Props { children: React.ReactNode; root?: boolean; meta?: PostMetaLike; + en?: boolean; theme?: { background: string; color: string; @@ -55,9 +57,9 @@ interface Props { } export const PostLayout: React.FC = (props) => { - const { root, meta, theme, children } = props; + const { root, meta, theme, en, children } = props; - const prev = meta?.year ? `/${meta.year}${meta.codebattle ? "-codebattle" : ""}` : "/"; + const prev = `${en ? "/en" : ""}${meta?.year ? `/${meta.year}${meta.codebattle ? "-codebattle" : ""}` : "/"}`; const title = meta?.title ? `${meta.title}${ @@ -91,16 +93,30 @@ export const PostLayout: React.FC = (props) => { {root ? ( - NYPC 공식 사이트 + {en ? "NYPC Official Website" : "NYPC 공식 사이트"} ) : ( - 이전 + {en ? "Back" : "이전"} )} + {root && + (en ? ( + + + [한국어로 보기] + + + ) : ( + + + [View in English] + + + ))} {meta && ( diff --git a/src/components/ProblemList.tsx b/src/components/ProblemList.tsx index fec89133..e360dc20 100644 --- a/src/components/ProblemList.tsx +++ b/src/components/ProblemList.tsx @@ -23,10 +23,11 @@ interface Props { | Array<[string, string]> | ReadonlyArray<[string, string]> | ReadonlyArray; + en?: boolean; } export const ProblemList: React.FC = (props) => { - const { year, problems: list } = props; + const { year, problems: list, en } = props; const practices = useMemo( () => list.filter(([, title]) => title.startsWith("[연습문제]")), @@ -44,7 +45,7 @@ export const ProblemList: React.FC = (props) => { {practices.map(([id, title]) => (
  • - + 연습문제: {title.replace(/^\[연습문제] */, "")}
  • @@ -55,7 +56,7 @@ export const ProblemList: React.FC = (props) => { {problems.map(([id, title]) => (
  • - + {title}
  • diff --git a/src/components/styles.css b/src/components/styles.css new file mode 100644 index 00000000..8bbb5625 --- /dev/null +++ b/src/components/styles.css @@ -0,0 +1,5 @@ +.no-block p, +aside p, +span p { + display: inline; +} diff --git a/src/routes/en/$year.$page.tsx b/src/routes/en/$year.$page.tsx new file mode 100644 index 00000000..96f269c7 --- /dev/null +++ b/src/routes/en/$year.$page.tsx @@ -0,0 +1,28 @@ +import { createFileRoute, notFound } from "@tanstack/react-router"; +import { MDXViewer, PostLayout } from "components"; +import { allPosts } from "content-collections"; +import { z } from "zod"; + +const Post = () => { + const post = Route.useLoaderData(); + return ( + + + + ); +}; + +export const Route = createFileRoute("/en/$year/$page")({ + params: { + parse: z.object({ + year: z.union([z.number(), z.string()]), + page: z.string(), + }).parse, + }, + loader: ({ params }) => { + const post = allPosts.find((p) => p.slug === `en/${params.year}/${params.page}`); + if (!post) throw notFound(); + return post; + }, + component: Post, +}); diff --git a/src/routes/en/$year.notice.$page.tsx b/src/routes/en/$year.notice.$page.tsx new file mode 100644 index 00000000..00952ade --- /dev/null +++ b/src/routes/en/$year.notice.$page.tsx @@ -0,0 +1,28 @@ +import { createFileRoute, notFound } from "@tanstack/react-router"; +import { MDXViewer, PostLayout } from "components"; +import { allPosts } from "content-collections"; +import { z } from "zod"; + +const Post = () => { + const post = Route.useLoaderData(); + return ( + + + + ); +}; + +export const Route = createFileRoute("/en/$year/notice/$page")({ + params: { + parse: z.object({ + year: z.union([z.number(), z.string()]), + page: z.string(), + }).parse, + }, + loader: ({ params }) => { + const post = allPosts.find((p) => p.slug === `en/${params.year}/notice/${params.page}`); + if (!post) throw notFound(); + return post; + }, + component: Post, +}); diff --git a/src/routes/en/2025-codebattle/finals_1.mdx b/src/routes/en/2025-codebattle/finals_1.mdx new file mode 100644 index 00000000..17a97aa2 --- /dev/null +++ b/src/routes/en/2025-codebattle/finals_1.mdx @@ -0,0 +1,346 @@ +--- +title: Connexion +year: 2025 +stage: Final Round +codebattle: true +bikoId: 5629 +--- + +
    + +
    + +## Problem Description + +Yeti and Pink Bean arrived at the Mushroom Castle and saw mushrooms of various colors and patterns. Yeti wanted to collect mushrooms of the same pattern, while Pink Bean wanted to collect mushrooms of the same color. + +## Game Rules + +Connexion is a turn-based game played by two players. The game is played using a game board and game tiles. +The game consists of a **Preparation Phase**, a **Placement Phase**, and a **Scoring Phase**. + +### Game Board + +
    +
    +
    + +The game board is shaped as shown above, consisting of a total of $64$ cells. The coordinates of each board cell can be represented as an ordered triple (column, row, sign). + +- There are $6$ columns from left to right: `a`, `b`, `c`, `d`, `e`, `f`. +- There are $6$ rows from bottom to top: `1`, `2`, `3`, `4`, `5`, `6`. +- At the intersection of each column and row, there are two cells: `-` and `+`. + +A cell is represented by concatenating the column character, the row character, and the sign. + +Out of the $72$ possible combinations of columns, rows, and signs, the following $8$ are not used: + +- `a1-`, `a4-`, `c3+`, `c6+`, `d1-`, `d4-`, `f3+`, `f6+` + +Each cell is connected in the following manner: + +- A `-` cell is connected to the following three cells (if they exist): + - The `+` cell of the same column and row, + - The `+` cell of the column immediately to the left and the same row, + - The `+` cell of the same column and the row immediately below. +- A `+` cell is connected to the following three cells (if they exist): + - The `-` cell of the same column and row, + - The `-` cell of the column immediately to the right and the same row, + - The `-` cell of the same column and the row immediately above. + +For example, `c5-` is connected to `c5+`, `b5+`, and `c4+`, while `f4+` is connected to `f4-` and `f5-`. + +### Game Tiles + +
    + Connexion game tiles have colors and patterns. There are $4$ types of colors: + + R ( + Red tile + ) + + , + + G ( + Green tile + ) + + , + + B ( + Blue tile + ) + + , and + + Y ( + Yellow tile + ) + + . There are $4$ types of patterns: + + 1 ( + Pattern 1 + ) + + , + + 2 ( + Pattern 2 + ) + + , + + 3 ( + Pattern 3 + ) + + , and + + 4 ( + Pattern 4 + ) + + . For each of the $16$ different combinations of color and pattern, there are $4$ tiles, making a + total of $64$ tiles. A tile is represented by concatenating the color character and the pattern + character. +
    + +
    +
    +
    + +## Preparation Phase + +Determine the first and second players. Each person takes $2$ tiles of each of the $16$ combinations (total $32$ tiles), shuffles them, and puts them in a bag. Then, each player draws $5$ tiles from their bag and places them in front of them so everyone can see. 1 + +## Placement Phase + +The placement phase is carried out $64$ times in total, with each person taking $32$ turns starting from the first player. + +1. Place one of the tiles in front of you on one of the cells of the game board. +2. If there are tiles left in the bag, draw one tile from the bag and place it in front of you. 1 In the last five placement turns, no tiles will remain in the bag, so the drawing process is omitted. + + + +## Scoring + +If tiles placed in two adjacent cells have the same color, they are **connected by color**; if they have the same pattern, they are **connected by pattern**. + +Scoring can be calculated using either of the following two methods. The score calculated by both methods is identical. The person with the higher score wins; if scores are equal, it is a draw. + +### Calculation by Tile + +The first and second players calculate their scores differently. The score for each tile is: + +- First player: The number of tiles indirectly connected2 by the same pattern. +- Second player: The number of tiles indirectly connected2 by the same color. + +Each person's total score is the sum of the scores of all tiles. + + + +### Calculation by Group + +The first and second players group tiles differently. + +- First player: All tiles reachable by following connections of the same pattern are grouped together. +- Second player: All tiles reachable by following connections of the same color are grouped together. + +The score for each group is $(\text{number of tiles in the group})^2$. The total score is the sum of the scores of all groups. + +### Scoring Example + +
    + +The image above shows tiles placed at: (`a4+`, `G2`); (`a5-`, `G1`); (`b4-`, `B2`); (`b4+`, `Y2`); (`b5-`, `Y4`); (`b5+`, `R4`); (`b6-`, `B4`); (`c4+`, `R3`); (`c5-`, `R2`); (`c5+`, `Y2`). The scoring is as follows: + +#### First Player (Pattern) + +- **1 (Pattern 1)**: $1 \text{ point} \times 1 \text{ tile} = 1 \text{ point}$ +- **2 (Pattern 2)**: $3 \text{ points} \times 3 \text{ tiles} + 2 \text{ points} \times 2 \text{ tiles} = 13 \text{ points}$ +- **3 (Pattern 3)**: $1 \text{ point} \times 1 \text{ tile} = 1 \text{ point}$ +- **4 (Pattern 4)**: $3 \text{ points} \times 3 \text{ tiles} = 9 \text{ points}$ + +Total Score: $1+13+1+9 = 24 \text{ points}$ + +#### Second Player (Color) + +- + R ( + Red tile + ) + + : $3 \text{points} \times 3 \text{tiles} = 9 \text{points}$ +- + Y ( + Yellow tile + ) + + : $2 \text{points} \times 2 \text{tiles} + 1 \text{point} \times 1 \text{tile} = 5 \text{points}$ +- + G ( + Green tile + ) + + : $2 \text{points} \times 2 \text{tiles} = 4 \text{points}$ +- + B ( + Blue tile + ) + + : $1 \text{point} \times 1 \text{tile} + 1 \text{point} \times 1 \text{tile} = 2 \text{points}$ + +Total Score: $9+5+4+2 = 20 \text{ points}$ + +## Input/Output Format + +The participant's program must read input line by line and act according to each command. Commands requiring output are shown in red with their **time limits**. Failure to output within the limit results in a Time Limit Exceeded (TLE) and disqualification for that game. + +| Command | Input Format | Description | +| :------ | :----------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| READY | `READY (FIRST\|SECOND)` | Tells the player whether they are first or second. `FIRST` is first, `SECOND` is second. Must output OK within $\textbf{3,000}$**ms** to indicate readiness. | +| INIT | `INIT A₁ A₂ A₃ A₄ A₅ B₁ B₂ B₃ B₄ B₅` | Indicates the 5 tiles drawn by the player ($A_1 \dots A_5$) and the 5 tiles drawn by the opponent ($B_1 \dots B_5$) during preparation. | +| TIME | `TIME t₁ t₂` | At the start of the player's turn, provides remaining time for both players. $t_1$ is your time, $t_2$ is the opponent's time (in ms). You must output PUT p T within $t_1$ ms to place tile $T$ at position $p$. The initial $t_1, t_2$ is $10,000$ms, independent of time used for `READY`. | +| GET | `GET T` | Indicates the player drew tile $T$ after their turn. If the bag is empty, $T$ is `X0`. No output required. | +| OPP | `OPP p T₁ T₂ t` | Indicates the opponent placed $T_1$ at $p$, drew $T_2$, and took $t$ ms. If the bag was empty, $T_2$ is `X0`. No output required. | +| FINISH | `FINISH` | Signals the end of the game. The program must terminate normally immediately. No output required. | + +All commands must be processed line by line. When outputting, follow with a newline and flush the buffer. + +## Sample Code + +Sample codes for each language: + +- C20: [sample-code.c](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.c) +- C++20: [sample-code.cpp](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.cpp) +- C#: [sample-code.cs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.cs) +- OpenJDK Java 21: [sample-code.java](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.java) +- Node.js: [sample-code.rs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.rs) +- Typescript: [sample-code.ts](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.ts) +- PyPy3 / Python3: [sample-code.py](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.py) +- Rust 2024: [sample-code.rs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.rs) +- Lua: [sample-code.lua](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.lua) +- Go: [sample-code.go](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.go) +- Kotlin: [sample-code.kt](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.kt) + +The sample code places a tile in a valid position that maximizes the immediate score. + +## Match with Sample AI + +If the submitted code **compiles successfully**, it will compete against the **provided sample code**. +Two matches will be played, alternating between first and second player. Points are awarded as follows: + +- **Win**: +1 win +- **Draw**: +0.5 win +- **Loss**: +0 win + +## Testing Tool (GUI) + +A testing tool `testing-tool-connexion` is provided to test your program. You can test locally using your compiled executable or script environments like `python`, `java`, `node`, or `lua`. + +- 64-bit Windows (x86-64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/testing-tool-connexion/testing-tool-connexion-1.0.1.exe)) +- MacOS Universal ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/testing-tool-connexion/testing-tool-connexion_1.0.1_universal.dmg)) +- deb (Ubuntu/Debian AMD64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/testing-tool-connexion/testing-tool-connexion_1.0.1_amd64.deb)) +- rpm (Fedora/RHEL x86-64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/testing-tool-connexion/testing-tool-connexion-1.0.1-1.x86_64.rpm)) + +## Testing Tool (CLI) + +A CLI testing tool package `testing-tool-connexion.zip` ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/testing-tool-connexion/testing-tool-connexion-1.0.0.zip)) is also provided. Refer to the `README.md` inside for details. + +You are free to modify the CLI tool and discuss its execution. However, you must not share modified tools or logs with anyone outside your team. + +## Visualization Tools + +- + [Game Simulator] + +- + [Play Alternately] + +- + [Log Visualization Tool] + + +## Example Interaction + +| First Player Input | First Player Output | Second Player Input | Second Player Output | Log | +| :----------------------------------- | :------------------ | :----------------------------------- | :------------------- | :----------------------------------- | +| `READY FIRST` | `OK` | `READY SECOND` | `OK` | | +| `INIT R1 Y3 B1 G4 Y1 G3 Y3 R1 Y2 R3` | | `INIT G3 Y3 R1 Y2 R3 R1 Y3 B1 G4 Y1` | | `INIT R1 Y3 B1 G4 Y1 G3 Y3 R1 Y2 R3` | +| `TIME 10000 10000` | `PUT a1+ R1` | | | | +| `GET B3` | | `OPP a1+ R1 B3 70` | | `FIRST a1+ R1 B3 70` | +| | | `TIME 10000 9930` | `PUT a2- R1` | | +| `OPP a2- R1 R1 40` | | `GET R1` | | `SECOND a2- R1 R1 40` | +| `TIME 9930 9960` | `PUT a2+ B1` | | | | +| `GET Y2` | | `OPP a2+ B1 Y2 80` | | `FIRST a2+ B1 Y2 80` | +| | | (omitted) | | | +| `FINISH` | (Exit) | `FINISH` | (Exit) | `FINISH` | diff --git a/src/routes/en/2025-codebattle/index.tsx b/src/routes/en/2025-codebattle/index.tsx new file mode 100644 index 00000000..b5a2cfd2 --- /dev/null +++ b/src/routes/en/2025-codebattle/index.tsx @@ -0,0 +1,57 @@ +import { Divider, Itemize, Typo } from "@solved-ac/ui-react"; +import { Link, createFileRoute } from "@tanstack/react-router"; +import { PostLayout, ProblemList } from "components"; + +const year = "2025-codebattle"; + +export const problems = { + online: [ + ["online_p", "[Practice] Mushroom Game"], + ["online_1", "Yacht Auction"], + ], + finals: [["finals_1", "Connexion"]], +} as const; + +const List = () => { + return ( + + Information + +
  • + + Contest Rules + +
  • +
  • + + Development Tools Guide + +
  • +
    + + + Online Round + + + + + Final Round + + +
    + ); +}; + +export const Route = createFileRoute("/en/2025-codebattle/")({ + component: List, +}); diff --git a/src/routes/en/2025-codebattle/notice/rule.mdx b/src/routes/en/2025-codebattle/notice/rule.mdx new file mode 100644 index 00000000..565c830f --- /dev/null +++ b/src/routes/en/2025-codebattle/notice/rule.mdx @@ -0,0 +1,289 @@ +--- +title: Competition Rules +tool_link: /2025-codebattle/notice/tool +rule_link: /2025-codebattle/notice/rule +--- + +### Revision History + +- **September 24**: Added Final Round rules +- **August 11**: Added Swiss System guide +- **July 28**: Added Performance formula +- **July 28**: Added Practice Problem mid-term evaluation +- **July 28**: Added Final Submission selection +- **July 28**: Added Binary file submission +- **July 14**: Added Source code size limit +- **July 14**: Added content regarding Practice Problem discussion and sharing + +## Procedure Guide + +NYPC \ is a competition where participants create a program (AI) that implements strategies according to provided game rules to compete against other participants' AIs.
    +The competition consists of an Online Round and a Final Round. + +### Online Round + +- **Registration**: July 7 (Mon) – August 18 (Mon) +- **Practice Problems Open**: July 14 (Mon) 10:00 AM +- **Online Round Start**: August 8 (Fri) 10:00 AM +- **Online Round End**: August 18 (Mon) 11:59 PM + +Before the Online Round begins, you can test the environment used in the competition through the practice problems released on July 14.
    +Scores from practice problems are not reflected in the total score and do not affect the final Online Round score. + +The Online Round runs freely for 10 days. One problem is revealed at the start of the competition, and participants can submit code until the designated deadline. + +### Final Round + +At least the top 20 teams with outstanding performance in the Online Round can participate in the final competition held at the Pangyo office on October 25 (Sat). + +- **Entry and Registration**: 9:00 AM – 9:30 AM +- **Opening and Competition OT**: 9:30 AM – 10:00 AM +- **Final Competition**: 10:00 AM – 4:00 PM **(6 hours)** +- **Awards Ceremony**: 5:30 PM – + +(All times are based on KST, Saturday, October 25, 2025.) + +- All team members must arrive at the final venue to enter. +- The entry deadline is noon (12:00 PM), and entry is not permitted thereafter. + +## Problem Solving + +Participants can check the problem description and conditions on the problem page and submit one code file and one binary file. + +- Code must be 1MiB (1,048,576 bytes) or less, and the binary file must be 10MiB (10,485,760 bytes) or less. +- Grading against the Sample AI begins immediately upon submission. After grading is complete, you can check the submission history and results in the `VS: Sample AI` section. + - Grading results are displayed as Win/Draw/Loss. + - Fixed inputs are always provided. + - The Sample AI uses the same strategy for the same input. +- Answers can be submitted multiple times, but only one "Final Submission" will be used. + +### Online Round + +- If you submit code more than twice within 5 minutes, additional submissions are only possible 5 minutes after the first (penultimate) submission, not the second (last) submission. + - Submission intervals and frequency are subject to change depending on the organizer's circumstances. + +### Final Round + +- Code can be submitted once every 10 seconds. + +Please check the `Evaluation Rules` below for more details. + +## Execution and Grading Environment + +Execution and grading of all submitted code take place in the following environment: + +- Amazon Web Services c7i.4xlarge instance +- Custom processor based on 4th Gen Intel Xeon +- Clock: 3.2 GHz +- Processor Architecture: 64 bit +- OS: Ubuntu 24.04 + +Please note that code that does not operate normally in this environment will not be graded.
    +For information on compilers and specific development environments used for each language, please refer to the [Development Tool Guide] page.
    +Time and memory limit exceedance are determined based on the resources used by the process in which the participant's submitted source code is executed. + +- The time limit basically measures the time the process occupied the CPU (CPU time). +- The memory limit measures the amount of memory used by the process. This includes memory allocated to the process by the operating system and libraries used (header files, modules, etc.) in addition to variables or arrays declared by the user. +- It is possible to solve problems using multiple threads. However, only one CPU core is allocated to the program, and when measuring time and memory limits, the time and memory of all threads are summed. + +## Grading Results + +One of the following results is displayed for each submission, with details as follows: + +- `CE` (Compile Error) - Failed to compile the submitted source code. You can check the compile failure log by clicking the 'Compile Failed' text. +- `TLE` (Time Limit Exceeded) - The execution time of the submitted source code exceeded the time limit specified in the problem. +- `WTLE` (Wall Clock Time Limit Exceeded) - The actual execution time of the submitted source code exceeded the designated time limit. This occurs when the program does not terminate after the designated time limit, regardless of the CPU time limit written in the problem. It may occur if an error happens during execution or if the output buffer is not flushed. +- `RE` (Runtime Error) - An error occurred during execution. This error may also occur if the memory limit is exceeded. +- (Wrong Answer) - The program terminated normally, but the output is + incorrect. +- `IE` (Internal Error) - An unknown internal error occurred. If you receive this result, please contact the organizers. +- `X Wins (A/B/C)` - Result of matches against Sample AIs. 1 point for a win, 0.5 points for a draw, and 0 points for a loss. The win/loss is determined by summing the results of playing as both first and second player. + +If cases belonging to the same category have different results, one of the results may be displayed arbitrarily. +For example, if some cases in the same category are `RE` and others are `TLE`, the result may be displayed as either `RE` or `TLE`. + +## Inquiries about Problems + +If there is incorrect content in a problem or an unknown internal error that hinders the competition, you can inquire through the "Ask a Question" feature within the problem. + +- Please be careful as you may be disqualified if your questions contain slang or profanity during the competition. +- NYPC aims for a fair competition for all participants, so we cannot answer questions regarding problem-solving methods. +- Questions that deviate significantly from the intent of Q&A may not receive an answer. + +### Invalid Question Types + +The following are representative examples of invalid question types: + +> "The program I wrote works well on my computer, but the results are not normal when graded." + +- The provided testing tools may differ from the actual grading environment. Please double-check the problem's input/output format. + +> "It compiles well on my computer, but it says Compile Error when I submit it." + +- The development environment used by the participant and the grading environment where the program is actually compiled and executed may differ. Please be sure to check the [Development Tool Guide] page. + +### Answer Types + +When the issue does not hinder the progress of the competition, the organizer's typical responses are as follows: + +- `Only questions related to the problem are allowed.` - Applicable when the nature of the question is out of scope. +- `The answer to your question is in the problem description.` - Applicable when it is judged that the content written in the problem sufficiently answers the question. +- `No comment.` - Applicable when it is judged that the organizer's answer could influence the participant's problem-solving or competition progress in any way. + +## Evaluation Rules + +- You can select one submission that received a certain score or higher in `VS: Sample AI` as your **Final Submission**. + - If no final submission is selected, the very last submission that received a certain score or higher in `VS: Sample AI` will be selected as the final submission. + - The final submission can be re-selected during the competition. +- Mid-term and final evaluations are conducted using the submission designated as the Final Submission. + +### Practice Problems + +**Mid-term Evaluation** + +Every day at 3:00 PM before the Online Round begins, evaluations are conducted based on the code selected as the Final Submission among the codes submitted by each team.
    +At least 20 rounds are conducted in a Swiss-system tournament, and rankings are provided based on the results. +This can be checked in `VS: Participants Nationwide`. + +Practice problems do not undergo final evaluation and are not reflected in the final grades. + +### Online Round + +**Mid-term Evaluation** + +Every day at 3:00 PM and 9:00 PM, evaluations are conducted based on the code selected as the Final Submission among the codes submitted by each team.
    +At least 20 rounds are conducted in a Swiss-system tournament, and rankings are provided based on the results. +This can be checked in `VS: Participants Nationwide`. + +> Mid-term evaluations are for reference only and do not affect the final evaluation. + +**Final Evaluation** + +At least 50 rounds are conducted in a Swiss-system tournament to select at least the top 100 teams.
    +The selected teams will play at least 5 matches against every opponent in a Round-robin format, and the final ranking will be determined based on victory points. + +### Final Round + +**Mid-term Evaluation** + +Starting one hour after the competition begins, evaluations are conducted at least 10 times at designated points based on the code selected as the Final Submission. On the day of the competition, information about each mid-term evaluation can be checked at the venue. + +Matches are played against all opponents in a Round-robin format, and rankings are provided based on the results. +This can be checked in `VS: Participants Nationwide`. + +> Mid-term evaluations are for reference only and do not affect the final evaluation. + +**Final Evaluation** + +Matches are played at least 5 times with every opponent to calculate the number of wins against each opponent. When deciding winners, if the difference in points between two teams is marginal (if the null hypothesis that one team's points are superior cannot be adopted at a 5% significance level), additional matches may be conducted. + +The evaluation proceeds as follows: + +1. Based on matches involving all final participants, the top 10 teams with the highest sum of wins against all other opponents are selected. +2. Based on matches among the top 10 teams, the top 5 teams with the highest sum of wins against all other opponents are selected. +3. Based on matches among the top 5 teams, the top 2 teams with the highest sum of wins against all other opponents are selected. +4. Based on matches between the top 2 teams, the team that wins more against the opponent is selected as the final winner. + +## Tournament Progression + +Tournaments are conducted in either a Swiss-system or Round-robin format. The Swiss-system proceeds for a fixed number of rounds, and the Round-robin involves a fixed number of matches against every opponent within a single round. + +### Seed Determination + +- Seeds are assigned according to the **ranking of the previous evaluation**. (Lower rankings receive smaller seeds.) +- For first-time participants, smaller seeds are assigned in the **order of earlier submission time**. + +### Swiss-system Matchmaking + +**1. Bye Processing (If the number of participants is odd)** + +- Selected from participants who have not yet received a bye. +- Among participants satisfying this condition, the person with the **lowest score** is selected. +- If still tied, the participant with the **smallest seed** is selected. + +**2. Opponent Matching** + +- Matching is done in descending order of scores, and within the same score, in **descending order of seeds**. +- Match with an **opponent not yet played** as much as possible. +- If there are multiple candidates, the **opponent with the highest score** is prioritized. +- If still tied, matching is done with the **opponent with the largest seed**. + +### Round-robin Matchmaking + +- Matches are conducted against all opponents for a fixed number of times. + +### Match Progression + +- Multiple matches proceed simultaneously in each round. +- If there is a difference based on being the first or second player, **both sides take turns being the first/second player**. + +### Point Allocation + +Points are allocated according to match results as follows: + +- Win - 1 point +- Draw - 0.5 points +- Loss / Program Error (Runtime error, wrong output, time limit exceeded, etc.) - 0 points + +### Final Ranking Determination + +The final ranking is determined according to the following criteria: + +1. The participant with a **higher total score** gets a lower (better) rank. +2. If scores are equal, **tie-breaker criteria** are applied in order. +3. If still tied, the participant with the **smaller seed** gets a lower (better) rank. + +### Swiss-system Tie-breaker Criteria + +1. The participant with more **rounds where their match points were higher than the opponent's** gets a lower rank. +2. The participant with a higher **sum of all opponents' total scores** gets a lower rank. +3. The participant with a higher **sum of weighted scores from early rounds** gets a lower rank. + (Score of the i-th round × (Total number of rounds - i + 1)) +4. The participant with a higher **sum of weighted opponent scores from early rounds** gets a lower rank. + (Opponent's score of the i-th round × (Total number of rounds - i + 1)) + +### Round-robin Tie-breaker Criteria + +1. The participant with a higher **Sonneborn-Berger score** gets a lower rank. + (For all matches, the sum of [my match points in that match × opponent's total score]) + +### Performance + +Performance metrics are provided to gauge the skill level of the submitted code. Performance is for reference only and is not reflected in the evaluation. + +- "Estimated Performance" is provided based on the number of wins obtained through matches with the Sample AI in `VS: Sample AI`. +- Performance is calculated through match results with participants nationwide in `VS: Participants Nationwide`. + +For the performance calculation formula, please refer to the [Performance Calculation Formula PDF](https://github.com/nypc/nypc-perf/blob/main/docs/rating.pdf). + +## Misconduct + +**The following actions are considered misconduct, and you may face disadvantages if caught.** + +- Disclosing or leaking problems, problem-related algorithms, solutions, or source code for problems other than practice problems to an unspecified number of people. +- Discussing materials related to problems other than practice problems with third parties other than team members. +- Submitting code for which you do not have usage rights. + - Example 1: Code obtained through hacking, etc. + - Example 2: Code obtained using methods such as reversing (reverse engineering) commercial programs. + - Example 3: Code obtained through other illegal methods. + - Even if the code is publicly available to an unspecified number of people on the internet, it is considered that you do not have usage rights if the source is not indicated in comments, etc. +- Submitting code written by someone other than a team member after the start of the competition. +- Solving problems through proxy testing or with help from someone other than team members. +- Sharing or disclosing personal IDs and passwords to others. +- Duplicate participation by the same person using multiple IDs. +- Interfering with others' participation or attacking the system. +- Other actions that can commonly be considered misconduct. + +The items above are examples, and other actions may be considered misconduct at the discretion of the organizers.
    +If misconduct occurs or is suspected, participation and award eligibility may be revoked at any time during the competition.
    +If interference with competition operations is caused, the organizers may take legal action and claim damages. + +**The following actions are NOT misconduct.** + +- Discussing or sharing problems, problem content, solution methods, source code, etc., regarding practice problems. +- Discussing or sharing problem content, solution methods, source code, etc., among team members. + - In particular, using private chat rooms or code repositories that outsiders cannot see is not misconduct. + - However, when using chat rooms or code repositories, please be extra careful with **visibility/privacy settings**. +- Generating or modifying code using LLMs (ChatGPT, Copilot, etc.) and other coding assistance tools. + +If you are curious whether an action constitutes misconduct, do not judge arbitrarily and be sure to inquire with the organizers. diff --git a/src/routes/en/2025-codebattle/notice/tool.mdx b/src/routes/en/2025-codebattle/notice/tool.mdx new file mode 100644 index 00000000..47348cb8 --- /dev/null +++ b/src/routes/en/2025-codebattle/notice/tool.mdx @@ -0,0 +1,321 @@ +--- +title: Development Tool Usage Guide +tool_link: /2025-codebattle/notice/tool +rule_link: /2025-codebattle/notice/rule +--- + +### Revision History + +- **July 31**: Added Python tensorflow, torch, C++26, Rust nightly. Updated Rust 1.85 → 1.88 +- **July 28**: Added `data.bin` + +You may use development tools on your local computer for debugging and convenience when writing code.
    +In this case, please make sure to read this guide to avoid any disadvantages where the code does not execute or get graded due to differences between your local development environment and the grading environment (especially when using Visual Studio / Visual C++). + +## Grading Environment + +The execution and grading of all code submitted for code submission problems take place in the following environment: + +- Amazon Web Services c7i.4xlarge instance +- Custom processor based on 4th Generation Intel Xeon +- Clock: 3.2 GHz +- Processor Architecture: 64 bit +- OS: Ubuntu 24.04 + +Code that does not operate in this environment will not be graded. Please keep this in mind when using development tools. + +### Compiler by Language + + -XmX -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPC", + }, + { + name: "Rust 2024", + code: "rust2024", + version: "rustc 1.88.0", + libs: [ + { name: "bitvec@1.0.1", href: "https://crates.io/crates/bitvec/1.0.1" }, + { + name: "itertools@0.14.0", + href: "https://crates.io/crates/itertools/0.14.0", + }, + { name: "num@0.4.3", href: "https://crates.io/crates/num/0.4.3" }, + { name: "rand@0.9.0", href: "https://crates.io/crates/rand/0.9.0" }, + ], + compilation: + "cargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc", + execution: "./target/release/main NYPC", + }, + { + name: "Node.js", + code: "nodejs22", + version: "Node.js v22.13.1", + execution: "node main.js NYPC", + }, + { + name: "Typescript 5.8.3", + code: "nodets22", + version: "Typescript 5.8.3 (Node.js v22.13.1)", + libs: [ + { + name: "@types/node@22.13.1", + href: "https://www.npmjs.com/package/@types/node/v/22.13.1", + }, + ], + compilation: + "tsc main.ts --target ESNext --moduleResolution node --module commonjs --noEmitOnError", + execution: "node main.js NYPC", + }, + { + name: "C# 9", + code: "csharp9", + version: "dotnet 9.0.104", + libs: [ + { + name: "MathNet.Numerics 5.0.0", + href: "https://www.nuget.org/packages/MathNet.Numerics/5.0.0", + }, + ], + compilation: + 'dotnet publish -r linux-x64 -p:PublishSingleFile=true -p:DefineConstants="ONLINE_JUDGE;NYPC" --no-restore -c Release --sc true', + execution: "./bin/Release/net9.0/linux-x64/publish/Main NYPC", + }, + { + name: "Go", + code: "golang124", + version: "go 1.24.2", + libs: [ + { + name: "gonum.org/v1/gonum@v0.16.0", + href: "https://pkg.go.dev/gonum.org/v1/gonum@v0.16.0", + }, + { + name: "github.com/emirpasic/gods@v1.18.1", + href: "https://pkg.go.dev/github.com/emirpasic/gods@v1.18.1", + }, + { + name: "github.com/liyue201/gostl@v1.2.0", + href: "https://pkg.go.dev/github.com/liyue201/gostl@v1.2.0", + }, + ], + compilation: "go build -mod vendor -o main main.go", + execution: "./main NYPC", + }, + { + name: "LuaJIT", + code: "luajit", + version: "Lua 5.1 (LuaJIT 2.1.1748459687)", + compilation: "luajit -O3 -b Main.lua Main.out", + execution: "luajit Main.out NYPC", + }, + { + name: "Lua 5.4", + code: "lua", + version: "Lua 5.4.6", + compilation: "luac5.4 -o Main.out Main.lua", + execution: "lua5.4 Main.out NYPC", + }, + { + name: "Kotlin JVM 2.1", + code: "kotlinjvm", + version: "kotlinc-jvm 2.1.21", + compilation: "kotlinc -include-runtime -d Main.jar Main.kt", + execution: "java -Xms -XmX -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPC", + }, + { + name: "Kotlin/Native 2.1", + code: "kotlinnative", + version: "kotlinc-native 2.1.21", + compilation: "konanc Main.kt -o Main -opt", + execution: "./Main.kexe NYPC", + }, + { + name: "C++26", + code: "cpp-exp", + version: "gcc 15", + libs: [ + { + name: "Boost 1.83.0", + href: "https://www.boost.org/releases/1.83.0/", + }, + ], + compilation: + "g++-15 -std=gnu++26 -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.cpp -I/opt/boost/gcc/include -L/opt/boost/gcc/lib", + execution: "./main NYPC", + showExample: false, + }, + { + name: "Rust 2024 Nightly", + code: "rust-exp", + version: "rustc >=1.90.0", + libs: [ + { name: "bitvec@1.0.1", href: "https://crates.io/crates/bitvec/1.0.1" }, + { + name: "itertools@0.14.0", + href: "https://crates.io/crates/itertools/0.14.0", + }, + { name: "num@0.4.3", href: "https://crates.io/crates/num/0.4.3" }, + { name: "rand@0.9.0", href: "https://crates.io/crates/rand/0.9.0" }, + ], + compilation: + "cargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc", + execution: "./target/release/main NYPC", + showExample: false, + }, + ]} +/> + +- C++26 and Rust 2024 Nightly are experimental languages; the grading and compilation environments may change frequently, and normal operation is not guaranteed. + +### Precautions + +Please be careful not to write code that only works on specific platforms (especially Windows or Visual C++), as shown in the examples below. + +| Prohibited Example | Remarks | +| --------------------- | ----------------------------------------------------------------------- | +| `void main()` | Must be `int main` according to the standard | +| `getch()` | Use `getchar()` instead | +| `fflush(stdin)` | Use of non-standard function | +| `GetTickCount()` | Windows API cannot be used | +| `CString` | `CString` is not standard and cannot be used. Use `std::string` instead | +| `#include ` | `stdafx.h` is a Visual C++ exclusive precompiled header | + +### Java Precautions + +The class name must be `Main`. + +## Using Standard Input/Output + +In all code submission problems, you must receive input via standard input according to the given input format and produce output via standard output according to the given output format.
    +If there is a problem that requires receiving two integers and outputting their product as in the example below, the methods for handling standard input and standard output by language are as follows. + +### Input Example + +``` +8 4 +``` + +### Output Example + +``` +32 +``` + +### Code Examples by Language + + + + + + + + + + + + + + + + +### Binary Files + +In the NYPC \ grading environment, you can submit binary files in addition to source code. The binary file is provided under the name `data.bin` in the directory where the source code is executed. +This file is provided only during code execution and is not provided during compilation.
    +The following is code that outputs all bytes of `data.bin` to standard output. + + + + + + + + + + + + + + + + +## Program Exit Code + +The exit code of the written program must always be 0 (normal termination). If it does not terminate with 0, the program may not be graded even if it outputs the correct answer.
    +In particular, even if you submit code that sets the exit code to 0, it may terminate with a non-zero code depending on whether a runtime error occurs in the written program. diff --git a/src/routes/en/2025-codebattle/online_1.mdx b/src/routes/en/2025-codebattle/online_1.mdx new file mode 100644 index 00000000..eee72f6b --- /dev/null +++ b/src/routes/en/2025-codebattle/online_1.mdx @@ -0,0 +1,203 @@ +--- +title: Yacht Auction +year: 2025 +stage: Online Round +codebattle: true +--- + +
    + +
    + +## Problem Description + +After finishing their mushroom game, Yeti and Pink Bean have moved to Grandis. Reminiscing about the past when they threw dice using the Lucky Dice skill, they decided to play a board game called Yacht Auction. + +## Game Rules + +- A single match consists of $13$ rounds. +- Each round consists of a **Bidding** phase and a **Scoring** phase. + - Exceptionally, the first round does not include a **Scoring** phase, and the last ($13$th) round does not include a **Bidding** phase. + +### Bidding Phase + +The bidding phase proceeds as follows: + +1. Two sets of dice, Set $A$ (5 dice) and Set $B$ (5 dice), are rolled. Each die is independent and has an equal probability of resulting in an integer between $1$ and $6$ inclusive. +2. Each player submits the dice set they wish to take ($A$ or $B$) and a bid score between $0$ and $100,000$ inclusive. +3. Dice sets are distributed based on the submitted choices and bid scores according to these rules: + +- If the players choose different sets, each player takes their desired set. +- If both players choose the same set, the player who submitted the higher bid score takes that set. +- If both the chosen set and the bid score are identical, the winner is determined randomly with equal probability ($50\%$), and each occurrence is independent. + +4. Scores are then adjusted according to the following rules: + +- If a player successfully takes their desired set, they **lose points** equal to their bid score. +- If a player fails to take their desired set, they **gain points** equal to their bid score. + +### Scoring Phase + +From the $10$ dice currently in possession (note: only $5$ dice are available in the final scoring phase), the player selects $5$ dice. Then, the player chooses one of the following **Scoring Rules** to earn points. Each scoring rule can be used at most once per match. + +### Basic Scoring Rules + +- `ONE`: $\text{Sum of dice showing } 1 \times \mathbf{1,000}$ **points** +- `TWO`: $\text{Sum of dice showing } 2 \times \mathbf{1,000}$ **points** +- `THREE`: $\text{Sum of dice showing } 3 \times \mathbf{1,000}$ **points** +- `FOUR`: $\text{Sum of dice showing } 4 \times \mathbf{1,000}$ **points** +- `FIVE`: $\text{Sum of dice showing } 5 \times \mathbf{1,000}$ **points** +- `SIX`: $\text{Sum of dice showing } 6 \times \mathbf{1,000}$ **points** + +Additionally, if a player earns a total of $63,000$ points or more from the Basic Scoring Rules, they receive a **Bonus Score** of $\mathbf{35,000}$ **points**. + +### Combination Scoring Rules + +- `CHOICE`: $\textbf{Sum of all five dice} \times \mathbf{1,000}$ **points** +- `FOUR_OF_A_KIND`: If there are at least $4$ dice with the same value, $\textbf{Sum of all five dice} \times \mathbf{1,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `FULL_HOUSE`: If $3$ dice have the same value and the other $2$ dice have a different but identical value, $\textbf{Sum of all five dice} \times \mathbf{1,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `SMALL_STRAIGHT`: If $4$ dice form a sequence ($1234, 2345, \text{ or } 3456$), $\mathbf{15,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `LARGE_STRAIGHT`: If all $5$ dice form a sequence ($12345 \text{ or } 23456$), $\mathbf{30,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `YACHT`: If all $5$ dice have the same value, $\mathbf{50,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. + +### Final Score and Victory Condition + +After all rounds are completed, the player with the higher total score wins. If the total scores are equal, it is a draw. + +- $\text{Player's Total Score} = \text{Points from Basic Rules} + \text{Points from Combination Rules} + \text{Bidding Points}$ + +## Input/Output Format + +The participant's program must read input line by line and act according to each command. Commands requiring output are marked in red in the table below, along with their **time limits**. Failure to output within the time limit will result in a Time Limit Exceeded (TLE) verdict and disqualification from that game. + +| Command | Input Format | Description | +| :------ | :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| READY | `READY` | Output OK within **3 seconds** to indicate readiness. | +| ROLL | `ROLL a₁a₂a₃a₄a₅ b₁b₂b₃b₄b₅` | Indicates dice in Group A are $a_1, \cdots, a_5$ and Group B are $b_1, \cdots, b_5$. Output BID g x within **0.5 seconds**. This means bidding $x$ points for group $g$. $g$ must be `A` or `B`, and $x$ must be an integer between $0$ and $100,000$. | +| GET | `GET g g₀ x₀` | Indicates you took group $g$ as a result of the bidding. The opponent bid $x_0$ points for group $g_0$. | +| SCORE | `SCORE` | Indicates the start of the scoring phase. Output PUT c d₁d₂d₃d₄d₅ within **0.5 seconds**. This means using rule $c$ with dice $d_1, \cdots, d_5$ from your possession. | +| SET | `SET c d₁d₂d₃d₄d₅` | Indicates the opponent used rule $c$ with dice $d_1, \cdots, d_5$ during their scoring phase. | +| FINISH | `FINISH` | Command signaling the end of the game. Upon receiving this, the program must terminate normally immediately regardless of the game state. No output is required. | + +All commands must be processed one line at a time. When outputting, ensure you print a newline character and then flush the buffer. Please refer to the official documentation or sample codes for your specific language on how to flush the buffer. + +## Sample Code + +The following are sample codes provided for each language: + +- C20: [sample-code.c](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.c) +- C++20: [sample-code.cpp](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.cpp) +- C# 9: [sample-code.cs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.cs) +- OpenJDK Java 21: [sample-code.java](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.java) +- Node.js: [sample-code.js](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.js) +- Typescript: [sample-code.ts](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.ts) +- PyPy3 / Python3: [sample-code.py](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.py) +- Rust 2024: [sample-code.rs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.rs) +- Lua 5.1/5.4: [sample-code.lua](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.lua) +- Go: [sample-code.go](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.go) +- Kotlin 2.1 (JVM, Native): [sample-code.kt](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/sample-code/sample-code.kt) + +The sample code operates as follows: + +- Bidding phase: Bids on the group (A or B) with the higher sum, using a bid of $\left\lfloor(\text{my current score} - \text{opponent's current score})/{10}\right\rfloor$, clamped between $0$ and $100,000$. +- Scoring phase: Uses the first 5 dice obtained and assigns them to the first available (unused) scoring rule. + +## Match Against Sample AIs + +Once the submitted code **compiles successfully**, it will compete against a total of **10 sample AIs**. +One match is played against each sample AI. Points are awarded as follows: + +- **Win**: +1 win +- **Draw**: +0.5 win +- **Loss**: +0 win + +| Battle No. | Description | Code | `data.bin` | +| :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------- | +| 1 | Performs the same actions as the provided sample code. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht1A.rs) | | +| 2 | **Bidding**: Bids (difference in group sums) $\times 1,000$ on the group with the higher sum.
    **Scoring**: Uses the rule and combination that yields the highest possible score. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht2B.rs) | | +| 3 | **Bidding**: Randomly picks A or B and bids $0$ points.
    **Scoring**: Uses the rule and combination that yields the highest possible score. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht2C.rs) | | +| 4 | **Bidding**: Randomly picks A or B and bids $0$ points.
    **Scoring**: Prioritizes combinations that are difficult to score. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht3C.rs) | | +| 5 | **Bidding**: Randomly picks A or B and bids $0$ points.
    **Scoring**: Prioritizes Basic Scoring Rules. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht4C.rs) | [data](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht4C.bin) | +| 6 | **Bidding**: Bids defensively on better combinations.
    **Scoring**: Prioritizes Basic Scoring Rules. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht4D.rs) | [data](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht4D.bin) | +| 7 | **Bidding**: Bids aggressively on better combinations.
    **Scoring**: Prioritizes Basic Scoring Rules. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht4E.rs) | [data](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht4E.bin) | +| 8 | **Bidding**: Randomly picks A or B and bids $0$ points.
    **Scoring**: Prioritizes Combination Scoring Rules. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht5C.rs) | [data](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht5C.bin) | +| 9 | **Bidding**: Bids defensively on better combinations.
    **Scoring**: Prioritizes Combination Scoring Rules. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht5D.rs) | [data](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht5D.bin) | +| 10 | **Bidding**: Bids aggressively on better combinations.
    **Scoring**: Prioritizes Combination Scoring Rules. | [Code](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht5E.rs) | [data](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/ai.ylb98uspah/yacht5E.bin) | + +> Note: Sample AI codes and `data.bin` files were not provided during the actual competition. + +## Testing Tool (GUI) + +A testing tool, `testing-tool-yacht`, is provided to test the participant's program. You can test your code locally using compiled executables or scripts in environments such as `python`, `java`, `node`, or `lua`. + +- 64-bit Windows (x86-64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/testing-tool-yacht/testing-tool-yacht-1.0.0.exe)) + - Run the downloaded `.exe` file. +- MacOS Universal ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/testing-tool-yacht/testing-tool-yacht_1.0.0_universal.dmg)) + - Double-click the `.dmg` file, then drag and drop the `testing-tool-yacht` file into the `Applications` folder. Then, run the app. + - If a security warning appears regarding apps not from the App Store, check the app info in "Settings > Privacy & Security". +- deb (Ubuntu/Debian AMD64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/testing-tool-yacht/testing-tool-yacht_1.0.0_amd64.deb)) + - Install the `.deb` file using `apt` or `dpkg`, then run `testing-tool-yacht`. +- rpm (Fedora/RHEL x86-64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/testing-tool-yacht/testing-tool-yacht-1.0.0-1.x86_64.rpm)) + - Install the `.rpm` file using `rpm` or `yum`, then run `testing-tool-yacht`. + +## Testing Tool (CLI) + +A CLI testing tool package, `testing-tool-yacht-cli.zip` ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/yacht-auction.858aad472ce8/testing-tool-yacht/testing-tool-yacht-cli.zip)), is also provided. For details, refer to the `README.md` inside the file. + +You are free to modify the CLI testing tool and discuss its execution methods with others. However, you must not share modified tools or log files generated by the tool with anyone outside your team, nor discuss them. + +In the grading results, you will receive log files in the same format as those output by the testing tool. However, since the actual grading program is implemented differently from the testing tool, successful operation in the testing tool does not always guarantee successful operation in the actual grading. + +## Visualization Tools + +- + [Game Simulator] + +- + [Play Alternately] + +- + [Log Visualization Tool] + + +You can download log files for each battle from the Sample AI matches. Use the Log Visualization Tool to examine how the game progressed and refine your strategy. + +## Example + +### Example Input (Used in Testing Tool) + +``` +35561 15336 0 +31452 33164 0 +21464 46146 0 +51211 45446 1 +62612 34411 1 +12421 36431 0 +54344 36225 1 +13653 32122 0 +53644 61453 0 +64215 15142 1 +35522 44162 1 +54111 55424 1 +``` + +### Example Interaction + +| First Player Input | First Player Output | Second Player Input | Second Player Output | Log | +| :--------------------- | :------------------ | :------------------------ | :--------------------- | :----------------------------------------------------------------- | +| `READY` | `OK` | `READY` | `OK` | | +| `ROLL 35561 15336` | | `ROLL 35561 15336` | |

    `ROUND 1`

    `ROLL 35561 15336`

    | +| | `BID A 123` | | `BID A 456` |

    `BID FIRST A 123`

    `BID SECOND A 456`

    | +| `GET B A 456` | | `GET A A 123` | |

    `GET FIRST B`

    `GET SECOND A`

    | +| `ROLL 31452 33164` | | `ROLL 31452 33164` | |

    `ROUND 2`

    `ROLL 31452 33164`

    | +| | `BID A 99` | | `BID B 11` |

    `BID FIRST A 99`

    `BID SECOND B 11`

    | +| `GET A B 11` | | `GET B A 99` | |

    `GET FIRST A`

    `GET SECOND B`

    | +| `SCORE` | | `SCORE` | | | +| | `PUT ONE 35561` | | `PUT THREE 13356` |

    `PUT FIRST ONE 35561`

    `PUT SECOND THREE 13356`

    | +| `SET THREE 13356` | | `SET ONE 35561` | | | +| | | **(Rounds 3-12 omitted)** | | | +| `SCORE` | | `SCORE` | |

    `ROUND 13`

    | +| | `PUT YACHT 12556` | | `PUT FULL_HOUSE 42533` |

    `PUT FIRST YACHT 12556`

    `PUT SECOND FULL_HOUSE 42533`

    | +| `SET FULL_HOUSE 42533` | | `SET YACHT 12556` | | | +| `FINISH` | (Program ends) | `FINISH` | (Program ends) |

    `FINISH`

    | +| | | | |

    `SCOREFIRST 19000`

    `SCORESECOND 30372`

    | diff --git a/src/routes/en/2025-codebattle/online_p.mdx b/src/routes/en/2025-codebattle/online_p.mdx new file mode 100644 index 00000000..ec6eef5a --- /dev/null +++ b/src/routes/en/2025-codebattle/online_p.mdx @@ -0,0 +1,207 @@ +--- +title: Mushroom Game +year: 2025 +stage: Online Round Practice Problems +codebattle: true +--- + +
    +
    +
    + +## Problem Description + +In the peaceful forest of Maple World, Yeti and Pink Bean were tending to their mushroom patch together as usual. +One day, the two friends discovered that every mushroom had a number written on it and decided to create a new game using these numbers. +They devised a game where they compete to occupy parts of the mushroom patch, taking turns to select areas according to the rules below. + +### Game Rules + +- **Rule 1** + On their turn, a player selects a single rectangular area in the mushroom patch. + +- **Rule 2** + If the sum of the numbers within the selected area is exactly $10$, the mushrooms in that area are removed and the player occupies that area. + If the area contains cells already occupied by the opponent, the ownership of those cells is taken over. + Additionally, each of the four sides of the selected rectangle must have at least one mushroom **adjacent** to the inside of the area. + +- **Rule 3** + If there are no selectable areas or if a player strategically chooses not to make a move, they may skip their turn and pass. + +- **Rule 4** + The game ends when both players pass their turns consecutively. + The player who occupies more cells at the end of the game wins. + +Write a program to play as either Yeti or Pink Bean and occupy as many cells as possible in the mushroom patch. + +## Input/Output Format + +The participant's program must read input line by line and operate according to each command. Commands that require output are marked in red in the table below. + +| Command | Input Format | Description | +| ------- | ----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| READY | `READY (FIRST\|SECOND)` | A command informing the player whether they go first or second. The program must output **OK**, indicating it is ready for input, within 3 seconds. | +| INIT | `INIT ...` | A command to initialize the game board information. `...` consists of $10$ strings, each composed of $17$ digits.
    Each digit is an integer between $1$ and $9$ inclusive, representing the number on the mushroom at that position. No output is required.
    Each digit is provided independently with an equal probability for integers from $1$ to $9$. | +| TIME | `TIME t₁ t₂` | A command informing the players of their remaining time. $t_1$ is your program's remaining time, and $t_2$ is the opponent's remaining time.
    Upon receiving this command, the player must output the coordinates of the rectangle selected for this turn in the format $r_1$ $c_1$ $r_2$ $c_2$.
    The top-left coordinate of the board is $(r, c) = (0, 0)$, and the bottom-right is $(9, 16)$.
    To pass, output $r_1 = c_1 = r_2 = c_2 = -1$. Output values must satisfy:

    $-1 \le r_1 \le r_2 \le 9$
    $-1 \le c_1 \le c_2 \le 16$
    The initial time given as $t_1, t_2$ is $10,000$, regardless of the time used for the `READY` command. | +| OPP | `OPP x₁ y₁ x₂ y₂ t` | A command providing information about the opponent's move. It includes the coordinates $r_1$ $c_1$ $r_2$ $c_2$ selected by the opponent and the time $t$ they used during that turn.
    If the opponent passed, $r_1 = c_1 = r_2 = c_2 = -1$ is given. No output is required. | +| FINISH | `FINISH` | A command indicating the end of the game. Upon receiving this, the program must terminate normally. No output is required. | + +The buffer must be flushed after every output. Failure to flush the buffer may result in a TLE (Time Limit Exceeded) because the output was not properly sent. Please refer to the official reference documentation and sample codes for each language on how to flush the buffer. + +## Sample Code + +The following are sample codes written for each language. + +- C20: [sample_code.c](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.c) +- C++20: [sample_code.cpp](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.cpp) +- C#: [Main.cs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/Main.cs) +- OpenJDK Java 21: [Main.java](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/Main.java) +- Node.js: [sample_code.js](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.js) +- Typescript: [sample_code.ts](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.ts) +- PyPy3 / Python3: [sample_code.py](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.py) +- Rust 2024: [sample_code.rs](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.rs) +- Lua: [sample_code.lua](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.lua) +- Go: [sample_code.go](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.go) +- Kotlin: [sample_code.kt](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/sample_code/sample_code.kt) + +The sample code selects and outputs the rectangle $(r_1, c_1, r_2, c_2)$ that is lexicographically smallest among all valid rectangles—essentially the one furthest to the top-left. If no selectable rectangle exists, it passes the turn. + +## Matches with Sample AIs + +If the submitted code **compiles successfully**, it will compete against a total of **7 sample AIs**. +The program will play **2 matches against each sample AI**, alternating between going first and second. Scores based on wins and losses are as follows: + +- **Win**: +1 win +- **Draw**: +0.5 win +- **Loss**: +0 win + +The strategies of the sample AIs are as follows: + +| Battle No. | Description | +| ---------- | ------------------------------------------------------------- | +| 1 / 2 | Always "Passes" on its turn. | +| 3 / 4 | Performs the same actions as the provided sample code. | +| 5 / 6 | Uses the strategy of the game simulator sample AI, Pink Bean. | +| 7 / 8 | Uses a medium-difficulty defensive strategy. | +| 9 / 10 | Uses a medium-difficulty offensive strategy. | +| 11 / 12 | Uses a high-difficulty defensive strategy. | +| 13 / 14 | Uses a high-difficulty offensive strategy. | + +## Visualization Tools (Sample AI / Two-Player / Log Analysis) + +You can play the game against sample AIs, play with two people alternating turns, and use a visualization tool to visualize logs generated by the game simulator and testing tools. + +- + [Game Simulator] + +- + [Two-Player Mode] + +- + [Log Visualization Tool] + + +You can download log files for each battle from the sample AI matches. Use the log visualization tool to examine how the game progressed and refine your strategy. + +## Testing Tool (GUI) + +A testing tool, `testing-tool-mushroom`, is provided to test participant programs. You can test the problem locally using executable files compiled in your environment or scripts using `python`, `java`, `node`, or `lua` environments. + +- 64-bit Windows (x86-64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/testing-tool-mushroom/testing-tool-mushroom.exe)) + - Run the downloaded `.exe` file. +- MacOS Universal ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/testing-tool-mushroom/testing-tool-mushroom_1.0.0_universal.dmg)) + - After double-clicking the `.dmg` file, drag and copy the `testing-tool-mushroom` file to the `Applications` folder. Then, run the `testing-tool-mushroom` app. + - If a message appears saying "testing-tool-mushroom-app cannot be opened because the developer cannot be verified," check the app information in "Settings > Privacy & Security." +- 64-bit Ubuntu (AMD64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/testing-tool-mushroom/testing-tool-mushroom_1.0.0_amd64.deb)) + - Install the `.deb` file using `apt` or `dpkg`, then run `testing-tool-mushroom`. +- 64-bit RedHat (x86-64) ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/testing-tool-mushroom/testing-tool-mushroom-1.0.0-1.x86_64.rpm)) + - Install the `.rpm` file using `rpm` or `yum`, then run `testing-tool-mushroom`. + +## Testing Tool (Command Line, Python Script) + +A testing tool, `testing_tool.py` ([Download](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/mushroom.92e824cffe84/testing_tool.py)), is provided to test participant programs. The testing tool is a program written in Python 3.12. Regarding the execution of this program, please refer to [Python Setup and Usage]. + +To use the testing tool, create a `setting.ini` file in the same location as `testing_tool.py`. The content should be as follows: + +``` +INPUT= +LOG= +EXEC1= +EXEC2= +``` + +For example, if the input is `input.txt` in the same folder, the log is output to `log.txt`, the command for the first player is `./Main.exe`, and the command for the second player is `python3 main.py --test`, you would write: + +``` +INPUT=./input.txt +LOG=./log.txt +EXEC1=./Main.exe +EXEC2=python3 main.py --test +``` + +## Testing Tool Input Format and Log Interpretation + +The input file for the testing tool represents the initial state of the board. The board must consist of $10$ lines, each containing $17$ digits from $1$ to $9$. Then, run `testing_tool.py`. After execution, the logs will be output to the specified log file `./log.txt`. + +The logs output the following information: + +- `INIT ... ` + - Indicates that the `i`-th row of the board is `` when the game starts. +- `