Introduction to the UVa Online Judge

Introduction to the UVa Online Judge

Written by on 2 May 2012

Topics: UVa Online Judge

UVa Online Judge is a website hosted by the University of Valladolid, Spain.

It has two main roles. First, it’s a problem archive with over 3500 programming problems. Second, you can upload your solution (the program source code) to one of the problems in the archive, and the online judge will determine whether it’s correct or not.

Your first solution

Let’s take a look at how you can submit your first solution on the UVa Online Judge.

  1. If you haven’t already, you should start off by registering, and then log in.
  2. Our first stop is the problem archive. Go to “Browse Problems”, located under “Online Judge” in the left menu.
  3. There are a number of folders. The top two folders are the main source of problems, but the folders below are mostly just better categorizations of the problems in the top two folders. For now, go to the top folder, “Problem Set Volumes”.
  4. And now we see even more folders. The problems are split into these folder, problems 100-199 are in “Volume I”, problems 200-299 are in “Volume II”, and so on… Let’s go to “Volume I”.
  5. Now we finally see some problems. We can also see some statistics for each problem. Let’s check out “100 – The 3n + 1 problem”.
  6. Here you can read the description for problem 100. When you’ve finished reading, head over to our coverage of UVa 100, and then implement your own solution.
  7. Now that we have a solution ready, let’s head over to “Quick Submit”, located under “Online Judge” in the left menu.
  8. Type in the Problem ID, which in this case is 100, and select the programming language you wrote your solution in. The UVa Online Judge only supports C, C++, Java and Pascal (we here at MathBlog will be using Java). Then either paste your source code in the text box below or upload the source file. Click Submit when you’re ready.
  9. Now you are taken to the “My Submissions” page (which can also be accessed through the left menu under “Online Judge”). There you will see a list of all your submissions, with your newest submission on the top. It most likely has the “In Queue” verdict at first, which means that your solution has not been judged yet. You can refresh the page until you get a verdict other than “In Queue”. If your verdict is “Accepted“, congratulations, you’ve solved your first problem at UVa Online Judge. If your verdict is something else, your solution is most likely wrong, so try again. Here is a list of verdicts you can get, along with their meaning.
  10. Now you can go back to “Browse Problems” and find, and solve, another problem.

If you’re having problems with submitting problems in your language of choice, take a look at the Submission specification for some guidelines and example source codes.

Correct solution?

So how does the judge figure out whether your solution is correct? Well, it starts off by compiling your program into an executable. If your solution doesn’t compile, the judge lets you know. Then he tests your program using various pairs of input/output files. The input files contain the problem data, the data that your program should read, and the output files contain what a correct solution should print out for the matching input file. It runs your compiled solution and feeds the input file into the standard input (the same as reading from the console) of the program, and redirects everything you print to the standard output (the same as writing to the console) into a separate file. It then compares your output file with the correct output file and if there are any differences (even the smallest whitespace), your solution is wrong. If the files are the same, your solution is correct. This type of input/output file comparison check is not true for a few problems, but they have a custom verification program that takes the input file and your output file, and determines if your output file is correct in a custom way.

Tools

Finding easy problems to solve can be hard if you blindly wander around the “Browse Problems” page. uHunt is a great tool to help you find the next problem to solve. For example, it can sort all of the UVa problems in a number of convenient ways and filter out the problems you’ve already solved.

Some problems have weird corner cases or are just very hard to crack. When this happens, you might want some more example test-cases. UVa Toolkit is a webpage that let’s you run your own custom input on a solution that has been judged as correct, for nearly 1500 UVa problems. It then returns the output that a correct solution should output.

Conclusion

This concludes the introduction to the UVa Online Judge. You might still have unanswered questions, but the best way to learn is to go and actually solve a couple of problems yourself. If you are still not sure about something, feel free to leave a comment.

Have any tips for us or the beginners out there? Leave a comment and let us know.

1 Comment For This Post I'd Love to Hear Yours!

  1. Matthew says:

    Is there any way to find out what the input was that the online judge used for your program? It’s a bit hard to find edge cases which don’t work if you don’t know what the input data was

Leave a Comment Here's Your Chance to Be Heard!

You can use these html tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

You can use short tags like: [code language="language"][/code]

The code tag supports the following languages: as3, bash, coldfusion, c, cpp, csharp, css, delphi, diff,erlang, groovy, javascript, java, javafx, perl, php, plain, powershell, python, ruby, scala, sql, tex, vb, xml

You can use [latex]your formula[/latex] if you want to format something using latex

This site uses cookies.