Created
March 18, 2016 03:22
-
-
Save 648trindade/f3873c1e07041781da99 to your computer and use it in GitHub Desktop.
Arquivo de cabeçalho com definições rápidas para auxiliar na resolução de problemas de programação competitiva
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
/* | |
Arquivo de cabeçalho com definições rápidas para auxiliar na resolução de | |
problemas de programação competitiva. | |
Retirado do livro "Competitive Programming: Increasing the Lower Bound of | |
Programming Contests", de HALIM, S. e HALIM, F. | |
*/ | |
// Atalhos para tipos de dados 'comuns' em competições | |
typedef long long ll; | |
typedef vector<int> vi; | |
typedef pair<int, int> ii; | |
typedef vector<ii> vii; | |
typedef set<int> si; | |
typedef map<string, int> msi; | |
// Para simplificar laços/repetições. Note: defina seu estilo de laço e use! | |
#define REP(i, a, b) \ | |
for (int i = int(a); i <= int(b); i++) // a para b, e a variável i é local! | |
#define TRvi(c, it) \ | |
for (vi::iterator it = (c).begin(); it != (c).end(); it++) | |
#define TRvii(c, it) \ | |
for (vii::iterator it = (c).begin(); it != (c).end(); it++) | |
#define TRmsi(c, it) \ | |
for (msi::iterator it = (c).begin(); it != (c).end(); it++) | |
#define INF 2000000000 // 2 bilhões | |
// Se você precisar lembrar como usar memset: | |
#define MEMSET_INF 127 // para 2B | |
#define MEMSET_HALF_INF 63 // para 1B | |
//memset(dist, MEMSET_INF, sizeof dist); // útil para inicializar distâncias do menor caminho | |
//memset(dp_memo, -1, sizeof dp_memo); // útil para inicializar tabela de memoização DP | |
//memset(arr, 0, sizeof arr); // útil para limpar vetores de inteiros |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment