Skip to content

Instantly share code, notes, and snippets.

View velicast's full-sized avatar

Eduar Castrillo Velilla velicast

View GitHub Profile
@velicast
velicast / c.cpp
Last active December 18, 2015 15:09
Dynamic Programming solution to problem http://codeforces.com/problemset/problem/22/B
#include <bits/stdc++.h>
using namespace std;
char b[28][28];
int dp[28][28], n, m, r;
int main() {
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
@velicast
velicast / c.cpp
Last active December 18, 2015 15:09
Dynamic Programming solution to problem http://codeforces.com/problemset/problem/66/B
#include <bits/stdc++.h>
using namespace std;
int l[1024],r[1024],h[1024];
int main() {
int n,res = 0;
cin >> n;
@velicast
velicast / huffman.m
Last active December 18, 2015 21:29
Algoritmo de Huffman. Laboratorio 4 Sistemas de comunicación.
n = input("N simbols (N >= 2): ");
cw = cell(n, n-1);
prob = zeros(n-1);
add = zeros(n-1);
for i = 1 : n
printf("p%d = ", i);
prob(i) = input("");
end
@velicast
velicast / stdc++.h
Created July 17, 2013 17:56
Linux GCC 4.8.0 /bits/stdc++.h header definition.
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@velicast
velicast / stdc++.h
Created July 17, 2013 17:58
Windows MinGW 4.6.1 "bits/stdc++.h" header definition.
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@velicast
velicast / ordered.cpp
Created July 30, 2018 20:35
Ordered Numbers en C++. Compile with g++ ordered.cpp -ansi -O3
#include <string>
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
// O(d) where d is the length of input_N
int firstIndexOfUnorderedPair(const string &input_N) {