How co-op problems work
What happens to the players' code, what every box in the admin editor is for, and how to explain it to students. Every example uses the problem สร้างบ้านง่าย ๆ.
One program, two players
In a co-op problem, the two players write one C program together. Player 1 writes the top half, and Player 2 writes the bottom half. The server glues them together into one main.c: Player 1's code, then Player 2's code directly after it.
So Player 2 carries on inside the same main() and can use every variable Player 1 made. That's why the Player 2 editor says main.c (continued) and its line numbers carry on from Player 1's.
#include <stdio.h>int main(void) { int w, l, h, f, n; scanf("%d %d %d %d", &w, &l, &h, &f); n = 2 * (w * l + w * h + l * h) * 9;
int per = f + 1; printf("%d\n", (n + per - 1) / per); return 0;}
The hand-off is what Player 1 leaves for Player 2. Here it is n (Gold Ingots needed) and f (the Fortune level). Deciding the hand-off is the most important part of designing a co-op problem.
The three test sets
When a team presses Submit, the server builds and tests three different programs, each with its own hidden tests. Pick one to see what is compiled:
Why three sets?
So one strong student can't carry the team. If Player 1 writes everything, including the printf, the team test may pass. But Player 1's own test adds the Test ending after their code, so that output is printed twice and compiling may fail, and Player 2's test runs an empty part. Each player's own tests only pass when each player did their own job.
Results and points
Students never see the hidden inputs or outputs. They get one symbol per test, for example PPPF-PPPPP.
| Mark | Meaning | Usual cause |
|---|---|---|
| P | Passed | Output matches. |
| F | Wrong answer | Wrong formula, forgot to round up, extra text printed. |
| - | No output | Nothing printed. Often Player 2's part is empty. |
| C | Compile error | Typo, undeclared variable, the two halves don't fit together. |
| T | Time limit | Too slow or an endless loop. |
| X | Crashed | Divide by zero, bad array index, scanf without &. |
| E | Error exit | main returned something other than 0. |
| O | Output too long | Printing in an endless loop. |
| S | Skipped | Judging ran out of time; the rest weren't run. |
Spaces at the end of lines and blank lines at the very end don't matter. Everything else must match exactly.
A mission is cleared only when all three sets pass every test. If the team tests pass but a player's own tests don't, the result says so: "but a player's own tests failed".
| Difficulty | Points |
|---|---|
| ☆ 0 (example) | 0 |
| ★ 1 | 5 |
| ★★ 2 | 20 |
| ★★★ 3 | 30 |
| ★★★★ 4 | 60 |
| ★★★★★ 5 | 120 |
| 6 | 200 |
| Special | 50 first clan, 20 after (full clear only) |
Points, money, progress, hints and the code being written are shared by the whole clan. Every point earned also gives 1 money. A mission that is only partly passed still gives points: the mission's points × the share of hidden tests passed in the clan's best Submit, rounded down. Every test counts the same (team tests and each player's own tests). Submitting again only adds points if it beats the best Submit.
On the map, each co-op mission shows [T] [1] [2]: the team tests, Player 1's tests and Player 2's tests. Grey = not submitted yet, red = not all passed yet, green = all passed (it stays green).
Each clan has 3 hints in total for the whole game. A problem can have a main hint plus one for each player. Once a hint is opened, everyone in the clan can read it.
สร้างบ้านง่าย ๆ is difficulty 2, so clearing it is worth 20 points. Passing 13 of its 20 hidden tests gives 20 × 13 ÷ 20 = 13 points.
Every admin box, and who sees it
The editor has three tabs: Global (the whole problem), Player 1 and Player 2. The same tabs appear on the student's problem sheet.
| Box | Seen by | What it does | In สร้างบ้านง่าย ๆ |
|---|---|---|---|
| Statement, Input, Output, Constraints | everyone | The problem sheet: the story and the rules for the whole program. | The house story, 4 input lines, "the fewest Gold Ore". |
| Examples (Global) | everyone | Shown on the sheet and loaded into Run examples, so students can run them on the team program. | 1 1 1 1 → 27, 6 7 6 2 → 720, 1 2 3 3 → 50 |
| Player task, output, examples | that player's tab | Explains one player's job. These examples are display only, never run, so you can write them however reads best. | Player 2: n = 198, f = 3 → 50 |
| Starter code | that player | What the player's editor starts with. #include lines at the top are locked. | Player 1 gets int w, l, h, f, n; already declared. |
| Your solution | admin only | Your finished answer for that player's part. Used by Test, Check with my solution and Fill outputs. | The full code in section 1. |
| Test ending (Player 1 tab) | admin only | Added after Player 1's code in Player 1's tests. Prints the hand-off, then closes main(). | printf("%d\n", n); return 0; } |
| Test start (Player 2 tab) | admin only | Added before Player 2's code in Player 2's tests. A correct copy of Player 1's part. | Declares the variables, reads input, sets n. |
| Hidden tests (Team, P1, P2) | admin only | The real judging. Up to 100 per set. Inputs always look like the real program input. | 10 per set. |
| Hints (main, P1, P2) | after a clan spends a hint | Opened one at a time from the clan's 3 hints. | None yet. |
Setting up a co-op problem
Do it in this order. Each step depends on the one before.
Write the story and solve it yourself
Global tab: statement, input, output, constraints, examples. Work an example out by hand before anything else, e.g.
1 1 1 1: 6 blocks → 54 ingots → 27 ores.Choose where to cut, and the hand-off
Pick a point in the solution where the work splits fairly, and decide exactly which variables cross it. Write their names into both player tasks. Here: Player 1 leaves
nandf.Write the starter code
Player 1 starts with
#include,int main(void) {and the hand-off variables declared. Player 2's starter ends withreturn 0;and}. Declaring the hand-off in the starter means nobody can misspell it.Write your solution for both players
Click Start from the starter code, then finish it like a good student would.
Write the Test ending (Player 1)
Print every hand-off variable, then close
main(). Click Test under your Player 1 solution to compile them together.Test endingruns after Player 1printf("%d\n", n); return 0;}
Write the Test start (Player 2)
A correct Player 1 part: includes,
main, the same declarations, reading input, the hand-off set. It must end exactly where Player 1 would end. Click Test under your Player 2 solution.Test startruns before Player 2#include <stdio.h>int main(void) { int w, l, h, f, n; scanf("%d %d %d %d", &w, &l, &h, &f); n = 2 * (w * l + w * h + l * h) * 9;
Add hidden test inputs to all three sets
Only the inputs, in the real input format (all 4 lines, even for Player 2's set). Cover the smallest and biggest values, every case (each Fortune level), and the tricky one (rounding up).
Fill outputs from my solution
The server runs your solutions and writes the expected outputs for you. No typing answers by hand.
Check with my solution
Runs your code against all three sets. Every set should say it passes all tests. If not, the details show the input, expected output and what your code printed.
Play it as a clan
Log in on the map as one of the clan's students (Admin → Clans lists who is in each clan), open the problem and submit. Use Reset on that clan afterwards so the test doesn't count.
Rules that keep it working
- Test ending: print(...) instead of printf(...)A typo in a Test piece breaks every student's tests with C, even correct code. Always press Test after editing one.
- error: 'r' undeclaredCode may only use variables that the code above it declared. Player 2 can use what Player 1 declared, but anything new, Player 2 declares in their own part.
- error: redefinition of 'per'The Test start must declare the hand-off and nothing more. If it also declares a helper variable that Player 2 is likely to declare, Player 2's correct code won't compile.
- Team passes, Player 1 failsPlayer 1's tests feed the full input, so Player 1 must read all of it, including values only Player 2 uses (here
f). - Examples break the constraintsEvery example and hidden test must obey the constraints you wrote (the old
15 4 11 1brokew ≤ l). - Rounding cases missingIf a common mistake still passes every test, add a test that catches it. Here: Fortune III with an odd total, where
n / 4isn't whole.
Teaching students
Students don't need to know about Test pieces. They need to know four things: you share one program, agree on the hand-off, do only your own half, and each half is tested on its own.
A 5-minute explanation you can give
- "You and your partner write one C program. Player 1 writes the start, Player 2 writes the rest. The computer joins them, so Player 2's first line comes right after Player 1's last line."
- "Read the Global tab together first. Then each of you reads your own tab, Player 1 or Player 2. It says exactly what you must do and which variables you hand over."
- "Agree on the hand-off before typing. In this problem, Player 1 must leave the number of ingots in
n, and the Fortune level inf. Use these exact names." - "Press Run examples to try the whole program on the examples. You can add your own inputs there too."
- "Submit tests the team program and each of your halves separately. If one player does both halves, the other half's tests fail. So each of you writes your own part."
- "You get one letter per test. P is good. C means it doesn't compile. F means a wrong answer. Fix it and submit again. Hints are shared by the clan, and you only get 3, so use them carefully."
Try it live with the class
Log in as a student, open สร้างบ้านง่าย ๆ and submit Player 2's first idea, printf("%d\n", n / (f + 1));. Show the F marks, then ask the class: "Why is 49 ores not enough for 198 ingots with Fortune III?" Then fix it together and submit again.