This Summer of Making, I dedicated my time, effort, and mind to this ongoing Competitive Coding Catalog!

L👀k... See... Everything is more than it seems......

Olivia's Competitive Coding Catalog

WELCOME!

This is my coding catalog: an inventory of all the programming problems I have solved with Java to this moment! Before I continue, you must first understand what competitive programming is in order to comprehend the work, effort, and time I invested into this Summer of Making project. Scroll down!

Competitive Programming

As its name suggests, competitive programming is an intellectual "sport" which requires participants to code algorithmic programs with a high-level programming language (e.g. Python, Java, and C++) to solve problems.

These problems often consist of a story and a specification for number value restrictions, time and memory limit, as well as input and output formats.

To successfully solve the problem, competitive programmers utilize their mathematical background knowledge and combine logical thinking, problem solving, and programming skills to code an algorithmic program which instructs the computer to follow a set of instructions to read input and output the calculated result.

In order to translate this source code into language that a computer's CPU can understand and execute, a compiler is often used and provided within IDEs.

You may recognize this IDE that I use: Visual Studio Code, which is paired with a C++ compiler. However, since I code using Java, I had to download javac, the official Java compiler that performs according to your code and specifies any compilation errors (e.g. syntax errors)

My Journey

Over the course of 4 months, I developed my competitive programming skills by enrolling in several courses and employing my newfound knowledge into solving countless coding problems on DMOJ, USACO, and VJudge.

From the basics: scanning, printing, and data types; to advanced topics: PSA, Recursion, and Binary Trees; my learning skyrocketed this summer. However, believe it or not, this is only the beginning of my courses and coding journey!

This Webpage

I created this website as, not only a showcase of my extensive work, but also to be your guiding light for your journey in competitive programming.

I hope that this webpage will inspire you to become a competitive programmer, inform you on one of the careers available in the world, or just encourage you to learn to code in any aspect (perhaps even building a website like this, of your own!).

Now, you've already taken your first step: you've learned about what competitive programming is, so continue on your journey and scroll down to learn about input and output!

Input

In Java, you need to type

import java.util.scanner;

at the top to import the scanner, which scans input.

For integers, you can type

int N = in.nextInt();

This will set N to the next integer that is inputted.

Output

In contrast to inputting, java has a built-in function to output results

To print out an integer, you can type

System.out.print(N);

where N is an integer.

If you would like to print out a space before an integer, you can type:

System.out.print(" " + N)

again, where N is an integer.

Note

Although I originally planned to display all my solutions to the problems I solved, I have

133

solutions, which is A LOT!

Thus, I will only display a couple of my Java solutions in the box below.

For the rest, you should visit my github link, go into /src/Problems, and click on the .java files that are named with DMOJ or USACO problem names!

If you have any problems with submitting my submissions on DMOJ or USACO, please don't hesitate to message me on slack (@Olivia Pu)!

To learn more, you can always read the free Think Java book and practice your skills by solving the problems on the websites above!

The Lost Cow


                    import java.util.*;
                    import java.io.*;
                    import java.lang.Math;
                    
                    public class The_Lost_Cow {
                        public static void main(String[] args) throws IOException {        
                            Scanner in = new Scanner(new File("lostcow.in"));
                            PrintWriter pw = new PrintWriter("lostcow.out");
                            int x = in.nextInt();
                            int y = in.nextInt();
                            int distanceFromInitial = 1;
                            int previousPosition = x;
                            int steps = 0;
                            boolean gotCow = false;
                            while (!gotCow) {
                                int newPosition = x + distanceFromInitial;
                                // if (newPosition < 0) {
                                //     newPosition = 0;
                                // }
                                // if (newPosition > 1000) {
                                //     newPosition = 1000;
                                // }
                                if ((x < y && newPosition >= y) || (x > y && newPosition <= y)) {
                                    steps += Math.abs(y - previousPosition);
                                    gotCow = true;
                                } else {
                                    steps += Math.abs(newPosition - previousPosition) ;
                                }
                                distanceFromInitial *= -2;
                                previousPosition = newPosition;
                            }
                            in.close();
                            pw.println(steps);
                            pw.close();
                        }
                    }
                    

DMOPC Scrambling Swaps


                    import java.io.*;
                    import java.util.StringTokenizer;


                    public class DMOPC_21_Contest_2_P2_Scrambling_Swaps {
                    public static void main(String[] args) throws IOException {
                        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
                        PrintWriter pw = new PrintWriter(System.out);


                        StringTokenizer st = new StringTokenizer(r.readLine());
                        int N = Integer.parseInt(st.nextToken());
                        int Q = Integer.parseInt(st.nextToken());
                        char command;
                        int storage;
                        int index1 = 0;
                        int index2 = 0;
                        int swap1 = 0;
                        int swap2 = 0;
                        int[] substitute = new int[N];
                        for (int i = 1; i < N + 1; i++) {
                            substitute[i - 1] = i;
                        }
                        int[] query = new int[N];
                        for (int i = 0; i < Q; i++) {
                            st = new StringTokenizer(r.readLine());
                            command = st.nextToken().charAt(0);
                            if (command == 'B') {
                                swap1 = Integer.parseInt(st.nextToken()) - 1;
                                swap2 = Integer.parseInt(st.nextToken()) - 1;
                                storage = substitute[swap1];
                                substitute[swap1] = substitute[swap2];
                                substitute[swap2] = storage;
                            } else if (command == 'E') {
                                swap1 = Integer.parseInt(st.nextToken());
                                swap2 = Integer.parseInt(st.nextToken());
                                for (int j = 0; j < N; j++) {
                                    if (substitute[j] == swap1) {
                                        index1 = j;
                                    } else if (substitute[j] == swap2) {
                                        index2 = j;
                                    }
                                }
                                substitute[index2] = swap1;
                                substitute[index1] = swap2;
                            } else {
                                for (int j = 0; j < N; j++) {
                                    query[j] = Integer.parseInt(st.nextToken());
                                }
                                pw.print(query[substitute[0]-1]);
                                for (int j = 1; j < N; j++) {
                                    pw.print(" " + query[substitute[j]-1]);
                                }
                                pw.println();
                            }
                        }
                        pw.close();
                    }
                    }
                    

Thank You!

I appreciate you taking your time to read my website and learn a little bit about competitive programming!

I hope you are inspired to continue your journey in coding or competitive programming now😃

Now, I would like to share one last thing with you: my dmoj account, where you can look at the problems I have solved and track my progress!

THANK YOU!