USACO Bronze 2018 February - Teleportation

Authors: Ananth Kashyap, Tanmoy Das, Thamognya Kodi


Official Analysis

Implementation

Time Complexity: O(1)\mathcal{O}(1)

Python

# Take in data using Python file i/o system
file_in = open("teleport.in")
data = file_in.read().strip().split("\n")
a, b, x, y = map(int, data[0].split(" "))
# Manually sort a, b to be increasing order
if a > b:
a, b = b, a
# Manually sort x, y to be increasing order

Java

import java.io.*;
public class Teleportation {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new FileReader("teleport.in"));
PrintWriter pw = new PrintWriter("teleport.out");
String[] input = r.readLine().split(" ");
int a = Integer.parseInt(input[0]);
int b = Integer.parseInt(input[1]);

C++

#include <bits/stdc++.h>
using namespace std;
int main() {
freopen("teleport.in", "r", stdin);
freopen("teleport.out", "w", stdout);
int a, b, c, d;
cin >> a >> b >> c >> d;
/*

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!