C Practice How co-op problems work ⚙ Admin
Guide for admins and teachers

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 สร้างบ้านง่าย ๆ.

1

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.

Player 1 writes
#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;
Player 2 writes
    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.

2

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.

3

Results and points

Students never see the hidden inputs or outputs. They get one symbol per test, for example PPPF-PPPPP.

MarkMeaningUsual cause
PPassedOutput matches.
FWrong answerWrong formula, forgot to round up, extra text printed.
-No outputNothing printed. Often Player 2's part is empty.
CCompile errorTypo, undeclared variable, the two halves don't fit together.
TTime limitToo slow or an endless loop.
XCrashedDivide by zero, bad array index, scanf without &.
EError exitmain returned something other than 0.
OOutput too longPrinting in an endless loop.
SSkippedJudging 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".

DifficultyPoints
☆ 0 (example)0
★ 15
★★ 220
★★★ 330
★★★★ 460
★★★★★ 5120
6200
Special50 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.

4

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.

BoxSeen byWhat it doesIn สร้างบ้านง่าย ๆ
Statement, Input, Output, ConstraintseveryoneThe problem sheet: the story and the rules for the whole program.The house story, 4 input lines, "the fewest Gold Ore".
Examples (Global)everyoneShown 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, examplesthat player's tabExplains 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 codethat playerWhat 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 solutionadmin onlyYour 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 onlyAdded 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 onlyAdded 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 onlyThe 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 hintOpened one at a time from the clan's 3 hints.None yet.
5

Setting up a co-op problem

Do it in this order. Each step depends on the one before.

  1. 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.

  2. 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 n and f.

  3. Write the starter code

    Player 1 starts with #include, int main(void) { and the hand-off variables declared. Player 2's starter ends with return 0; and }. Declaring the hand-off in the starter means nobody can misspell it.

  4. Write your solution for both players

    Click Start from the starter code, then finish it like a good student would.

  5. 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 1
        printf("%d\n", n);    return 0;}
  6. 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;
  7. 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).

  8. Fill outputs from my solution

    The server runs your solutions and writes the expected outputs for you. No typing answers by hand.

  9. 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.

  10. 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.

6

Rules that keep it working

7

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

  1. "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."
  2. "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."
  3. "Agree on the hand-off before typing. In this problem, Player 1 must leave the number of ingots in n, and the Fortune level in f. Use these exact names."
  4. "Press Run examples to try the whole program on the examples. You can add your own inputs there too."
  5. "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."
  6. "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.