This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# vim: set expandtab:ts=2:sw=2 | |
import argparse | |
import bluetooth | |
import struct | |
import sys | |
def checksum(msg): | |
checksum = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Invoke n instances of sudo in parallel. This works fine in all machines I've | |
# tried this on, except Windows Azure VMs, where occasionally invocations to | |
# sudo take ~5s to complete when n > 1. | |
# Tested on a Standard_A1 instance w/Ubuntu Utopic, kernel 3.16.0-34-generic. | |
import subprocess | |
import sys | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import Image | |
import math | |
# calculates simple two-line intersection. be warned: fails miserably with | |
# vertical lines and parallelograms. | |
def intersection(p0, p1, p2, p3): | |
m0 = (p1[1] - p0[1]) / float(p1[0] - p0[0]) | |
m2 = (p3[1] - p2[1]) / float(p3[0] - p2[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t ∈ [0, 1]; | |
x(t) = 0.0000000000000000055471625557159340725376176154529062181733718807506255520255*t^302 - 0.000000000000000073364101000888831703733953581037511007054939579810582331399*t^301 + 0.00000000000000019993660043110753520337148440192171752144851216958770618608*t^300 + 0.0000000000000025431459190353075519117623598827064762116187905095073821053*t^299 - 0.000000000000025925946645421675754267336846692479715572284533512884725878*t^298 + 0.000000000000033895461820820261658723914655701363831301259561299803770339*t^297 + 0.00000000000098435998558754374882208672660807298710459239071613885704591*t^296 - 0.0000000000068611167133899914841924408007856853142977551403882403283457*t^295 - 0.0000000000048908713957691280882664471217742259158249732413864474770153*t^294 + 0.00000000029798626331047729269718080398515232860371117604820388543549*t^293 - 0.0000000012579473080466912761750295031070320627008549897730597637288*t^292 - 0.0000000050712723859962030166333419681481068633434285144559824963219*t^291 + 0.0000000672479633 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import argparse | |
import random | |
import subprocess | |
import sys | |
import time | |
PREFIX = '/sbin/ip netns exec' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Este problema es especial porque es el primero en omegaUp de solo salida! Usualmente lo que debes esperar cuando te enfrentes con uno de esos problemas es que sea un problema NP que no tiene una solución rápida, y usualmente te pedirán que te aproximes lo más posible a la solución óptima. Esto significa que te vas a tener que valer de técnicas ad-hoc y heurísticas para sacar puntos. | |
La solución del problema es bastante sencilla de explicar: haz una búsqueda en profundidad intentando todos los posibles movimientos por fuerza bruta hasta que te salga una solución aceptable e imprímela. El problema es que esta estrategia es $O(n!)$, y como $n$ puede valer hasta 30x30, puedes esperar que el programa corria varios milenios antes de encontrar la solución óptima. Hay tres trucos (en orden de importancia) para obtener una solución decente en un tiempo razonable: | |
* No repetir estados. | |
* No "clavarse" con soluciones que parece que son muy buenas, pero en realidad llevan a callejones sin salida. | |
* Encontrar una maner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
// Todos los problemas en Java _deben_ usar Main como nombre de clase. | |
class Main { | |
public static void main(String[] args) throws IOException { | |
// Declaración del scanner para poder leer por tokens. | |
Scanner in = new Scanner(System.in); | |
int a, b, c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
class Main { | |
public static void main(String[] args) throws IOException { | |
Scanner in = new Scanner(System.in); | |
long a, b, c; | |
a = in.nextInt(); | |
b = in.nextInt(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cstring> | |
#include <cstdio> | |
#include <vector> | |
#include <boost/graph/adjacency_list.hpp> | |
#include <boost/graph/max_cardinality_matching.hpp> | |
using namespace std; | |
// Un grafo no-dirigido. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cstdio> | |
#include <queue> | |
#include <vector> | |
using namespace std; | |
#define IOI 2 | |
struct Arco { |
OlderNewer