Last active
November 20, 2017 01:01
-
-
Save Gabrielgtt/ce50eb13f540131c1ee6add5ea745fbe to your computer and use it in GitHub Desktop.
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
# Your snippets | |
# | |
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to | |
# expand the prefix into a larger code block with templated values. | |
# | |
# You can create a new snippet in this file by typing "snip" and then hitting | |
# tab. | |
# | |
# An example CoffeeScript snippet to expand log to console.log: | |
# | |
# '.source.coffee': | |
# 'Console log': | |
# 'prefix': 'log' | |
# 'body': 'console.log $1' | |
# | |
# Each scope (e.g. '.source.coffee' above) can only be declared once. | |
# | |
# This file uses CoffeeScript Object Notation (CSON). | |
# If you are unfamiliar with CSON, you can read more about it in the | |
# Atom Flight Manual: | |
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson | |
'.source.cpp': | |
'contest': | |
'prefix': 'SHOWTIME' | |
'body': """ | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
$1 | |
return 0; | |
} | |
""" | |
'vector': | |
'prefix': 'vector' | |
'body': 'vector <${1:int}> ${2:nome};' | |
'Scanner': | |
'prefix': 'scanf' | |
'body': 'scanf("${1:%d}", &${2:n});' | |
'For loop': | |
'prefix': 'for' | |
'body': """ | |
for (int ${1:i} = 0; ${1:i} < ${2:count}; ${1:i}++) { | |
${3:/* code */} | |
} | |
""" | |
'LCA algorimth': | |
'prefix': 'buildLCA' | |
'body': """ | |
int pai[MAXN][LOGMAXN], parent[MAXN], level[MAXN]; | |
void preCompute(){ | |
memset(pai, -1, sizeof pai); | |
for (int i = 1; i <= nodes; i++){ | |
pai[i][0] = parent[i]; | |
} | |
for (int j = 1; (1 << j) < nodes; j++){ | |
for (int i = 1; i <= nodes; i++){ | |
if (pai[i][j-1] != -1){ | |
pai[i][j] = pai[pai[i][j-1]][j-1]; | |
} | |
} | |
} | |
} | |
int LCA(int u, int v){ | |
if (level[u] < level[v]) swap(u, v); | |
int pulo, dist = level[u] - level[v]; | |
while (dist > 0) { | |
pulo = log2(dist); | |
u = pai[u][pulo]; | |
dist -= (1 << pulo); | |
} | |
if (u == v) return u; | |
for (int j = log2(nodes); j >= 0; j--){ | |
if ((pai[u][j] != -1 && pai[v][j] != -1) && (pai[u][j] != pai[v][j])){ | |
u = pai[u][j]; | |
v = pai[v][j]; | |
} | |
} | |
return parent[u]; | |
} | |
""" | |
'source.coffee': | |
'Novo snippet': | |
'prefix': 'snipns' | |
'body': """ | |
'${1:nome}': | |
'prefix': '${2:atalho}' | |
'body': ${3:corpo} | |
""" | |
'.source.java': | |
'Classe simples': | |
'prefix': 'Classe' | |
'body': """ | |
public class ${1:nome}{ | |
public ${1:nome}(${2:argumentos}){ | |
$3 | |
} | |
} | |
""" | |
'Método': | |
'prefix': 'method' | |
'body': """ | |
${2:public} ${3:void} ${1:nome}(${4:/*args*/}){ | |
$5 | |
} | |
""" | |
'Comentário': | |
'prefix': 'coment' | |
'body': """ | |
/** | |
* ${1:Descricao} | |
* | |
* @param ${2:parametro} | |
* @return ${3:retorno} | |
*/ | |
""" | |
'For loop': | |
'prefix': 'for' | |
'body': """ | |
for (int ${1:i} = 0; ${1:i} < ${2:count}; ${1:i}++) { | |
${3:/* code */} | |
} | |
""" | |
'Caso de teste': | |
'prefix': 'teste' | |
'body': """ | |
@Test(expected=${1:NullPointerException}.class) | |
public void ${2:NomeDoTeste}(){ | |
${3:Classe} ${4:instancia} = new ${3:Classe}(${5:args}); | |
${6:instancia}.${7:metodo}(${8:args}); | |
fail("${9:Falha no teste}"); | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment