PA_Guide

advertisement
Summer 2015
Guide for Programming Assignments
page 1
Guide for Programming Assignments
A. General information
 Programming Assignment is an important part of this course. You will complete 2
assignments within the specified deadlines. An assignment usually consists of 3
problems.
 For each problem, you will need to write a program on C++ or Java to solve it.
 Your program will read input from standard input (console) and print results in the
required format to standard output (screen).
 Each problem will have constraints with different input sizes. Thus, you will need to
design/use appropriate algorithms and data structures to pass all the constraints.
 The memory limit for your program is 256M. Time limit is usually 1 - 2 seconds,
depending on each problem. Please check the time limit and other constraints in the
problem description.
 Your program will be judged by an automated online judge server (i.e. Mooshak). Thus,
your program is expected to be compiled with the same compiler of the online judge, as
following (Note: you can use IDEs that support newer compiler, as long as your program
is adaptable to these old compilers):
o For C++: g++ 4.4.7
o For Java: javac 1.6
 You will get full marks for a problem, if the program passed all test cases with
“Accepted” status given by the online judge. Partial mark will be given proportionally to
the number of test cases that your program passed.
 What you need for programming assignments:
 NUSNET account to login into Lab machine (if you want to use Lab machine to write
code). You also can code in your laptop at home.
 Mooshak user account and password to login into online judge server
What if I need help:
1. Read the document carefully
2. Use your common sense to solve the issue yourself!
3. Ask your tutor for help
4. Ask your friends for help
B. Access to Lab machines
 Use your NUSNET to login into the machine allocated to you. You may need to press
Ctrl+Alt+Del to get to the authentication prompt first.
 Your user name must be in this format: nusext/NUSHS15-xx, where NUSHS15-xx
is your NUS user id.
 Note 1: for the first time login into machine, it takes time for setting up your account.
Please be patient! You can choose default options or well skip these settings.
 Note 2: If your machine is already turned on, you may need to “Switch Users” and
choose “Others” before you can login.
Web-browsers:
Summer 2015
Guide for Programming Assignments
page 2
There are two web-browsers for your choice: Chrome and IE.
Where to store your data:
 You can store your own data on desktop (private to your user account) or to hard
disk D (shared to everybody).
 You are recommended to back up your own data, as data on Lab machine is not
guaranteed to be secured and backed up.
C. Using IDE/Editors and programming language reference on Lab machine
You can use one of following IDE/editors available in the Lab machine for your programming
language: DevC++, drjava or cygwin console.
Using DevC++ for C++
1. To start DevC++, click on its short cut on the desktop
2. For the first time use of DevC++, you will be asked for configuration. Just use default
settings by clicking “Next”. Please be patient!
3. After that, you are ready to use DevC++.
4. Look into its menu to check for Compile/Run/Debug commands
Note 1: The program after being successfully compiled on DevC++ will be run in console mode.
If you want to see the result in the terminal window, you can insert to the end of your program
the following command:
system(“PAUSE”);
Note 2: Remember to comment out (or delete) the above command before submitting your
program to the online judge server. That command will cause a runtime error on the online
judge.
Use drjava for Java
1.
2.
3.
4.
To start drjava editor, click on its short cut on the desktop.
Write your java code
Look into the menu for compile/run/debug commands
drjava will have console windows (usually these windows are below the code area) for
you to enter input and see the output.
Use cygwin for unix-like command line console
1. cygwin folder is in the hard disk D:
2. You can write your code in any text editor available in the machine, then use command
line for compiling your code manually.
Note: You can use any other IDEs/Editors of your choice.
Language references:
Use following shortcut links on the desktop to access reference on the Internet, if you need (you
may skip it, but make sure you don’t use any features that are not stated in the reference):
C++: shortcut link: “Reference for C+10”
Java: shortcut link “Reference for Java 1.6”
Summer 2015
Guide for Programming Assignments
page 3
D. Use online judge server Mooshak
Login
1. Go to this link: http://algorithmics.comp.nus.edu.sg/~cs3230oj/
2. Wait for the server to redirect you to default page. Then click “Login” to login.
3. Login using user name and password given to you (this is Mooshak account, not NUS
account!). Remember to choose the correct assignment in the list of Contest. The picture
below shows how to login into one of the assignments for this summer course.
Summer 2015
Guide for Programming Assignments
page 4
Read the problem description
1. After login, you are ready to read the problem description and submit your program.
2. Choose the problem (e.g. A, B, or C) to view, then click “View” button to see to problem
description.
Submit your program
1. Select the problem (A or B or C, etc.) which you want to submit the solution for.
2. Choose source file to submit by clicking Chose File. Remember to name your file
with .cpp or .java before submitting.
3. Then click Submit. After that, the server will show the status of your program.
See the result and ranking
1. Choose Submissions or Ranking
2. Then click “View” button, and you will see the result of your program and your
ranking
If you don’t get “Accepted” status, you should re-do your assignment!
Summer 2015
Guide for Programming Assignments
page 5
E. Frequently Asked Questions
Q1: How should the program read its input data? How should the results of a program be
written?
A1: Input data is passed to the process through standard input and results must be written to the
standard output.
Q2: I tried to submit a solution and got the message "Program with an invalid extension"!
A2: You have to submit the source code for your program. A submission gets accepted for
evaluation only if it has a file extension corresponding to one of the accepted languages for the
contest (C++ or Java).
Q3: What languages and compilers are currently available?
A3: For this contest the analyzer accepts the following languages and uses the following
compilers:
Language
Compiler
Version
Command line
Extension
C++
g++
4.4.7
g++ -Wall -w $file
.cpp
Java
javac
1.6.0.24
javac $file -nowarn -Xlint:-deprecation
.java
Q4: What's the meaning of the evaluation messages?
A4: The evaluation messages are as follows:
your program passed all tests and is accepted as correct;
Accepted:
Compile Time Error:
the system was not able to successfully compile your program; the
compiler returned an error or warning;
Runtime Error:
your program "crashed", i.e. it exited prematurely due to a run-time
error;
Time Limit Exceeded:
your program did not finish within the given amount of time;
Wrong Answer:
your program run through one or more test cases without a run-time
error but the output did not match the expected output;
Presentation Error:
the output seems to be correct but it is not presented in the required
format. Since it is not always easy to distinguish this message from
the wrong answer message, it is only sent in obvious cases;
Invalid Submission:
your submission does not comply with expected extensions;
Output Limit Exceeded:
your program generates an output too long for this problem; the
limits are dependent on the test cases, but are usually low (limit is
around 100KB);
Program Size Exceeded:
your program is too long and will not be considered (limit is around
100KB);
Summer 2015
Guide for Programming Assignments
page 6
Q5: Are there any limits enforced by the judging system?
A5: There are several limits that if reached will penalize you:
Core size
0 Kb
Data of execute
256 Mb
Execution output
262144 Kb
Stack of execute
256 Mb
Program code
100 Kb
Real time timeout
60 sec
Compilation timeout
60 sec
Execution timeout *
1-5 sec
*) Depends also on the problem
Q6: When I press the submit button nothing happens!
A6: You must check the cache policy being used by your browser. Pages should be retrieved
from the server every time some update to the page is detected. If the pages are never requested
from the server, they will not be updated in your browser. In Mozilla and Netscape check the
"Edit" | "Preferences." | "Advanced" | "Cache" menu and choose "Every time (I view the page)".
Q7: The format of the interface has an odd appearance
A7: Try choosing a smaller font for your browser. Alternatively, try to remove the navigation
and personal bars in the browser (menu "View").
Q8: I pressed the "Submit" button and got the message "Unspecified Program".
A8: You must select the file with the source program. Press "Choose File" to open a file
selection window, and make sure you choose the correct file.
Q9: How can I ask a question regarding a problem specification?
A9: Press the "Ask" button in the upper right corner. A form will appear where you may write
your question and send it to the jury of the contest. Before pressing the "Ask" button you should
check whether you are selecting the right problem. Inform your lab tutor that you have
question, otherwise he/she may not know it.
Download