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/2025-codebattle/finals_1.mdx b/src/routes/2025-codebattle/finals_1.mdx index e96f5e86..0b920313 100644 --- a/src/routes/2025-codebattle/finals_1.mdx +++ b/src/routes/2025-codebattle/finals_1.mdx @@ -272,7 +272,7 @@ $64$개가 있습니다. 타일은 색을 표현하는 문자와 문양을 표 - 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) +- Node.js: [sample-code.js](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.js) - 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) 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..acbf059b --- /dev/null +++ b/src/routes/en/2025-codebattle/finals_1.mdx @@ -0,0 +1,368 @@ +--- +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 gather mushrooms of the same pattern, while Pink Bean wanted to gather 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 triplet (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 each 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 triplets of columns, rows, and signs, the following $8$ triplets 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, namely + + R ( + Red tile + ) + + , + + G ( + Green tile + ) + + , + + B ( + Blue tile + ) + + , and + + Y ( + Yellow tile + ) + + . There are $4$ types of patterns, namely + + 1 ( + Pattern 1 + ) + + , + + 2 ( + Pattern 2 + ) + + , + + 3 ( + Pattern 3 + ) + + , and + + 4 ( + Pattern 4 + ) + + . There are 4 tiles each, for the $16$ different pairings of colors and patterns, making a total + of $64$ tiles. A tile is represented as two characters, concatenating the color and the pattern. +
    + +
    +
    +
    + +## Preparation Phase + +Determine the first and second players. Each player takes $32$ tiles, $2$ tiles of each pairings of colors and patterns. Each player shuffles tiles, and puts them in a bag. Finally, 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 consists of $64$ turns in total. Each person takes $32$ turns starting from the first player. + +1. Place one of the tiles in front of you on one of the empty 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, drawing tile is ommitted as no tiles are left in bag. + + + +## Scoring + +If tiles placed in two adjacent cells have the same color, they are said to be **connected by color**; if they have the same pattern, they are said to be **connected by pattern**. + +The scores can be calculated using either of the following two methods. The scores calculated by both methods are identical. The person with the higher score wins; if scores are equal, the game ends with draw. + +### Calculation by Tile + +The first and second players calculate their score respectively. 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. + +The score of each player is the sum of the scores of all tiles. + + + +### Calculation by Group + +The first and second players group tiles respectively. + +- 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 Protocol + +Your program must read input line by line and follow the protocol of each command. Commands requiring the output are denoted with red color with their **time limit** specified. If your program fails to output within specified time limit, you will receive Time Limit Exceeded (TLE) verdict and will result forfeiting the game. + +| Command | Input Format | Description | +| ------- | ------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| READY | `READY (FIRST\|SECOND)` | Indicates whether your program takes first or second player. Must output OK within $\textbf{3\,000}$**ms** as a response. | +| INIT | `INIT A₁ A₂ A₃ A₄ A₅ B₁ B₂ B₃ B₄ B₅` | Indicates the 5 tiles drawn by your program ($A_1 \dots A_5$) and the 5 tiles drawn by the opponent's program ($B_1 \dots B_5$) during a preparation phase. | +| TIME | `TIME t₁ t₂` | Indicates it is your program's turn. Also provides remaining time for both players; $t_1$ is yours, $t_2$ is the opponent's (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 given as $10\,000$ms, regardless of time used for `READY` command. | +| GET | `GET T` | Indicates your program drew tile $T$ after the placement of tile. If the bag is empty so drawing tile is omitted, $T$ is `X0`. Output is not required. | +| OPP | `OPP p T₁ T₂ t` | Indicates the opponent placed $T_1$ at $p$, drew $T_2$, while taking $t$ ms. If the bag was empty, $T_2$ is `X0`. Output is not required. | +| FINISH | `FINISH` | Indicates the end of the game. The program must terminate properly and immediately, regardless of the current status of the game. Output is not required. | + +All commands must be processed line by line. When you output, make sure you print a newline character and then flush the buffer. Please refer to the reference document or sample code of your programming 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/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.js](https://nypc-static.s3.ap-northeast-2.amazonaws.com/2025/connexion.8c20978b76cf/sample-code/sample-code.js) +- 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 the program. You can test your compiled executable or script locally, using `python`, `java`, `node`, or `lua` in your envinroment. + +- 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)) + - Run the downloaded `.exe` file. +- 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)) + - Double-click the `.dmg` file, then drag and drop the `testing-tool-connexion` 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/connexion.8c20978b76cf/testing-tool-connexion/testing-tool-connexion_1.0.1_amd64.deb)) + - Install the `.deb` file using `apt` or `dpkg`, then run `testing-tool-connexion`. +- 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)) + - Install the `.rpm` file using `rpm` or `yum`, then run `testing-tool-connexion`. + +## Testing Tool (CLI) + +A CLI testing tool package, `testing-tool-connexion-cli.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 provided to test the program. For details, refer to the `README.md` inside the zip file. + +You can freely 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. + +You will receive log files having same format with testing tool, in the submission result dialogue. However, actual grading program is implemented differently from the testing tool, a successful execution in the testing tool does not always guarantee a successful execution in the actual grading. + +## Visualization Tools + +- + [Game Simulator] + +- + [Play by Yourself] + +- + [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 + +``` +R1 Y3 B1 G4 Y1 B3 Y2 R3 G1 R2 G3 G1 R2 R1 B4 G4 B2 Y2 R3 Y4 B1 R4 B4 B2 Y4 G2 R4 Y3 G2 B3 G3 Y1 +G3 Y3 R1 Y2 R3 R1 Y1 B1 G1 R3 G2 Y4 Y2 Y3 B3 B2 B4 G2 R2 B4 R4 Y1 G4 R4 G3 Y4 G1 G4 B1 R2 B2 B3 +``` + +### Example interaction + +| First player input | First player output | Second player input | Second player output | Log output | +| ------------------------------------ | ------------------------------------- | ------------------------------------ | -------------------------------------- | ----------------------------------------------- | +| `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` |

    (Took 70ms)

    `PUT a1+ R1`

    | | | | +| `GET B3` | | `OPP a1+ R1 B3 70` | | `FIRST a1+ R1 B3 70` | +| | | `TIME 10000 9930` |

    (Took 40ms)

    `PUT a2- R1`

    | | +| `OPP a2- R1 R1 40` | | `GET R1` | | `SECOND a2- R1 R1 40` | +| `TIME 9930 9960` |

    (Took 80ms)

    `PUT a2+ B1`

    | | | | +| `GET Y2` | | `OPP a2+ B1 Y2 80` | | `FIRST a2+ B1 Y2 80` | +| | | `TIME 9960 9850` |

    (Took 50ms)

    `PUT b1- R3`

    | | +| `OPP b1- R3 Y1 50` | | `GET Y1` | | `SECOND b1- R3 Y1 50` | +| | | (Omitted) | | | +| | | `TIME 980 1730` |

    (Took 100ms)

    `PUT f4+ Y1`

    | | +| `OPP f4+ Y1 X0 100` | | `GET X0` | | `SECOND f4+ Y1 X0 100` | +| `FINISH` | (Terminate program) | `FINISH` | (Terminate program) |

    `FINISH`

    | +| | | | |

    `SCOREFIRST 314`

    `SCORESECOND 270`

    | 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..cde6fbce --- /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 + +## Contest overview + +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 + +The top 20 (or more) teams 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 (1048576 bytes) or less, and the binary file must be 10MiB (10485760 bytes) or less. +- Grading with 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. + - Inputs are fixed. + - The Sample AI uses the same strategy for the same input. +- Programs 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 (second last) 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 'Compilation 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 time limit written in the problem. It may occur if an error happens during an 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 have received 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 abnormal 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 + +**Pretest** + +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 + +**Pretest** + +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`. + +> Pretests are for reference only and do not affect the final evaluation. + +**System test** + +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 + +**Pretest** + +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`. + +> Pretests are for reference only and do not affect the final evaluation. + +**System test** + +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 unsure 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..66b35182 --- /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 Roll of the Dice skill, they 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 skips **Scoring** phase, and the last, $13$th round skips 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 identically distributed 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. Each player take dice set based on following rules: + +- If the players choose different sets, each player takes their chosen set. +- If both players choose the same set, the player who submitted the higher bid score takes the chosen set. +- If both the chosen set and the bid score are identical, the winner is determined randomly. Every trial is independent and identical. + +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 hand (exception: 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{The total number of pips in five dice} \times \mathbf{1,000}$ **points** +- `FOUR_OF_A_KIND`: If there are $4$ or more dice of same value, $\textbf{The total number of pips in five dice} \times \mathbf{1,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `FULL_HOUSE`: If there are $3$ dice of same value plus other $2$ dice of same value, $\textbf{The total number of pips in five dice} \times \mathbf{1,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `SMALL_STRAIGHT`: If there are $4$ dice which form a consecutive sequence ($1234, 2345, \text{ or } 3456$), $\mathbf{15,000}$ **points**. Otherwise, $\mathbf{0}$ **points**. +- `LARGE_STRAIGHT`: If all $5$ dice form a consecutive 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, the game ends with draw. + +- $\text{Player's Total Score} = \text{Points from Basic Rules} + \text{Points from Combination Rules} + \text{Bidding Points}$ + +## Input/Output Format + +Your program must read input line by line and follow the protocol of each command. Commands requiring the output are denoted with red color with their **time limit** specified. If your program fails to output within specified time limit, you will receive Time Limit Exceeded (TLE) verdict and will result forfeiting the game. + +| Command | Input Format | Description | +| :------ | :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| READY | `READY` | Must output OK within **3 seconds** as a response. | +| 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 corresponds 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 corresponds 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` | Indicates the end of the game. The program must terminate properly and immediately, regardless of the current status of the game. Output is not required. | + +All commands must be processed line by line. When you output, make sure you print a newline character and then flush the buffer. Please refer to the reference document or sample code of your programming 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 uses following strategy: + +- 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 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 immediate 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 immediate 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 contest. + +## Testing Tool (GUI) + +A testing tool, `testing-tool-yacht`, is provided to test the program. You can test your compiled executable or script locally, using `python`, `java`, `node`, or `lua` in your envinroment. + +- 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 provided to test the program. For details, refer to the `README.md` inside the zip file. + +You can freely 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. + +You will receive log files having same format with testing tool, in the submission result dialogue. However, actual grading program is implemented differently from the testing tool, a successful execution in the testing tool does not always guarantee a successful execution in the actual grading. + +## Visualization Tools + +- + [Game Simulator] + +- + [Play by Yourself] + +- + [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..0f9157db --- /dev/null +++ b/src/routes/en/2025-codebattle/online_p.mdx @@ -0,0 +1,211 @@ +--- +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 grid together as usual. +One day, they discovered that every mushroom had a digit written on it, so they decided to create a new game using these digits. +They made a game where they compete to own parts of the mushroom grid, alternating turns using following rules. + +### Game Rules + +- **Rule 1** + On their turn, a player selects a single rectangular area in the mushroom grid. + +- **Rule 2** + If the sum of the digits within the selected area is exactly $10$, the mushrooms in that area are removed and the player owns that area. + If the area contains cells already owned 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 **inscribed** to the rectangular area. + +- **Rule 3** + If no areas can be selected or 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 owns more cells at the end of the game wins. + +Become a Yeti or Pink Bean and own as many cells as possible in the mushroom grid by writing a program. + +## Input/Output Protocol + +Your program must read input line by line and follow the protocol of each command. Commands requiring the output are denoted with red color with their **time limit** specified. If your program fails to output within specified time limit, you will receive Time Limit Exceeded (TLE) verdict and will result forfeiting the game. + +| Command | Input Format | Description | +| ------- | ----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| READY | `READY (FIRST\|SECOND)` | Indicates whether your program takes first or second player. Must output OK within 3 seconds as a response. | +| INIT | `INIT ...` | Indicates the game board information. `...` consists of $10$ strings, each consisting of $17$ digits.
    Each digit is an integer between $1$ and $9$ inclusive, representing the number on the mushroom at corresponding position. Output is not required
    Each digit is drawn independent and identically from digits $1$ through $9$. | +| TIME | `TIME t₁ t₂` | Indicates it is your program's turn. Also provides remaining time for both players; $t_1$ is yours, $t_2$ is the opponent's (in ms).
    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 $t_1, t_2$ is given as $10\,000$ms, regardless of time used for `READY` command. | +| OPP | `OPP x₁ y₁ x₂ y₂ t` | Indiciates the coordinates $r_1$ $c_1$ $r_2$ $c_2$ selected by the opponent, while taking $t$ ms during their turn.
    If the opponent passed, $r_1 = c_1 = r_2 = c_2 = -1$ is given. Output is not required. | +| FINISH | `FINISH` | Indicates the end of the game. The program must terminate properly and immediately, regardless of the current status of the game. Output is not required. | + +All commands must be processed line by line. When you output, make sure you print a newline character and then flush the buffer. Please refer to the reference document or sample code of your programming 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/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, i.e. the top-left rectangle. 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 | Uses the same strategy as provided in the sample code. | +| 5 / 6 | Uses the strategy of the game simulator sample AI, Pink Bean. | +| 7 / 8 | Uses a medium-level defensive strategy. | +| 9 / 10 | Uses a medium-level offensive strategy. | +| 11 / 12 | Uses a high-level defensive strategy. | +| 13 / 14 | Uses a high-level 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 the program. You can test your compiled executable or script locally, using `python`, `java`, `node`, or `lua` in your envinroment. + +- 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)) + - Double-click the `.dmg` file, then drag and drop the `testing-tool-mushroom` 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". +- 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 CLI 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 the program. The testing tool is a program written in Python 3.12. Regarding the execution of this program, please refer to [Python Setup and Usage]. + +You can freely 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. + +You will receive log files having same format with testing tool, in the submission result dialogue. However, actual grading program is implemented differently from the testing tool, a successful execution in the testing tool does not always guarantee a successful execution in the actual grading. + +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. +- `