Why this matters when you build with AI
AI tools make it easy to paste a problem statement into a chat window and get code back in seconds. Many contests ban this, and some ban any outside help while the timer runs. The penalty for breaking a rule is set by each contest and site, so read it before you enter. Even when nobody catches you, you lose the thing you came to get: the ability to solve the next problem alone.
There is a second cost that is easy to miss. An AI tool gives wrong answers with the same confidence as right ones. In a contest, you cannot know which answer is wrong without working the problem yourself. If you use AI to skip the thinking, you may submit code you do not understand, get a wrong verdict, and have no idea why. Practice on your own is the only way to build the habit of checking an idea before you code it.
This lesson is about rules and about the skill cost. It does not explain how to hide anything. It explains how to read the rules, sort what you plan to do, and make a checklist before the start.
A contest rule is a written statement by the organiser that says what a competitor may and may not do during the contest. The rules differ between contests. Some allow printed notes, some allow a personal template file, some allow documentation pages, and some ban everything except a compiler. The rules of the specific contest you enter are the only ones that count. Anything written in this lesson about typical rules is a starting point, not a verdict on any contest.
A template is code you write before a contest and keep in a file. It usually holds fast input and output, common type aliases, and standard helper functions. Whether you may open a template during a contest depends on the contest rules.
A verdict is the judge's answer to a submission, such as accepted or wrong answer. A judge is the program that runs your code against test inputs.
This lesson uses C++17 for the worked example and Python for the rule classifier. We compiled with g++ 15.2.0 on Ubuntu and ran Python 3.14. The output of the classifier does not depend on the machine.
The idea: read the rules, then sort your actions
Before you enter a contest, do three things in order.
-
Read the full rules. Find the section on outside help, on materials, on accounts, and on tools. Read the penalties too. Note any rule that names a tool or a source. If a rule is unclear, write the question down and ask the organiser before the start, not during the contest.
-
List what you plan to do. Write each action you expect to take, in plain words: "open my template file", "read the language's standard library page", "ask a friend to look at my code", "use an AI assistant to explain an error". Include the small actions, such as opening a second browser window to test something.
-
Sort each action. Put each one under allowed, banned, or unclear. If it is unclear, treat it as banned until the rules say otherwise.
The sort is a rule that you apply, not a feeling. An action is allowed only if the rules say it is, or if the rules do not forbid it and you can name the rule that covers it. When you cannot name a rule, the honest answer is that you do not know.
What contests usually allow
Most contests allow the following, but each contest decides for itself:
- Code you wrote and saved before the contest, such as a personal template with input routines and standard helpers, if the rules allow outside files.
- Printed or handwritten notes, if the rules allow them.
- Documentation for the language and its standard library, where the rules say that documentation is permitted.
What contests usually ban
These actions break rules in nearly every contest. Check each contest's wording:
- Sharing solutions, hints about a specific problem, or code with anyone during the contest.
- Copying a solution from a public post, a blog, or a previous contest's editorial, then submitting it as your own.
- Using a second account to test your code, look at a judge, or submit for someone else.
- Getting help from another person while the timer runs, unless the contest is a team contest and the rules allow it.
- Using an AI assistant to write or fix code, where the contest bans it.
Some contests allow AI tools, and some name a specific list of tools. Read the rule for the contest you enter. Do not assume that a tool you use in practice is allowed in a timed contest.
Why the rules exist
Contests test your ability to solve a problem in a fixed time. A solution that another person wrote, or a model wrote, does not show your ability. Organisers also need to keep the scores fair. A person who gets help while the timer runs gets a score that others did not earn. That is the reason most of these rules exist, and it is the reason to follow them even when you think nobody would notice.
The skill cost is the other reason. If you copy an answer, you do not practise the step where you find the idea. That step is what the contest measures, and it is what gets better with practice. A copied answer gives you a score today and leaves you unable to solve the next problem tomorrow.
Worked example: classify three scenarios against a sample rule set
The classifier below is a sample. It is not the rule text of any real contest. Its job is to show the method: a table of actions, a list of scenarios, and a check that stops at the first banned action.
We ran it with Python 3.14. The output is:
Scenario A: banned: use an AI assistant to write or fix code
Scenario B: banned: ask a friend for a hint on a problem
Scenario C: allowedThe method has two parts. First, each action maps to one verdict. Second, a scenario is allowed only if every action in it is allowed. The program stops at the first banned action and names it, which is what you want to see when you check your own plan.
The sample rule set has an entry for an AI assistant that is banned, and a separate entry for one that the contest names as allowed. This split is there because real rules often name specific tools. Your rule set must follow the wording of your contest, not a general idea of what is fair.
Why the program is short but the reasoning is not
The program can only check the actions you give it. The hard part is deciding what an action is. "Ask an AI assistant to explain the statement" and "ask an AI assistant to write the code" may fall under different rules. Some contests ban both. Others allow one. When the rule is unclear, write the action down and ask the organiser. Do not guess.
The program also cannot read a rule for you. If you paste rule text into a chat assistant and ask for a classification, the assistant may quote a rule that is not in the text, or describe a rule from a different contest. Check every quoted rule against the original page before you rely on it.
The three scenarios
Use these scenarios in the exercise below. They are invented for this lesson.
- Scenario A. You have a template file you wrote last month. During the contest, your code fails one test. You open a chat assistant and paste your code, asking it to find the bug.
- Scenario B. You are stuck on a problem. A friend who is not in the contest messages you a hint about which data structure to use.
- Scenario C. You open your template file, which you wrote before the contest. You read an offline reference that the contest rules name as allowed. You use an AI tool that the rules name as allowed, to check a formula's edge case.
Run the classifier on the sample rules. Then check the answer against the sample rule text above, which you can read on your own.
Hands-on exercise: write your pre-contest checklist
Do this on your own machine, without any help during the exercise, in about 30 minutes.
- Find the rules of a contest you plan to enter. If you have none yet, use a practice contest's rules page and note that it is practice. Copy the three sections on outside help, materials and tools into a notes file.
- Write a list of at least ten actions you expect to take during a contest. Include small ones.
- Sort each action into allowed, banned or unclear, using the rule text from step 1. Mark anything you cannot find a rule for as unclear.
- Put each unclear action into a question for the organiser, and note where you would ask it.
- Write a pre-contest checklist with at most ten lines. Each line is a check you can do in under a minute.
- Optionally, paste the rule text into an AI assistant and ask it to classify your list. Use the prompt below. Compare its answer with yours line by line, and check every quoted rule against the original page.
Here is the rules section of a programming contest. Read it and do not use any other source.
For each action in my list, answer allowed, banned or unclear, and quote the exact sentence from the rules that decides it.
If no sentence decides it, answer unclear. Do not guess.
Rules:
[paste the rules section here]
My actions:
- open my saved template file
- read the language's standard library page
- use an AI assistant to explain an error message
- ask a friend what data structure to useA good answer quotes a sentence for every allowed or banned verdict, and marks some actions unclear when the rules do not cover them. It does not invent rule numbers or rule names. Check the quotes against the rules page by searching for the words in the quote. If a quote is not there, the answer is wrong, and you should not use it.
A good pre-contest checklist is short. An example:
Before the start:
1. I have read the rules section on outside help, materials and tools.
2. Every tool I plan to open is named as allowed, or the rules are silent and I have asked.
3. My template file is saved and I know whether the rules allow it.
4. I have written down the questions I still have, and sent them to the organiser.
5. My phone is set to silent and I know where my notes are, if notes are allowed.
6. I have no open chat with another person about the contest.
7. I will not post or read any solution while the contest runs.
8. If I am unsure about an action, I will treat it as banned.
9. After the contest I will note which actions I took, for my own review.
10. I will upsolve problems I did not solve, without looking at a solution first.Your checklist should reflect your own contest's rules, not this example.
Show the answer
For the sample rule set, the classifier output in this lesson is the answer:
Scenario A: banned: use an AI assistant to write or fix code
Scenario B: banned: ask a friend for a hint on a problem
Scenario C: allowedFor your own checklist, there is no single answer. A sign that a checklist is wrong: it has a line that says "use AI if it helps" without a rule that allows it, or it has no way to check each line before the start.
Worked example: a template that stays in your file
A template is useful because it saves typing. The code below is a worked example that uses a simple fast input pattern. The task is original: given n integers, count the pairs of positions i < j where a_i + a_j is even. A pair has an even sum exactly when the two numbers have the same parity. Parity means whether a number is even or odd, and it works for negative numbers too.
Example input:
5
1 2 3 4 -5The odd numbers are 1, 3 and -5, which is 3 numbers. The even numbers are 2 and 4, which is 2 numbers. Pairs of odd numbers: 3 choose 2, which is 3. Pairs of even numbers: 2 choose 2, which is 1. The total is 4.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
long long even = 0, odd = 0;
for (int i = 0; i < n; i++) {
long long x;
cin >> x;
// Parity that also works for negative numbers.
if (((x % 2) + 2) % 2 == 0) even++;
else odd++;
}
// Two numbers have an even sum exactly when they have the same parity.
long long pairs = even * (even - 1) / 2 + odd * (odd - 1) / 2;
cout << pairs << "\n";
return 0;
}We compiled it with g++ -std=c++17 -O2 -Wall -Wextra and got no warnings. On the example it printed:
4The brute force is a Python loop over every pair:
import sys
def main():
data = sys.stdin.read().split()
n = int(data[0])
a = [int(x) for x in data[1:1 + n]]
count = 0
for i in range(n):
for j in range(i + 1, n):
if (a[i] + a[j]) % 2 == 0:
count += 1
print(count)
if __name__ == "__main__":
main()We wrote a generator for random inputs of 1 to 40 numbers, each between -1000 and 1000, and ran both programs on seeds 1 to 500. The C++ output matched the brute force on all 500 inputs. This tests negative numbers and small arrays. It does not test the largest inputs, so check the time on a large array before you rely on it.
The lesson for rules is in where the code came from. The template this program uses, with the fast input lines and the using namespace std line, is code you can write and save before any contest. Whether you may open that file during a contest is a rule question, not a coding question. Read your contest's rules before you rely on it. The fast input and output pattern itself is covered in the contest setup lessons, and this lesson does not repeat it.
Complexity
Reading the array takes O(n) time and O(1) extra memory. The brute force takes O(n^2) time, which is why it is only a check on small inputs.
Typical pitfalls
- Overflow in the pair count. With
nnear 200000, the count can reach about 2 times 10^10, which does not fit in a 32-bit integer. The code useslong longfor that reason. - Parity of negative numbers. In C++,
x % 2can be -1 for a negative odd number. The line((x % 2) + 2) % 2returns 0 or 1 for all inputs. - Pasting code from a saved file into a contest without checking the rules. The template may be allowed, but the rule text decides. Check it before the start.
Practice problems
Problem 1. Scenario D is this: you use your saved template, you share your code with a teammate during the contest, and you copy a solution from a public post. Classify it with the sample rule set.
Hint: the classifier stops at the first banned action, so check which one it reaches first.
Show the answer
The output is Scenario D: banned: share code with anyone during the contest. The first banned action in the list is the sharing, so that is the one the program names. The copied solution is also banned, and a real verdict would count both.
Problem 2. Change classify so that it lists every banned action in a scenario, not only the first. Run it on Scenario D. What does the output look like?
Hint: collect the banned actions in a list and join them with ; .
Show the answer
The output is:
Scenario D: banned: share code with anyone during the contest; banned: copy a solution from a public postScenario A still shows only the AI action, because it has one banned action.
Problem 3. Change the worked example so that it counts pairs with an odd sum instead of an even sum. Run it on the sample 5 and 1 2 3 4 -5.
Hint: an odd sum needs one odd number and one even number, so the count is the number of evens times the number of odds.
Show the answer
The output is 6. The sample has 3 odd numbers and 2 even numbers, and 2 times 3 is 6. The brute force gives the same number if you change its test to % 2 == 1. We ran the changed C++ program and got 6 on the sample.
Common mistakes
Treating what you do in practice as allowed in a contest. A tool that you use in practice may be banned during a timed round. Read the rules for each contest.
Trusting an AI answer about the rules. A model can invent a rule number or quote a rule that does not exist. Check every quote against the original page.
Thinking nobody will notice. Most checks happen after the contest, and the skill cost is paid no matter what anyone detects. The code you copy does not make you better at the next problem.
Asking a friend for a hint during the contest. A hint on one problem is help on that problem. Treat it as banned unless the rules say otherwise.
Leaving the rules unread until the start. Read the rules a few days before the contest, so you have time to ask questions.
Checklist
- Read the full rules of the contest before you enter, including penalties.
- List every action you plan to take, including small ones such as opening a file.
- Sort each action into allowed, banned or unclear. Treat unclear as banned until you have an answer.
- Ask the organiser about any unclear action before the start.
- Write your pre-contest checklist and keep it short enough to read in one minute.
- Check any AI answer about the rules against the original text.
- After the contest, upsolve the problems you did not solve, without reading a solution first.
Summary
Contest rules decide what you may do during a timed round, and they differ between contests. Sort each action you plan to take against the rules of the contest you enter. Treat anything unclear as banned, and ask the organiser before the start. The skill you build by solving alone is the part of the contest that lasts.