Swapping Numbers
This question is intended to be a basic introduction to how to submit a problem in a contest using the PCS contest server. In this question, you will need to write a program that takes two integers as input, we will call them \(x\) and \(y\) respectively. Your program will then need to output them in reverse order, that is, output \(y\) followed by \(x\). The exact details of this can be found in the Input and Output Specifications.
(Note, if maths notation shows up weirdly for you, like this \(x\)
, then you need to play with the math rendering settings. Go to the Edit Profile link under your username, and try selecting different "Math engine" settings.)
All input and output should be done using the standard input and output streams. Our system will test your program against several test files. The format of these files is described in the Input Specification. These files are fed to your program via standard input as stated. The standard output stream for your program will be recorded and checked against some expected answer. Unless otherwise stated, extra white-space (spaces and new-lines) will be ignored. If your program's output did not match, then you will get a 'wrong answer' (WA) verdict. If an error occurred, such as a segmentation fault, a compile error, a stack overflow, or an array out of bounds error, then this will be reported, and considered to be an incorrect submission.
Every question also has a time limit and a memory limit. During execution, your program cannot exceed either. See on the right for the limits. If you exceed either, this will be considered an incorrect submission. These limits are typically in place to make sure you come up with an efficient algorithm (in terms of complexity), and not a brute force solution. Sometimes, however, the time limit will allow a brute force solution intentionally. It is recommended to read the input bounds, time limit, and memory limit carefully.
If your program didn't run into any problems, you will get an 'accepted' (AC) verdict. The aim of a contest, of course, is to get as many accepted problem solutions as possible. Sometimes problems will have different point values, and so getting them correct is more valuable. That is not the case in this contest. Note that the sum of times for the last accepted solution on each problem is used a tie-breaker. There is no penalty for an incorrect submission in this contest. In a typical ICPC/ANZAC contest, there is a penalty for an incorrect submission.
Here are example programs that are not quite right in C++, Java, and Python for this question. See if you can fix them! When you are ready to submit, click Submit solution, select the right language, and paste your code in.
C++
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
cout << x << " " << y << endl;
}
Java
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt(), y = sc.nextInt();
System.out.println(x + " " + y);
}
}
Python3
from sys import stdin, stdout
x, y = [int(i) for i in stdin.readline().split()]
print(str(x) + " " + str(y))
Input Specification
The input will comprise a single line containing two space separated integers, \(x\) and \(y\) (\(1\leq x,y \leq 100\)).
Output Specification
Output a line containing two space separated integers, \(y\) and then \(x\).
Sample Input
10 9
Sample Output
9 10
Comments
For amusement's sake, here it is in Haskell: