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
#define MIN(a,b) (((a) < (b)) ? (a) : (b)) | |
#ifndef SEED | |
#define SEED 1 | |
#endif | |
// Compile-time if then else | |
template<bool B, class T, class F> | |
struct ifthenelse { typedef T type; }; | |
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 <iostream> | |
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
typedef long long int lli; | |
#define MAXN 100005 | |
lli N, K; | |
lli x[MAXN + 1]; |
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 <iostream> | |
#include <utility> | |
#include <algorithm> | |
using namespace std; | |
#define mp make_pair | |
typedef long long int lli; |
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 <cstdio> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
typedef vector<int> vi; | |
typedef vector<vi> vvi; | |
#define MAX_N 30 | |
#define MAX_OPTS 1000005 |
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
/* | |
7303013 2014-08-01 04:22:45 apaapa 111A - Petya and Inequiations GNU C++ Accepted 374 ms 0 KB | |
*/ | |
#include <iostream> | |
using namespace std; | |
#define forr(i, d, h) for (int i = (d); i < (h); ++i) | |
unsigned long long int N, X, Y; |
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
/* | |
7303089 2014-08-01 04:51:42 apaapa 45D - Event Dates GNU C++ Accepted 30 ms 0 KB | |
*/ | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
#define forr(i,d,h) for (int i = (d); i < (h); ++i) | |
#define repeat(n) forr(___, 0, n) |
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
def cuenta(nums): | |
return reduce(lambda r, x : (x + 4 + r) if (x + 4 > 5) else (r), nums, 0) | |
if __name__ == '__main__': | |
print [1,2,3], "->", cuenta([1,2,3]) |
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
# -*- coding: utf-8 -*- | |
import re; | |
class Tokenizer: | |
def __init__(self, inp): | |
self.tokens = inp.lower().encode('utf8') | |
self.substitutions = [ | |
("á", "a"), ("é", "e"), ("í", "i"), ("ó", "o"), ("ú", "u"), ("[^\w]", " "), | |
("(^| )un( |$)", " uno "), ("(^| )veintiun( |$)", " veintiuno "), ("(^| )cien( |$)", " ciento "), ("(^| )millon( |$)", " millones "), ("(^| )y( |$)", " "), | |
("(^| )once( |$)", " diez uno "), ("(^| )doce( |$)", " diez dos "), ("(^| )trece( |$)", " diez tres "), ("(^| )catorce( |$)", " diez cuatro "), |
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/env python3 | |
import math; | |
########################################################################################## | |
# Basado en: http://openpool.com.ar/reglamento/T.E.G.-REGLAMENTO.pdf | |
# | |
# Probabilidad de conquistar otro pais si atacamos sin frenar hasta que: | |
# i) conquistamos el otro pais, o | |
# ii) nos quedamos con una sola ficha y no podemos atacar más |
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/env python3 | |
# -*- coding: utf-8 -*- | |
import re | |
import random | |
def myshuffle(xs): | |
for i in range(len(xs)): | |
ind = random.randint(i, len(xs) - 1) | |
xs[i], xs[ind] = xs[ind], xs[i] |
OlderNewer