Each question you read will present a different interesting problem for you to solve. Each problem consists of a few common parts:
Let's look at Vases from AIO 2019 as an exaple. See if you can spot all the sections described above. Then give the problem a shot! There are some templates provided below to help you get started. Feel free to use them if you're not comfortable with reading/writing files. Click on the hint if you're stuck coming up with a solution.
/*
* Solution Template for Vases
*
* Australian Informatics Olympiad 2019
*
* This file is provided to assist with reading and writing of the input
* files for the problem. You may modify this file however you wish, or
* you may choose not to use this file at all.
*/
#include <cstdio>
/* N is the number of flowers. */
int N;
int a;
int b;
int c;
int main(void) {
/* Open the input and output files. */
FILE *input_file = fopen("vasesin.txt", "r");
FILE *output_file = fopen("vasesout.txt", "w");
/* Read the value of N from the input file. */
fscanf(input_file, "%d", &N);
/*
* TODO: This is where you should compute your solution. Store the number
* of flowers that should go in the first, second and third jars in the
* variables a, b and c. If it is impossible to arrange the flowers
* according to the rules, set each of these variables to 0.
*/
/* Write the answer to the output file. */
fprintf(output_file, "%d %d %d\n", a, b, c);
/* Finally, close the input/output files. */
fclose(input_file);
fclose(output_file);
return 0;
}
import sys
sys.setrecursionlimit(1000000000)
#
# Solution Template for Vases
#
# Australian Informatics Olympiad 2019
#
# This file is provided to assist with reading and writing of the input
# files for the problem. You may modify this file however you wish, or
# you may choose not to use this file at all.
#
# N is the number of flowers.
N = None
a = None
b = None
c = None
# Open the input and output files.
input_file = open("vasesin.txt", "r")
output_file = open("vasesout.txt", "w")
# Read the value of N from the input file.
N = int(input_file.readline().strip())
# TODO: This is where you should compute your solution. Store the number of
# flowers that should go in the first, second and third jars in the variables
# a, b and c. If it is impossible to arrange the flowers according to the
# rules, set each of these variables to 0.
# Write the answer to the output file.
output_file.write("%d %d %d\n" % (a, b, c))
# Finally, close the input/output files.
input_file.close()
output_file.close()